Enhancement searchBar but does not work
continuous-integration/drone/push Build is failing Details

pull/29/head
Matheo HERSAN 2 years ago
parent f6a4fd91b1
commit 4651aca48e

@ -1,19 +1,41 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using MangaMap.DataBinding;
using MangaMap.Stub;
namespace MangaMap.Model
{
public class Manager
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<Admin> Admins { get; private set; }
public List<Utilisateur> Utilisateurs { get; private set; }
public ObservableCollection<Oeuvre> Oeuvres { get; private set; }
private ObservableCollection<Oeuvre> oeuvres;
public ObservableCollection<Oeuvre> Oeuvres
{
get
{
return oeuvres;
}
set
{
oeuvres = value;
OnPropertyChanged();
}
}
public Utilisateur UtilisateurActuel { get; set; }
public bool isAdmin { get; set; }

@ -20,8 +20,9 @@
<VerticalStackLayout
VerticalOptions="Center">
<SearchBar Placeholder="Recherche"
CancelButtonColor="Orange"
<SearchBar
Placeholder="Recherche"
TextChanged="OnTextChanged"
TextColor="Black"
BackgroundColor="White"
HorizontalTextAlignment="Center"
@ -63,6 +64,8 @@
</ScrollView>
<!--<ListView x:Name="a1" ItemsSource="{Binding Utilisateurs}">
<ListView.ItemTemplate>

@ -1,12 +1,14 @@
namespace MangaMap.Views;
using MangaMap.Model;
using System.Collections.ObjectModel;
public partial class homePage : ContentPage
{
public Manager my_manager => (App.Current as App).MyManager;
private ObservableCollection<Oeuvre> filteredOeuvres = new ObservableCollection<Oeuvre>();
public homePage()
{
InitializeComponent();
@ -67,4 +69,16 @@ public partial class homePage : ContentPage
}
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
if(string.IsNullOrEmpty(e.NewTextValue))
{
searchResults.ItemsSource = my_manager.Oeuvres;
}
else
{
searchResults.ItemsSource = my_manager.Oeuvres.Where(i => i.Nom.ToLower().Contains(e.NewTextValue.ToLower()));
}
}
}

Loading…
Cancel
Save