From d9d9cd939c20d088d866c1a36aebc8a706d5e337 Mon Sep 17 00:00:00 2001 From: Allan Ritchie Date: Thu, 1 Aug 2024 21:47:36 -0400 Subject: [PATCH] Adding Acr.userDialogs.Maui --- Acr.UserDialogs.sln | 59 +++++++++++++++++++ Build.slnf | 13 ++-- readme.md | 20 +++---- sample/Sample/MauiProgram.cs | 5 +- sample/Sample/Sample.csproj | 15 ++--- .../Acr.UserDialogs.Maui.csproj | 16 +++++ src/Acr.UserDialogs.Maui/MauiExtensions.cs | 22 +++++++ src/Acr.UserDialogs/Acr.UserDialogs.csproj | 32 +--------- src/Directory.build.props | 22 +++++++ 9 files changed, 145 insertions(+), 59 deletions(-) create mode 100644 src/Acr.UserDialogs.Maui/Acr.UserDialogs.Maui.csproj create mode 100644 src/Acr.UserDialogs.Maui/MauiExtensions.cs create mode 100644 src/Directory.build.props diff --git a/Acr.UserDialogs.sln b/Acr.UserDialogs.sln index a5b0d599..b1823e20 100644 --- a/Acr.UserDialogs.sln +++ b/Acr.UserDialogs.sln @@ -12,10 +12,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build.slnf = Build.slnf icon.png = icon.png readme.md = readme.md + src\Directory.build.props = src\Directory.build.props EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "sample\Sample\Sample.csproj", "{15294F23-E346-4DD3-A0EA-FDAB8F73B9A9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Acr.UserDialogs.Maui", "src\Acr.UserDialogs.Maui\Acr.UserDialogs.Maui.csproj", "{D45ECD34-ED85-4F09-914F-0D2A566C39C3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -173,6 +176,62 @@ Global {15294F23-E346-4DD3-A0EA-FDAB8F73B9A9}.Release|x86.ActiveCfg = Release|Any CPU {15294F23-E346-4DD3-A0EA-FDAB8F73B9A9}.Release|x86.Build.0 = Release|Any CPU {15294F23-E346-4DD3-A0EA-FDAB8F73B9A9}.Release|x86.Deploy.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|Mixed Platforms.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|ARM.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|iPhone.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|Mixed Platforms.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|x64.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|x64.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|x86.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.AppStore|x86.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|ARM.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|ARM.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|iPhone.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|x64.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|x64.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|x86.ActiveCfg = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Debug|x86.Build.0 = Debug|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|Any CPU.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|ARM.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|ARM.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|iPhone.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|iPhone.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|x64.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|x64.Build.0 = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|x86.ActiveCfg = Release|Any CPU + {D45ECD34-ED85-4F09-914F-0D2A566C39C3}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Build.slnf b/Build.slnf index 77161710..ff355d68 100644 --- a/Build.slnf +++ b/Build.slnf @@ -1,8 +1,9 @@ { - "solution": { - "path": "Acr.UserDialogs.sln", - "projects": [ - "src\\Acr.UserDialogs\\Acr.UserDialogs.csproj" - ] - } + "solution": { + "path": "Acr.UserDialogs.sln", + "projects": [ + "src\\Acr.UserDialogs\\Acr.UserDialogs.csproj", + "src\\Acr.UserDialogs.Maui\\Acr.UserDialogs.Maui.csproj" + ] + } } \ No newline at end of file diff --git a/readme.md b/readme.md index b9916e0d..a9ab6131 100644 --- a/readme.md +++ b/readme.md @@ -23,17 +23,6 @@ A cross platform library that allows you to call for standard user dialogs from ## Support Platforms -v7.x Supports -* iOS 8+ -* Android -* Universal Windows Platform (Win10/UWP) -* NET Standard 2.0 - -v8.x Supports ONLY .NET 6 target -* .NET for Android (major target 12) -* .NET for iOS -* .NET for MacCatalyst - v9.x Supports ONLY .NET 8 target * .NET for Android * .NET for iOS @@ -41,6 +30,15 @@ v9.x Supports ONLY .NET 8 target ## Setup +### MAUI Users +Install Acr.UserDialogs.Maui from NuGet + +In your MauiProgram.cs, add the following + +```csharp + +``` + To use, simply reference the nuget package in each of your platform projects. If you are getting issues with System.Drawing.Color, please make sure you are using the latest version of Xamarin #### iOS and Windows diff --git a/sample/Sample/MauiProgram.cs b/sample/Sample/MauiProgram.cs index 474c9a5e..0c452dbd 100644 --- a/sample/Sample/MauiProgram.cs +++ b/sample/Sample/MauiProgram.cs @@ -1,4 +1,6 @@ -namespace Samples; +using Acr.UserDialogs; + +namespace Sample; public static class MauiProgram @@ -8,6 +10,7 @@ public static MauiApp CreateMauiApp() var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() + .UseUserDialogs() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); diff --git a/sample/Sample/Sample.csproj b/sample/Sample/Sample.csproj index 68ccb575..6d81f69a 100644 --- a/sample/Sample/Sample.csproj +++ b/sample/Sample/Sample.csproj @@ -37,14 +37,9 @@ - - - - - - - - - - + + + + + diff --git a/src/Acr.UserDialogs.Maui/Acr.UserDialogs.Maui.csproj b/src/Acr.UserDialogs.Maui/Acr.UserDialogs.Maui.csproj new file mode 100644 index 00000000..0d362ad8 --- /dev/null +++ b/src/Acr.UserDialogs.Maui/Acr.UserDialogs.Maui.csproj @@ -0,0 +1,16 @@ + + + + net8.0;net8.0-ios;net8.0-maccatalyst;net8.0-android + enable + enable + + + + + + + + + + diff --git a/src/Acr.UserDialogs.Maui/MauiExtensions.cs b/src/Acr.UserDialogs.Maui/MauiExtensions.cs new file mode 100644 index 00000000..2e9c6863 --- /dev/null +++ b/src/Acr.UserDialogs.Maui/MauiExtensions.cs @@ -0,0 +1,22 @@ +namespace Acr.UserDialogs; + + +public static class MauiExtensions +{ + public static MauiAppBuilder UseUserDialogs(this MauiAppBuilder builder) + { + #if ANDROID + UserDialogs.Init(() => Platform.CurrentActivity); + builder.Services.AddSingleton(UserDialogs.Instance); + + #elif IOS || MACCATALYST + builder.Services.AddSingleton(UserDialogs.Instance); + + #else + throw new ApplicationException("This plugin only works with .NET 8.0 for Android, iOS, and Mac Catalyst. You are calling this, but it isn't from one of those targets!"); + + #endif + + return builder; + } +} diff --git a/src/Acr.UserDialogs/Acr.UserDialogs.csproj b/src/Acr.UserDialogs/Acr.UserDialogs.csproj index 30df2970..27eb6bed 100644 --- a/src/Acr.UserDialogs/Acr.UserDialogs.csproj +++ b/src/Acr.UserDialogs/Acr.UserDialogs.csproj @@ -1,31 +1,7 @@  - net8.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net8.0-macos - $(TargetFrameworks);net8.0-windows - - https://github.com/aritchie/userdialogs + net8.0;net8.0-ios;net8.0-android;net8.0-maccatalyst $(AssemblyName) ($(TargetFramework)) - Allan Ritchie - A cross platform library that allows you to call for standard user dialogs from a shared/portable library. Supports Android, iOS, and UWP - ios android xamarin xam.pcl dialogs plugin - https://github.com/aritchie/userdialogs/raw/master/ChangeLog.md - MIT - latest - $(NoWarn);1591;1701;1591;1702;1705;VSX1000;NU1603 - https://github.com/aritchie/userdialogs - git - icon.png - readme.md - - - - True - true - true - snupkg - True - True - true @@ -33,11 +9,6 @@ - - - all - runtime; build; native; contentfiles; analyzers - @@ -63,7 +34,6 @@ -