From d51f646e5cf4df8e9d55c380495e681896469129 Mon Sep 17 00:00:00 2001 From: DJYohann Date: Sat, 17 Jun 2023 15:24:53 +0200 Subject: [PATCH] :sparkles: Add pagination + selected item --- App/App.csproj | 3 + App/AppShell.xaml.cs | 1 - App/MauiProgram.cs | 10 +- App/Pages/ChampionDetailPage.xaml.cs | 6 +- App/Pages/ChampionsListPage.xaml | 20 ++-- App/Pages/ChampionsListPage.xaml.cs | 22 ++--- App/ViewModel/ChampionListPageVM.cs | 33 +++++++ ViewModel/BaseToolkit.cs | 8 +- ViewModel/ChampionManagerVM.cs | 92 ++++++++++++++++--- ViewModel/ChampionVM.cs | 32 +++---- ViewModel/Platforms/Android/PlatformClass1.cs | 7 ++ .../Platforms/MacCatalyst/PlatformClass1.cs | 7 ++ ViewModel/Platforms/Tizen/PlatformClass1.cs | 9 ++ ViewModel/Platforms/Windows/PlatformClass1.cs | 7 ++ ViewModel/Platforms/iOS/PlatformClass1.cs | 7 ++ ViewModel/ViewModel.csproj | 30 ++++-- 16 files changed, 223 insertions(+), 71 deletions(-) create mode 100644 App/ViewModel/ChampionListPageVM.cs create mode 100644 ViewModel/Platforms/Android/PlatformClass1.cs create mode 100644 ViewModel/Platforms/MacCatalyst/PlatformClass1.cs create mode 100644 ViewModel/Platforms/Tizen/PlatformClass1.cs create mode 100644 ViewModel/Platforms/Windows/PlatformClass1.cs create mode 100644 ViewModel/Platforms/iOS/PlatformClass1.cs diff --git a/App/App.csproj b/App/App.csproj index 855fd29..5c8fe88 100644 --- a/App/App.csproj +++ b/App/App.csproj @@ -52,17 +52,20 @@ + + + diff --git a/App/AppShell.xaml.cs b/App/AppShell.xaml.cs index dc45408..7dd4687 100644 --- a/App/AppShell.xaml.cs +++ b/App/AppShell.xaml.cs @@ -8,7 +8,6 @@ public partial class AppShell : Shell { InitializeComponent(); - Routing.RegisterRoute(nameof(ChampionAddEditPage), typeof(ChampionAddEditPage)); Routing.RegisterRoute(nameof(ChampionDetailPage), typeof(ChampionDetailPage)); } } diff --git a/App/MauiProgram.cs b/App/MauiProgram.cs index f3a6caf..c19fcc0 100644 --- a/App/MauiProgram.cs +++ b/App/MauiProgram.cs @@ -1,8 +1,10 @@ using Microsoft.Extensions.Logging; +using CommunityToolkit.Maui; using Model; using StubLib; using ViewModel; using App.Pages; +using App.ViewModel; namespace App; @@ -13,14 +15,16 @@ public static class MauiProgram var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() - .ConfigureFonts(fonts => + .UseMauiCommunityToolkit() + .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }) .Services.AddSingleton() - .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton() + .AddSingleton(); #if DEBUG builder.Logging.AddDebug(); diff --git a/App/Pages/ChampionDetailPage.xaml.cs b/App/Pages/ChampionDetailPage.xaml.cs index b84ded8..2516ca8 100644 --- a/App/Pages/ChampionDetailPage.xaml.cs +++ b/App/Pages/ChampionDetailPage.xaml.cs @@ -6,15 +6,15 @@ public partial class ChampionDetailPage : ContentPage { public ChampionVM ChampionVM { get; private set; } - public ChampionDetailPage(ChampionVM championVM) + public ChampionDetailPage() { - ChampionVM = championVM; + //ChampionVM = championVM; InitializeComponent(); BindingContext = ChampionVM; } async void ToolbarItem_Clicked(System.Object sender, System.EventArgs e) { - await Navigation.PushAsync(new ChampionAddEditPage()); + await Navigation.PushModalAsync(new ChampionAddEditPage()); } } diff --git a/App/Pages/ChampionsListPage.xaml b/App/Pages/ChampionsListPage.xaml index 9b6ca4f..b570af4 100644 --- a/App/Pages/ChampionsListPage.xaml +++ b/App/Pages/ChampionsListPage.xaml @@ -2,10 +2,11 @@ - + @@ -24,9 +25,14 @@ + + + + @@ -60,11 +66,11 @@ -