From 0ec83e281392df8cfe16e4200ceff4c3eb85f3da Mon Sep 17 00:00:00 2001 From: DJYohann Date: Wed, 7 Jun 2023 00:15:39 +0200 Subject: [PATCH] :sparkles: Add champion detail page and addedit page --- App/App.csproj | 2 +- App/Converters/Base64ToImage.cs | 26 +++++++++++ App/MauiProgram.cs | 5 +- App/Pages/ChampionAddEditPage.xaml | 47 +++++++++++++++---- App/Pages/ChampionDetailPage.xaml | 57 +++++++++++++++++++--- App/Pages/ChampionDetailPage.xaml.cs | 12 +++-- App/Pages/ChampionsListPage.xaml | 70 ++++++++++++++++++++++++---- App/Pages/ChampionsListPage.xaml.cs | 7 +-- App/Platforms/iOS/Program.cs | 2 +- App/Resources/Styles/Colors.xaml | 4 ++ LeagueOfLegends.sln | 10 ++-- ViewModel/ChampionManagerVM.cs | 18 +++++++ ViewModel/ChampionVM.cs | 34 ++++++++++++-- 13 files changed, 247 insertions(+), 47 deletions(-) create mode 100644 App/Converters/Base64ToImage.cs diff --git a/App/App.csproj b/App/App.csproj index 7525df6..855fd29 100644 --- a/App/App.csproj +++ b/App/App.csproj @@ -70,7 +70,7 @@ - + diff --git a/App/Converters/Base64ToImage.cs b/App/Converters/Base64ToImage.cs new file mode 100644 index 0000000..ba220f9 --- /dev/null +++ b/App/Converters/Base64ToImage.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; + +namespace App.Converters +{ + public class Base64ToImage : IValueConverter + { + public Base64ToImage() + { + + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var bytes = System.Convert.FromBase64String(value as string); + MemoryStream imageDecode = new MemoryStream(bytes); + return ImageSource.FromStream(() => imageDecode); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} + diff --git a/App/MauiProgram.cs b/App/MauiProgram.cs index 9b09708..f3a6caf 100644 --- a/App/MauiProgram.cs +++ b/App/MauiProgram.cs @@ -20,10 +20,7 @@ public static class MauiProgram }) .Services.AddSingleton() .AddSingleton() - .AddSingleton() - - .AddTransient() - .AddTransient(); + .AddSingleton(); #if DEBUG builder.Logging.AddDebug(); diff --git a/App/Pages/ChampionAddEditPage.xaml b/App/Pages/ChampionAddEditPage.xaml index 25ee6d1..8692069 100644 --- a/App/Pages/ChampionAddEditPage.xaml +++ b/App/Pages/ChampionAddEditPage.xaml @@ -2,16 +2,47 @@ - - + xmlns:converters="clr-namespace:App.Converters" + Title="Add Champion" + BackgroundColor="Black"> + + - + + + + - diff --git a/App/Pages/ChampionDetailPage.xaml b/App/Pages/ChampionDetailPage.xaml index f6b1604..80f3cb6 100644 --- a/App/Pages/ChampionDetailPage.xaml +++ b/App/Pages/ChampionDetailPage.xaml @@ -1,12 +1,55 @@  - - + Title="Champion Page" + BackgroundColor="Black"> + + + + + + + + + + + + + + + + + + + + + diff --git a/App/Pages/ChampionDetailPage.xaml.cs b/App/Pages/ChampionDetailPage.xaml.cs index d321107..b84ded8 100644 --- a/App/Pages/ChampionDetailPage.xaml.cs +++ b/App/Pages/ChampionDetailPage.xaml.cs @@ -4,11 +4,17 @@ namespace App.Pages; public partial class ChampionDetailPage : ContentPage { - //public ChampionVM ChampionVM { get; private set; } + public ChampionVM ChampionVM { get; private set; } public ChampionDetailPage(ChampionVM championVM) { - InitializeComponent(); - BindingContext = championVM; + ChampionVM = championVM; + InitializeComponent(); + BindingContext = ChampionVM; + } + + async void ToolbarItem_Clicked(System.Object sender, System.EventArgs e) + { + await Navigation.PushAsync(new ChampionAddEditPage()); } } diff --git a/App/Pages/ChampionsListPage.xaml b/App/Pages/ChampionsListPage.xaml index 4e46368..9b6ca4f 100644 --- a/App/Pages/ChampionsListPage.xaml +++ b/App/Pages/ChampionsListPage.xaml @@ -1,20 +1,70 @@  - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +