From 1cab36362e44e039328d9b84b58e39caaefac497 Mon Sep 17 00:00:00 2001 From: Matheo HERSAN Date: Fri, 2 Jun 2023 11:04:55 +0200 Subject: [PATCH] Added UserControl for listPage --- MangaMap/MangaMap.csproj | 6 + MangaMap/Views/Composants/ListOeuvre.xaml | 167 ++++++++++++++++++ MangaMap/Views/Composants/ListOeuvre.xaml.cs | 23 +++ MangaMap/Views/Composants/StyleBouton.xaml | 5 +- MangaMap/Views/Composants/StyleBouton.xaml.cs | 21 ++- MangaMap/Views/FicheAnime.xaml.cs | 9 +- MangaMap/Views/homePage.xaml | 2 +- MangaMap/Views/listPage.xaml | 167 +----------------- MangaMap/Views/listPage.xaml.cs | 16 +- 9 files changed, 228 insertions(+), 188 deletions(-) create mode 100644 MangaMap/Views/Composants/ListOeuvre.xaml create mode 100644 MangaMap/Views/Composants/ListOeuvre.xaml.cs diff --git a/MangaMap/MangaMap.csproj b/MangaMap/MangaMap.csproj index 5d2ca9a..47f3e18 100644 --- a/MangaMap/MangaMap.csproj +++ b/MangaMap/MangaMap.csproj @@ -72,6 +72,9 @@ CustomHeader.xaml + + ListOeuvre.xaml + createOeuvre.xaml @@ -90,6 +93,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/MangaMap/Views/Composants/ListOeuvre.xaml b/MangaMap/Views/Composants/ListOeuvre.xaml new file mode 100644 index 0000000..dfb576e --- /dev/null +++ b/MangaMap/Views/Composants/ListOeuvre.xaml @@ -0,0 +1,167 @@ + + + + + + + + diff --git a/MangaMap/Views/Composants/ListOeuvre.xaml.cs b/MangaMap/Views/Composants/ListOeuvre.xaml.cs new file mode 100644 index 0000000..bbfe072 --- /dev/null +++ b/MangaMap/Views/Composants/ListOeuvre.xaml.cs @@ -0,0 +1,23 @@ +namespace MangaMap.Views.Composants; +using MangaMap.Model; + +public partial class ListOeuvre : ContentView +{ + public Manager my_manager => (App.Current as App).MyManager; + + public ListOeuvre() + { + InitializeComponent(); + BindingContext = my_manager; + } + + private async void AnimeImageClickedList(object sender, EventArgs e) + { + var selectedAnime = (sender as ImageButton)?.BindingContext as Oeuvre; + if (selectedAnime != null) + { + // Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné + await Navigation.PushAsync(new ficheAnime(selectedAnime)); + } + } +} \ No newline at end of file diff --git a/MangaMap/Views/Composants/StyleBouton.xaml b/MangaMap/Views/Composants/StyleBouton.xaml index 3df2ca1..ef39115 100644 --- a/MangaMap/Views/Composants/StyleBouton.xaml +++ b/MangaMap/Views/Composants/StyleBouton.xaml @@ -4,9 +4,8 @@ x:Class="MangaMap.Views.Composants.StyleBouton"> + Clicked="AnimeImageClickedList"/> diff --git a/MangaMap/Views/Composants/StyleBouton.xaml.cs b/MangaMap/Views/Composants/StyleBouton.xaml.cs index 94bf0f5..165852d 100644 --- a/MangaMap/Views/Composants/StyleBouton.xaml.cs +++ b/MangaMap/Views/Composants/StyleBouton.xaml.cs @@ -1,14 +1,23 @@ namespace MangaMap.Views.Composants; +using MangaMap.Model; public partial class StyleBouton : ContentView { - public StyleBouton() + public Manager my_manager => (App.Current as App).MyManager; + + public StyleBouton() { InitializeComponent(); - } + BindingContext = my_manager; + } - private async void ButtonIsPressed(object sender, EventArgs e) - { - await Shell.Current.Navigation.PushAsync(new ficheAnime()); - } + private async void AnimeImageClickedList(object sender, EventArgs e) + { + var selectedAnime = (sender as ImageButton)?.BindingContext as Oeuvre; + if (selectedAnime != null) + { + // Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné + await Navigation.PushAsync(new ficheAnime(selectedAnime)); + } + } } \ No newline at end of file diff --git a/MangaMap/Views/FicheAnime.xaml.cs b/MangaMap/Views/FicheAnime.xaml.cs index b83d928..12f0705 100644 --- a/MangaMap/Views/FicheAnime.xaml.cs +++ b/MangaMap/Views/FicheAnime.xaml.cs @@ -2,19 +2,25 @@ namespace MangaMap.Views; using Model; using System.ComponentModel; using System.Diagnostics; +using System.Windows.Input; using System.Xml.Linq; + public partial class ficheAnime : ContentPage, INotifyPropertyChanged { + public Manager my_manager => (App.Current as App).MyManager; public Oeuvre AnimeModel { get; set; } + public ICommand StarCommand => new Command(count => SetNote(uint.Parse(count))); + public ficheAnime() { InitializeComponent(); BindingContext = this; + } public ficheAnime(Oeuvre anime) @@ -24,6 +30,7 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged InitializeComponent(); BindingContext = this; + } public async void AjouterListe(object sender, EventArgs e) @@ -76,7 +83,7 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged private void SetNote(float note) { - note = (int)note; // Tronquer à un entier car nous ne gérons actuellement pas les demi-étoiles + note = (int)note; var starImages = star.Children.OfType().Reverse().ToList(); foreach (var img in starImages) { diff --git a/MangaMap/Views/homePage.xaml b/MangaMap/Views/homePage.xaml index 7a2919e..61b4b38 100644 --- a/MangaMap/Views/homePage.xaml +++ b/MangaMap/Views/homePage.xaml @@ -47,7 +47,7 @@ - + diff --git a/MangaMap/Views/listPage.xaml b/MangaMap/Views/listPage.xaml index 4c61c80..5ac3fe8 100644 --- a/MangaMap/Views/listPage.xaml +++ b/MangaMap/Views/listPage.xaml @@ -2,173 +2,14 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MangaMap" x:Class="MangaMap.Views.listPage" - BackgroundColor="Black"> + BackgroundColor="Black" + xmlns:views="clr-namespace:MangaMap.Views.Composants"> - - - - - + + diff --git a/MangaMap/Views/listPage.xaml.cs b/MangaMap/Views/listPage.xaml.cs index 9283e00..4edf59a 100644 --- a/MangaMap/Views/listPage.xaml.cs +++ b/MangaMap/Views/listPage.xaml.cs @@ -4,21 +4,9 @@ using static System.Net.Mime.MediaTypeNames; public partial class listPage : ContentPage { - public Manager my_manager => (App.Current as App).MyManager; public listPage() { - InitializeComponent(); - BindingContext = my_manager; - } - - private async void AnimeImageClickedList(object sender, EventArgs e) - { - var selectedAnime = (sender as ImageButton)?.BindingContext as Oeuvre; - if (selectedAnime != null) - { - // Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné - await Navigation.PushAsync(new ficheAnime(selectedAnime)); - } - } + InitializeComponent(); + } } \ No newline at end of file