diff --git a/MangaMap/Views/homePage.xaml b/MangaMap/Views/homePage.xaml index 25cac50..46f9891 100644 --- a/MangaMap/Views/homePage.xaml +++ b/MangaMap/Views/homePage.xaml @@ -29,7 +29,7 @@ Margin="30" /> - + + --> + + + + + + + + + + + + + + + + + + diff --git a/MangaMap/Views/homePage.xaml.cs b/MangaMap/Views/homePage.xaml.cs index c90a508..86ab527 100644 --- a/MangaMap/Views/homePage.xaml.cs +++ b/MangaMap/Views/homePage.xaml.cs @@ -9,20 +9,60 @@ public partial class homePage : ContentPage public homePage() { - InitializeComponent(); BindingContext = my_manager; - + chargerSerie(); } private async void AnimeImageClicked(object sender, EventArgs e) { - var selectedAnime = (sender as ImageButton)?.BindingContext as Oeuvre; - if (selectedAnime != null) + //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)); + //} + + var button = (ImageButton)sender; + var idAutomation = button.AutomationId; + + if (int.TryParse(idAutomation, out int id)) + { + await Navigation.PushAsync(new ficheAnime(my_manager.Oeuvres[id])); + } + } + + private void chargerSerie() + { + int imagesParLigne = 4; + int indice = 0; + + for (int i = 0; i < my_manager.Oeuvres.Count; i++) { - // Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné - await Navigation.PushAsync(new ficheAnime(selectedAnime)); + Oeuvre favoris = my_manager.Oeuvres[i]; + + ImageButton imageButton = new ImageButton + { + Source = favoris.Affiche, + WidthRequest = 150, + HeightRequest = 170, + CornerRadius = 15, + Aspect = Aspect.Fill, + AutomationId = indice.ToString(), + }; + + imageButton.Clicked += AnimeImageClicked; + + int ligne = 1 + (indice / imagesParLigne); + int colonne = indice % imagesParLigne; + + Grid.SetRow(imageButton, ligne); + Grid.SetColumn(imageButton, colonne); + grille.Children.Add(imageButton); + + indice++; } } + } diff --git a/MangaMap/Views/listPage.xaml b/MangaMap/Views/listPage.xaml index af59494..5882d91 100644 --- a/MangaMap/Views/listPage.xaml +++ b/MangaMap/Views/listPage.xaml @@ -70,52 +70,21 @@ HorizontalOptions="End" VerticalOptions="Center"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/MangaMap/Views/listPage.xaml.cs b/MangaMap/Views/listPage.xaml.cs index 7ed0a71..a91fdee 100644 --- a/MangaMap/Views/listPage.xaml.cs +++ b/MangaMap/Views/listPage.xaml.cs @@ -10,35 +10,5 @@ public partial class listPage : ContentPage { InitializeComponent(); BindingContext = my_manager; - //if (my_manager.UtilisateurActuel.Email != null) - //{ - // chargerFavoris(); - //} - } - - private void chargerFavoris() - { - int indice = 0; - - for (int i = 0; i < my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage.Count; i++) - { - Oeuvre favoris = my_manager.UtilisateurActuel.ListeOeuvreEnVisionnage[i]; - - ImageButton imageButton = new ImageButton - { - Source = favoris.Affiche, - WidthRequest = 100, - HeightRequest = 100, - }; - - int ligne = 1 + indice; - - Grid.SetRow(imageButton, ligne); - Grid.SetColumn(imageButton, 0); - - //grille.Children.Add(imageButton); - - indice++; - } } } \ No newline at end of file