Skip to content

Commit

Permalink
Merge pull request #105 from prostopsih/PureNetCompatibility
Browse files Browse the repository at this point in the history
feat: Add pure net to target frameworks
  • Loading branch information
Redth committed Oct 23, 2023
2 parents 676dfbb + 7c119a3 commit 4d07a9b
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI.Comet/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
global using NativePlatformView = global::Microsoft.UI.Xaml.FrameworkElement;
global using NativePlatformImageView = global::Microsoft.UI.Xaml.Controls.Image;
global using NativePlatformImage = global::Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif

using Microsoft.Extensions.DependencyInjection;
Expand Down
2 changes: 1 addition & 1 deletion ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks>net7.0;net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Comet</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
Expand Down
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
global using NativePlatformView = global::Microsoft.UI.Xaml.FrameworkElement;
global using NativePlatformImageView = global::Microsoft.UI.Xaml.Controls.Image;
global using NativePlatformImage = global::Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif

using Microsoft.Extensions.DependencyInjection;
Expand Down
2 changes: 1 addition & 1 deletion ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks>net7.0;net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Controls</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
Expand Down
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
global using NativePlatformView = global::Microsoft.UI.Xaml.FrameworkElement;
global using NativePlatformImageView = global::Microsoft.UI.Xaml.Controls.Image;
global using NativePlatformImage = global::Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif
16 changes: 16 additions & 0 deletions ZXing.Net.MAUI/Net/BarcodeWriter.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Graphics;

namespace ZXing.Net.Maui
{
public class BarcodeWriter : BarcodeWriter<NativePlatformImage>
{
public Color ForegroundColor { get; set; }

public Color BackgroundColor { get; set; }
}
}
43 changes: 43 additions & 0 deletions ZXing.Net.MAUI/Net/CameraManager.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZXing.Net.Maui
{
internal partial class CameraManager
{
public NativePlatformCameraPreviewView CreateNativeView()
{
return new NativePlatformCameraPreviewView();
}

public void Connect()
=> LogUnsupported();

public void Disconnect()
=> LogUnsupported();

public void UpdateCamera()
=> LogUnsupported();

public void UpdateTorch(bool on)
=> LogUnsupported();

public void Focus(Microsoft.Maui.Graphics.Point point)
=> LogUnsupported();

public void AutoFocus()
=> LogUnsupported();

public void Dispose()
=> LogUnsupported();

void LogUnsupported()
=> Debug.WriteLine("Camera preview is not supported on this platform.");
}
}
24 changes: 24 additions & 0 deletions ZXing.Net.MAUI/Net/NativePlatformView.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZXing.Net.Maui
{
public class NativePlatformCameraPreviewView
{
}

public class NativePlatformImageView
{
}

public class NativePlatformView
{
}

public class NativePlatformImage
{
}
}
10 changes: 8 additions & 2 deletions ZXing.Net.MAUI/ZXing.Net.MAUI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks>net7.0;net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
Expand Down Expand Up @@ -54,6 +54,9 @@
<Compile Update="**\*.windows*$(DefaultLanguageSourceExtension)">
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
</Compile>
<Compile Update="**\*.net*$(DefaultLanguageSourceExtension)">
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
</Compile>

<Compile Condition=" '$(TargetPlatformIdentifier)' == 'ios' " Update="*\*.ios*$(DefaultLanguageSourceExtension)">
<ExcludeFromCurrentConfiguration>False</ExcludeFromCurrentConfiguration>
Expand All @@ -70,17 +73,20 @@
<Compile Condition=" '$(TargetPlatformIdentifier)' == 'tizen' " Update="**\*.tizen*$(DefaultLanguageSourceExtension)">
<ExcludeFromCurrentConfiguration>False</ExcludeFromCurrentConfiguration>
</Compile>
<Compile Condition=" '$(TargetPlatformIdentifier)' == '' " Update="**\*.net*$(DefaultLanguageSourceExtension)">
<ExcludeFromCurrentConfiguration>False</ExcludeFromCurrentConfiguration>
</Compile>

</ItemGroup>


<Target Name="_MauiRemovePlatformFileNamePatternCompileItems" BeforeTargets="_MauiRemovePlatformCompileItems">
<ItemGroup>
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.ios*$(DefaultLanguageSourceExtension)" />
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.maccatalyst*$(DefaultLanguageSourceExtension)" />
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.android*$(DefaultLanguageSourceExtension)" />
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.windows*$(DefaultLanguageSourceExtension)" />
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.tizen*$(DefaultLanguageSourceExtension)" />
<Compile Condition=" '%(Compile.ExcludeFromCurrentConfiguration)' == 'true' " Remove="**\*.net*$(DefaultLanguageSourceExtension)" />
</ItemGroup>
</Target>
</Project>

0 comments on commit 4d07a9b

Please sign in to comment.