From 3321ff21e0b6022444b0ddaa45fdf9423fcb3e34 Mon Sep 17 00:00:00 2001 From: Matheo HERSAN Date: Fri, 2 Jun 2023 18:33:37 +0200 Subject: [PATCH] Search Bar works BUT image dont load until we write something in the search bar --- MangaMap/Model/Manager.cs | 9 +++++---- MangaMap/Views/homePage.xaml | 30 +++++++++++++++++++++++++----- MangaMap/Views/homePage.xaml.cs | 29 ++++++++++++++--------------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/MangaMap/Model/Manager.cs b/MangaMap/Model/Manager.cs index 614fe62..1dc29c7 100644 --- a/MangaMap/Model/Manager.cs +++ b/MangaMap/Model/Manager.cs @@ -13,10 +13,7 @@ namespace MangaMap.Model { public class Manager : System.ComponentModel.INotifyPropertyChanged { - public event PropertyChangedEventHandler? PropertyChanged; - - void OnPropertyChanged([CallerMemberName] string propertyName = null) - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public IPersistanceManager Persistance { get; set; } public List Admins { get; private set; } @@ -36,6 +33,10 @@ namespace MangaMap.Model OnPropertyChanged(); } } + public event PropertyChangedEventHandler? PropertyChanged; + + void OnPropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); public Utilisateur UtilisateurActuel { get; set; } public bool isAdmin { get; set; } diff --git a/MangaMap/Views/homePage.xaml b/MangaMap/Views/homePage.xaml index b97f4b1..0f13b6a 100644 --- a/MangaMap/Views/homePage.xaml +++ b/MangaMap/Views/homePage.xaml @@ -11,10 +11,10 @@ - + - - --> + + + + + + + + + + + + + + + - + diff --git a/MangaMap/Views/homePage.xaml.cs b/MangaMap/Views/homePage.xaml.cs index d7f24a1..0fc8d5b 100644 --- a/MangaMap/Views/homePage.xaml.cs +++ b/MangaMap/Views/homePage.xaml.cs @@ -7,34 +7,32 @@ public partial class homePage : ContentPage { public Manager my_manager => (App.Current as App).MyManager; - private ObservableCollection filteredOeuvres = new ObservableCollection(); - public homePage() { InitializeComponent(); BindingContext = my_manager; - chargerSerie(); + //chargerSerie(); } private async void AnimeImageClicked(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)); - //} - - var button = (ImageButton)sender; + 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() + /*private void chargerSerie() { int imagesParLigne = 4; int indice = 0; @@ -67,11 +65,12 @@ public partial class homePage : ContentPage indice++; } - } + }*/ private void OnTextChanged(object sender, TextChangedEventArgs e) { - if(string.IsNullOrEmpty(e.NewTextValue)) + + if(string.IsNullOrWhiteSpace(e.NewTextValue)) { searchResults.ItemsSource = my_manager.Oeuvres; }