Skip to content

Commit

Permalink
Adding Acr.userDialogs.Maui
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Aug 2, 2024
1 parent 065d8e3 commit d9d9cd9
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 59 deletions.
59 changes: 59 additions & 0 deletions Acr.UserDialogs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions Build.slnf
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
20 changes: 9 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@ 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
* .NET for MacCatalyst

## 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
Expand Down
5 changes: 4 additions & 1 deletion sample/Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Samples;
using Acr.UserDialogs;

namespace Sample;


public static class MauiProgram
Expand All @@ -8,6 +10,7 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseUserDialogs()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down
15 changes: 5 additions & 10 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@
<MauiFont Include="Resources\Fonts\*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
<ProjectReference Include="..\..\src\Acr.UserDialogs\Acr.UserDialogs.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Raw\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\Raw\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
<ProjectReference Include="..\..\src\Acr.UserDialogs.Maui\Acr.UserDialogs.Maui.csproj" />
<ProjectReference Include="..\..\src\Acr.UserDialogs\Acr.UserDialogs.csproj" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions src/Acr.UserDialogs.Maui/Acr.UserDialogs.Maui.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-ios;net8.0-maccatalyst;net8.0-android</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Acr.UserDialogs\Acr.UserDialogs.csproj" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions src/Acr.UserDialogs.Maui/MauiExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
32 changes: 1 addition & 31 deletions src/Acr.UserDialogs/Acr.UserDialogs.csproj
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net8.0-macos</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows</TargetFrameworks>
<!--<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>-->
<PackageProjectUrl>https://github.com/aritchie/userdialogs</PackageProjectUrl>
<TargetFrameworks>net8.0;net8.0-ios;net8.0-android;net8.0-maccatalyst</TargetFrameworks>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Authors>Allan Ritchie</Authors>
<Description>A cross platform library that allows you to call for standard user dialogs from a shared/portable library. Supports Android, iOS, and UWP</Description>
<PackageTags>ios android xamarin xam.pcl dialogs plugin</PackageTags>
<PackageReleaseNotes>https://github.com/aritchie/userdialogs/raw/master/ChangeLog.md</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1591;1701;1591;1702;1705;VSX1000;NU1603</NoWarn>
<RepositoryUrl>https://github.com/aritchie/userdialogs</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<IncludeSource>True</IncludeSource>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>True</PublishRepositoryUrl>
<EmbedUntrackedSources>True</EmbedUntrackedSources>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true' OR '$(CI)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<None Include="$(SolutionDir)icon.png" Pack="true" PackagePath="icon.png" />
<None Include="$(SolutionDir)readme.md" Pack="true" PackagePath="readme.md" />
<None Include="Platforms\**\*.*" />
<Compile Remove="Platforms\**\*.*" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('android'))">
Expand All @@ -63,7 +34,6 @@
<Compile Include="Platforms\Windows\**\*.cs" />
<Page Include="Platforms\Windows\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
<Compile Update="Platforms\Windows\**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />

<!--
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
Expand Down
22 changes: 22 additions & 0 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<Authors>Allan Ritchie</Authors>
<PackageProjectUrl>https://github.com/aritchie/userdialogs</PackageProjectUrl>
<Description>A cross platform library that allows you to call for standard user dialogs from a shared/portable library. Supports Android, iOS, and UWP</Description>
<PackageTags>ios android xamarin xam.pcl dialogs plugin</PackageTags>
<PackageReleaseNotes>https://github.com/aritchie/userdialogs/raw/master/ChangeLog.md</PackageReleaseNotes>
<PackageIconUrl>https://github.com/aritchie/userdialogs/raw/master/icon.png</PackageIconUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1591;1701;1591;1702;1705;VSX1000;NU1603</NoWarn>
<RepositoryUrl>https://github.com/aritchie/userdialogs</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

0 comments on commit d9d9cd9

Please sign in to comment.