From c7fae3996a9a2fe55277516983bcd96c2a4a7665 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk Date: Mon, 3 Apr 2023 23:54:47 +0300 Subject: [PATCH 01/34] BadgeCounter #807 --- .../AppShell.xaml.cs | 1 + .../MauiProgram.cs | 3 ++ .../Pages/Essentials/BadgeCounterPage.xaml | 43 +++++++++++++++++++ .../Pages/Essentials/BadgeCounterPage.xaml.cs | 11 +++++ .../Platforms/Android/AndroidManifest.xml | 34 +++++++++++++++ .../Essentials/BadgeCounterViewModel.cs | 32 ++++++++++++++ .../Essentials/EssentialsGalleryViewModel.cs | 1 + .../CommunityToolkit.Maui.Core.csproj | 4 ++ .../BadgeCounter/BadgeCounter.shared.cs | 20 +++++++++ .../BadgeCounterImplementation.android.cs | 29 +++++++++++++ .../BadgeCounterImplementation.macios.cs | 17 ++++++++ .../BadgeCounterImplementation.net.cs | 11 +++++ .../BadgeCounterImplementation.tizen.cs | 31 +++++++++++++ .../BadgeCounterImplementation.windows.cs | 28 ++++++++++++ .../BadgeCounter/IBadgeCounter.shared.cs | 13 ++++++ .../Essentials/BadgeCounterTests.cs | 24 +++++++++++ .../Mocks/BadgeCounterImplementationMock.cs | 11 +++++ 17 files changed, 313 insertions(+) create mode 100644 samples/CommunityToolkit.Maui.Sample/Pages/Essentials/BadgeCounterPage.xaml create mode 100644 samples/CommunityToolkit.Maui.Sample/Pages/Essentials/BadgeCounterPage.xaml.cs create mode 100644 samples/CommunityToolkit.Maui.Sample/ViewModels/Essentials/BadgeCounterViewModel.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounter.shared.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounterImplementation.android.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounterImplementation.macios.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounterImplementation.net.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounterImplementation.tizen.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/BadgeCounterImplementation.windows.cs create mode 100644 src/CommunityToolkit.Maui.Core/Essentials/BadgeCounter/IBadgeCounter.shared.cs create mode 100644 src/CommunityToolkit.Maui.UnitTests/Essentials/BadgeCounterTests.cs create mode 100644 src/CommunityToolkit.Maui.UnitTests/Mocks/BadgeCounterImplementationMock.cs diff --git a/samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs b/samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs index 55a555c9b..1659b4547 100644 --- a/samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs +++ b/samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs @@ -82,6 +82,7 @@ public partial class AppShell : Shell CreateViewModelMapping(), // Add Essentials View Models + CreateViewModelMapping(), CreateViewModelMapping(), CreateViewModelMapping(), diff --git a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs index 2bce37b94..1b432977f 100644 --- a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs +++ b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs @@ -1,3 +1,4 @@ +using CommunityToolkit.Maui.BadgeCounter; using CommunityToolkit.Maui.Markup; using CommunityToolkit.Maui.Sample.Models; using CommunityToolkit.Maui.Sample.Pages; @@ -151,6 +152,7 @@ static void RegisterViewsAndViewModels(in IServiceCollection services) services.AddTransientWithShellRoute(); // Add Essentials Pages + ViewModels + services.AddTransientWithShellRoute(); services.AddTransientWithShellRoute(); services.AddTransientWithShellRoute(); @@ -187,6 +189,7 @@ static void RegisterEssentials(in IServiceCollection services) services.AddSingleton(DeviceDisplay.Current); services.AddSingleton(FileSaver.Default); services.AddSingleton(FolderPicker.Default); + services.AddSingleton(BadgeCounter.BadgeCounter.Default); } static IServiceCollection AddTransientWithShellRoute(this IServiceCollection services) where TPage : BasePage diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/BadgeCounterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/BadgeCounterPage.xaml new file mode 100644 index 000000000..e88b274c0 --- /dev/null +++ b/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/BadgeCounterPage.xaml @@ -0,0 +1,43 @@ + + + + + +