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 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Pages/ChampionsListPage.xaml.cs b/App/Pages/ChampionsListPage.xaml.cs
index 34f9853..0145309 100644
--- a/App/Pages/ChampionsListPage.xaml.cs
+++ b/App/Pages/ChampionsListPage.xaml.cs
@@ -15,14 +15,11 @@ public partial class ChampionsListPage : ContentPage
async void AddClicked(System.Object sender, System.EventArgs e)
{
- await Shell.Current.GoToAsync(nameof(ChampionAddEditPage));
+ await Navigation.PushAsync(new ChampionAddEditPage());
}
async void ListView_ItemSelected(System.Object sender, Microsoft.Maui.Controls.SelectedItemChangedEventArgs e)
{
- await Shell.Current.GoToAsync(nameof(ChampionDetailPage), true, new Dictionary
- {
- { "ChampionVM", e.SelectedItem }
- });
+ await Navigation.PushAsync(new ChampionDetailPage(e.SelectedItem as ChampionVM));
}
}
diff --git a/App/Platforms/iOS/Program.cs b/App/Platforms/iOS/Program.cs
index a8da03b..07cdc01 100644
--- a/App/Platforms/iOS/Program.cs
+++ b/App/Platforms/iOS/Program.cs
@@ -10,7 +10,7 @@ public class Program
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
- UIApplication.Main(args, null, typeof(AppDelegate));
+ UIApplication.Main(args, null, typeof(AppDelegate));
}
}
diff --git a/App/Resources/Styles/Colors.xaml b/App/Resources/Styles/Colors.xaml
index b72af37..bd119a9 100644
--- a/App/Resources/Styles/Colors.xaml
+++ b/App/Resources/Styles/Colors.xaml
@@ -17,6 +17,10 @@
#404040
#212121
#141414
+
+ #AEAEB1
+ #FE3C30
+
diff --git a/LeagueOfLegends.sln b/LeagueOfLegends.sln
index 01782d8..ca9fded 100644
--- a/LeagueOfLegends.sln
+++ b/LeagueOfLegends.sln
@@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A88951E3
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "App\App.csproj", "{9A58F419-4627-4656-9C36-959DA39A55E9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{7A222D06-D84F-4DA7-ADCC-71D339261117}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{75E3813D-87BE-4837-B318-916CFA6A276F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -43,10 +43,10 @@ Global
{9A58F419-4627-4656-9C36-959DA39A55E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A58F419-4627-4656-9C36-959DA39A55E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A58F419-4627-4656-9C36-959DA39A55E9}.Release|Any CPU.Build.0 = Release|Any CPU
- {7A222D06-D84F-4DA7-ADCC-71D339261117}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7A222D06-D84F-4DA7-ADCC-71D339261117}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7A222D06-D84F-4DA7-ADCC-71D339261117}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7A222D06-D84F-4DA7-ADCC-71D339261117}.Release|Any CPU.Build.0 = Release|Any CPU
+ {75E3813D-87BE-4837-B318-916CFA6A276F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {75E3813D-87BE-4837-B318-916CFA6A276F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {75E3813D-87BE-4837-B318-916CFA6A276F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {75E3813D-87BE-4837-B318-916CFA6A276F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ViewModel/ChampionManagerVM.cs b/ViewModel/ChampionManagerVM.cs
index f65ef78..9cd6c0b 100644
--- a/ViewModel/ChampionManagerVM.cs
+++ b/ViewModel/ChampionManagerVM.cs
@@ -48,6 +48,24 @@ namespace ViewModel
await LoadChampions();
}
+ public int NbPages => NbChampions / Count;
+
+ public int NbChampions
+ {
+ get => _nbChampions;
+ set
+ {
+ _nbChampions = value;
+ }
+ }
+ private int _nbChampions;
+
+ private async Task GetNbChampions()
+ {
+ NbChampions = await DataManager.ChampionsMgr.GetNbItems();
+ OnPropertyChanged(nameof(NbPages));
+ }
+
private async Task LoadChampions()
{
_championVMs.Clear();
diff --git a/ViewModel/ChampionVM.cs b/ViewModel/ChampionVM.cs
index 8236d66..0a99621 100644
--- a/ViewModel/ChampionVM.cs
+++ b/ViewModel/ChampionVM.cs
@@ -1,4 +1,5 @@
using Model;
+using System;
namespace ViewModel
{
@@ -9,7 +10,7 @@ namespace ViewModel
get => _model;
set
{
- //if (_model.Equals(value) || _model.Equals(null)) return;
+ if (_model.Equals(value) || value == null) return;
_model = value;
OnPropertyChanged();
}
@@ -19,12 +20,12 @@ namespace ViewModel
public ChampionVM(Champion model)
{
- Model = model;
+ _model = model;
}
public ChampionVM()
{
- Model = new Champion("Poppy", ChampionClass.Tank);
+ _model = new Champion("Poppy", ChampionClass.Tank);
}
public string Name
@@ -42,5 +43,32 @@ namespace ViewModel
OnPropertyChanged();
}
}
+
+ public string Icon
+ {
+ get => Model.Icon;
+ set
+ {
+ if (value == null) return;
+ _model.Icon = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public string Image
+ {
+ get => Model.Image.Base64;
+ set
+ {
+ if (value == null) return;
+ _model.Image.Base64 = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public IReadOnlyDictionary Characteristics
+ {
+ get => Model.Characteristics;
+ }
}
}
\ No newline at end of file