From 4e0c2fb740a4e7f819d9eea3faf9f0d49b73b63a Mon Sep 17 00:00:00 2001 From: Matheo HERSAN Date: Fri, 26 May 2023 15:22:50 +0200 Subject: [PATCH] Button working --- MangaMap/Stub/DataToPersist.cs | 1 + MangaMap/Views/FicheAnime.xaml.cs | 43 ++++++++++++++++++++++++++----- MangaMap/Views/listPage.xaml | 3 ++- MangaMap/Views/listPage.xaml.cs | 3 +++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/MangaMap/Stub/DataToPersist.cs b/MangaMap/Stub/DataToPersist.cs index 2e5386e..ef26f80 100644 --- a/MangaMap/Stub/DataToPersist.cs +++ b/MangaMap/Stub/DataToPersist.cs @@ -12,5 +12,6 @@ namespace MangaMap.Stub { public List Oeuvres { get; set; } = new List(); public List Utilisateurs { get; set; } = new List(); + } } diff --git a/MangaMap/Views/FicheAnime.xaml.cs b/MangaMap/Views/FicheAnime.xaml.cs index 6f7ad15..ea5f9ac 100644 --- a/MangaMap/Views/FicheAnime.xaml.cs +++ b/MangaMap/Views/FicheAnime.xaml.cs @@ -28,6 +28,8 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged this.BindingContext = this; } + + public async void AjouterListe(object sender, EventArgs e) { if (my_manager.UtilisateurActuel == null) @@ -36,19 +38,46 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged return; } - if (my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage == null) + string selectedOption = await DisplayActionSheet("Ajouter à quelle liste ?", "Annuler", null, "En Visionnage", "Déjà Vu", "Pour Plus Tard", "Favoris"); + + if (selectedOption == "Annuler") + return; + + Debug.WriteLine("Selected Option: " + selectedOption); + + // Ajouter l'anime à la liste sélectionnée + switch (selectedOption) { - // Initialisez la liste si elle est nulle - //my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage = new List(); + case "En Visionnage": + Debug.WriteLine("Ajout à la liste En Visionnage"); + my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage.Add(AnimeModel); + break; + case "Déjà Vu": + Debug.WriteLine("Ajout à la liste Déjà Vu"); + my_manager.UtilisateurActuel.ListeOeuvreDejaVu.Add(AnimeModel); + break; + case "Pour Plus Tard": + Debug.WriteLine("Ajout à la liste Pour Plus Tard"); + my_manager.UtilisateurActuel.ListeOeuvrePourPlusTard.Add(AnimeModel); + break; + case "Favoris": + Debug.WriteLine("Ajout à la liste Favoris"); + my_manager.UtilisateurActuel.ListeOeuvreFavorites.Add(AnimeModel); + break; } - Debug.WriteLine("Iciii"); - my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage.Add(AnimeModel); - Debug.WriteLine("Okkkkkkkkkkkk"); - // Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné + foreach (Oeuvre oeuvre in my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage) + { + Debug.WriteLine("Titre de l'oeuvre : " + oeuvre.Nom); + // Faites d'autres opérations avec chaque élément de la liste + } + + my_manager.sauvegarder(); + await Navigation.PushAsync(new listPage()); } + private void SetNote(float note) { note = (int)note; // Tronquer à un entier car nous ne gérons actuellement pas les demi-étoiles diff --git a/MangaMap/Views/listPage.xaml b/MangaMap/Views/listPage.xaml index 6f22f68..adae05b 100644 --- a/MangaMap/Views/listPage.xaml +++ b/MangaMap/Views/listPage.xaml @@ -2,7 +2,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MangaMap" x:Class="MangaMap.Views.listPage" - BackgroundColor="Black"> + BackgroundColor="Black" + x:Name="listPage"> diff --git a/MangaMap/Views/listPage.xaml.cs b/MangaMap/Views/listPage.xaml.cs index 98a7c5a..29066e2 100644 --- a/MangaMap/Views/listPage.xaml.cs +++ b/MangaMap/Views/listPage.xaml.cs @@ -11,4 +11,7 @@ public partial class listPage : ContentPage BindingContext = my_manager.UtilisateurActuel; } + + + } \ No newline at end of file