diff --git a/Firebase.Auth.sln b/Firebase.Auth.sln index 742b844..5828da2 100644 --- a/Firebase.Auth.sln +++ b/Firebase.Auth.sln @@ -47,6 +47,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Auth.UI.WinUI3", "src\Auth. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Auth.WinUI3.Sample", "samples\WinUI3\Auth.WinUI3.Sample.csproj", "{4D7E8D5F-9DB9-46B3-99F3-2D768BBAA92D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Auth.UI.MAUI", "src\Auth.UI.MAUI\Auth.UI.MAUI.csproj", "{08B76970-ACB8-4823-AEEA-4E2F32CADD47}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Auth.MAUI.Sample", "samples\MAUI\Auth.MAUI.Sample.csproj", "{249C7854-09D3-4137-BFF1-D32FE972488A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -299,6 +303,56 @@ Global {4D7E8D5F-9DB9-46B3-99F3-2D768BBAA92D}.Release|x86.ActiveCfg = Release|x86 {4D7E8D5F-9DB9-46B3-99F3-2D768BBAA92D}.Release|x86.Build.0 = Release|x86 {4D7E8D5F-9DB9-46B3-99F3-2D768BBAA92D}.Release|x86.Deploy.0 = Release|x86 + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|ARM.ActiveCfg = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|ARM.Build.0 = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|ARM64.Build.0 = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|x64.ActiveCfg = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|x64.Build.0 = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|x86.ActiveCfg = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Debug|x86.Build.0 = Debug|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|Any CPU.Build.0 = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|ARM.ActiveCfg = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|ARM.Build.0 = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|ARM64.ActiveCfg = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|ARM64.Build.0 = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|x64.ActiveCfg = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|x64.Build.0 = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|x86.ActiveCfg = Release|Any CPU + {08B76970-ACB8-4823-AEEA-4E2F32CADD47}.Release|x86.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM.Build.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM.Deploy.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM64.Build.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|ARM64.Deploy.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x64.ActiveCfg = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x64.Build.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x64.Deploy.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x86.ActiveCfg = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x86.Build.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Debug|x86.Deploy.0 = Debug|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|Any CPU.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|Any CPU.Deploy.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM.ActiveCfg = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM.Deploy.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM64.ActiveCfg = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM64.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|ARM64.Deploy.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x64.ActiveCfg = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x64.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x64.Deploy.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x86.ActiveCfg = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x86.Build.0 = Release|Any CPU + {249C7854-09D3-4137-BFF1-D32FE972488A}.Release|x86.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -310,6 +364,7 @@ Global {31FAEF42-D294-4269-94B8-D5AE76CDF964} = {5528D6EA-402F-4FD9-9A01-0B799AFFC14B} {69BFF1A9-8384-4DD8-BD23-31E384D57499} = {5528D6EA-402F-4FD9-9A01-0B799AFFC14B} {4D7E8D5F-9DB9-46B3-99F3-2D768BBAA92D} = {CF8B7ECC-0E53-4B26-ABB3-0D74BDBB642F} + {249C7854-09D3-4137-BFF1-D32FE972488A} = {CF8B7ECC-0E53-4B26-ABB3-0D74BDBB642F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EBE8EC40-A988-4401-8C7E-61E1165C7D46} diff --git a/build/build-libs.ps1 b/build/build-libs.ps1 index 3720dd2..176f299 100644 --- a/build/build-libs.ps1 +++ b/build/build-libs.ps1 @@ -2,4 +2,5 @@ dotnet build --configuration release .\src\Auth.UI\Auth.UI.csproj dotnet build --configuration release .\src\Auth.UI.WPF\Auth.UI.WPF.csproj dotnet build --configuration release .\src\Auth.UI.WinUI3\Auth.UI.WinUI3.csproj -msbuild /restore /p:Configuration=Release .\src\Auth.UI.UWP\Auth.UI.UWP.csproj \ No newline at end of file +msbuild /restore /p:Configuration=Release .\src\Auth.UI.UWP\Auth.UI.UWP.csproj +dotnet build --configuration release .\src\Auth.UI.MAUI\Auth.UI.MAUI.csproj \ No newline at end of file diff --git a/build/build-samples.ps1 b/build/build-samples.ps1 index adb0509..774b282 100644 --- a/build/build-samples.ps1 +++ b/build/build-samples.ps1 @@ -1,4 +1,5 @@ dotnet build --configuration release .\samples\Console\Auth.Console.Sample.csproj dotnet build --configuration release .\samples\WPF\Auth.WPF.Sample.csproj dotnet build --configuration release .\samples\WinUI3\Auth.WinUI3.Sample.csproj -msbuild /restore /p:Configuration=Debug .\samples\UWP\Auth.UWP.Sample.csproj \ No newline at end of file +msbuild /restore /p:Configuration=Debug .\samples\UWP\Auth.UWP.Sample.csproj +dotnet build --configuration release .\samples\MAUI\Auth.MAUI.Sample.csproj \ No newline at end of file diff --git a/build/run-pack.ps1 b/build/run-pack.ps1 index f5d89ef..62a4b50 100644 --- a/build/run-pack.ps1 +++ b/build/run-pack.ps1 @@ -9,6 +9,7 @@ if ($preview) { dotnet pack --configuration release --output $output --version-suffix=$suffix .\src\Auth.UI.WPF\Auth.UI.WPF.csproj dotnet pack --configuration release --output $output --version-suffix=$suffix .\src\Auth.UI.WinUI3\Auth.UI.WinUI3.csproj msbuild /t:restore,pack /p:Configuration=Release /p:PackageOutputPath=$output /p:VersionSuffix=$suffix .\src\Auth.UI.UWP\Auth.UI.UWP.csproj + dotnet pack --configuration release --output $output --version-suffix=$suffix .\src\Auth.UI.MAUI\Auth.UI.MAUI.csproj } else { $version = $(git describe --tags --abbrev=0).substring(1) write "Creating packages with tag version $version" @@ -16,4 +17,5 @@ if ($preview) { dotnet pack --configuration release --output $output -p:version=$version .\src\Auth.UI.WPF\Auth.UI.WPF.csproj dotnet pack --configuration release --output $output -p:version=$version .\src\Auth.UI.WinUI3\Auth.UI.WinUI3.csproj msbuild /t:restore,pack /p:Configuration=Release /p:PackageOutputPath=$output /p:Version=$version .\src\Auth.UI.UWP\Auth.UI.UWP.csproj + dotnet pack --configuration release --output $output -p:version=$version .\src\Auth.UI.MAUI\Auth.UI.MAUI.csproj } \ No newline at end of file diff --git a/samples/MAUI/App.xaml b/samples/MAUI/App.xaml new file mode 100644 index 0000000..4a49538 --- /dev/null +++ b/samples/MAUI/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/samples/MAUI/App.xaml.cs b/samples/MAUI/App.xaml.cs new file mode 100644 index 0000000..fef1016 --- /dev/null +++ b/samples/MAUI/App.xaml.cs @@ -0,0 +1,47 @@ +using Firebase.Auth; +using Firebase.Auth.UI; +using Firebase.Auth.UI.MAUI; + +namespace Auth.MAUI.Sample +{ + public partial class App : Application + { + public App() + { + InitializeComponent(); + // Use Direct Navigation + UseDirectNavigation(); + // Use APP Shell + //MainPage = new AppShell(); + // Use Navigation Page + //MainPage = new AppNavigation(); + } + + private void UseDirectNavigation() + { + Router.RegisterMainType(Router.NavigationModeEnum.Direct); + MainPage = new LoginPage(); + FirebaseUI.Instance.Client.AuthStateChanged += this.AuthStateChanged; + } + private void AuthStateChanged(object sender, UserEventArgs e) + { + Application.Current.Dispatcher.DispatchAsync(async () => + { + if (e.User == null) + { + if (this.MainPage?.GetType() != Router.MainType) + await Router.NavigateToMain(); + } + else if (e.User.IsAnonymous) + { + if (this.MainPage?.GetType() != typeof(MainPage)) + MainPage = new MainPage(); + } + else if (this.MainPage?.GetType() != typeof(MainPage)) + { + MainPage = new MainPage(); + } + }); + } + } +} diff --git a/samples/MAUI/AppNavigation.xaml b/samples/MAUI/AppNavigation.xaml new file mode 100644 index 0000000..3874c6e --- /dev/null +++ b/samples/MAUI/AppNavigation.xaml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/samples/MAUI/AppNavigation.xaml.cs b/samples/MAUI/AppNavigation.xaml.cs new file mode 100644 index 0000000..684d5da --- /dev/null +++ b/samples/MAUI/AppNavigation.xaml.cs @@ -0,0 +1,39 @@ +using Firebase.Auth; +using Firebase.Auth.UI; +using Firebase.Auth.UI.MAUI; + +namespace Auth.MAUI.Sample; + +public partial class AppNavigation : NavigationPage +{ + public AppNavigation() + { + Router.RegisterMainType(Router.NavigationModeEnum.Stack); + InitializeComponent(); + + FirebaseUI.Instance.Client.AuthStateChanged += this.AuthStateChanged; + } + + private void AuthStateChanged(object sender, UserEventArgs e) + { + Application.Current.Dispatcher.DispatchAsync(async () => + { + Shell.SetBackButtonBehavior(this, new BackButtonBehavior() { IsVisible = false }); + + if (e.User == null) + { + if (this.Navigation.NavigationStack.LastOrDefault()?.GetType() != Router.MainType) + await Router.NavigateToMain(); + } + else if (e.User.IsAnonymous) + { + if (this.Navigation.NavigationStack.LastOrDefault()?.GetType() != typeof(MainPage)) + await Router.NavigateToMain(); + } + else if (this.Navigation.NavigationStack.LastOrDefault()?.GetType() != typeof(MainPage)) + { + await this.Navigation.PushAsync(new MainPage()); + } + }); + } +} \ No newline at end of file diff --git a/samples/MAUI/AppShell.xaml b/samples/MAUI/AppShell.xaml new file mode 100644 index 0000000..fd8efbe --- /dev/null +++ b/samples/MAUI/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/samples/MAUI/AppShell.xaml.cs b/samples/MAUI/AppShell.xaml.cs new file mode 100644 index 0000000..a53e44b --- /dev/null +++ b/samples/MAUI/AppShell.xaml.cs @@ -0,0 +1,39 @@ +using Firebase.Auth.UI; +using Firebase.Auth; +using Firebase.Auth.UI.MAUI; + +namespace Auth.MAUI.Sample +{ + public partial class AppShell : Shell + { + public AppShell() + { + Router.RegisterShellRoutes(); + Router.RegisterMainType(Router.NavigationModeEnum.StackModal); + InitializeComponent(); + + FirebaseUI.Instance.Client.AuthStateChanged += this.AuthStateChanged; + } + + private void AuthStateChanged(object sender, UserEventArgs e) + { + Application.Current.Dispatcher.DispatchAsync(async () => + { + if (e.User == null) + { + if (this.CurrentPage.GetType() != Router.MainType) + await Router.NavigateToMain(); + } + else if (e.User.IsAnonymous) + { + if (this.CurrentPage.GetType() != typeof(MainPage)) + await GoToAsync(nameof(MainPage)); + } + else if (this.CurrentPage.GetType() != typeof(MainPage)) + { + await GoToAsync(nameof(MainPage)); + } + }); + } + } +} diff --git a/samples/MAUI/Auth.MAUI.Sample.csproj b/samples/MAUI/Auth.MAUI.Sample.csproj new file mode 100644 index 0000000..4353afd --- /dev/null +++ b/samples/MAUI/Auth.MAUI.Sample.csproj @@ -0,0 +1,77 @@ + + + + net8.0-android;net8.0-ios;net8.0-maccatalyst + $(TargetFrameworks);net8.0-windows10.0.19041.0 + + + + + + + Exe + Auth.MAUI.Sample + true + true + enable + + + Auth.MAUI.Sample + + + com.companyname.auth.maui.sample + + + 1.0 + 1 + + 11.0 + 13.1 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + + diff --git a/samples/MAUI/LoginPage.xaml b/samples/MAUI/LoginPage.xaml new file mode 100644 index 0000000..13b02a9 --- /dev/null +++ b/samples/MAUI/LoginPage.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/MAUI/LoginPage.xaml.cs b/samples/MAUI/LoginPage.xaml.cs new file mode 100644 index 0000000..2af5580 --- /dev/null +++ b/samples/MAUI/LoginPage.xaml.cs @@ -0,0 +1,9 @@ +namespace Auth.MAUI.Sample; + +public partial class LoginPage : ContentPage +{ + public LoginPage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/samples/MAUI/MainPage.xaml b/samples/MAUI/MainPage.xaml new file mode 100644 index 0000000..ae81c58 --- /dev/null +++ b/samples/MAUI/MainPage.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + +