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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MangaMap.DataBinding;
using MangaMap.Stub; using MangaMap.Stub;
namespace MangaMap.Model 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 IPersistanceManager Persistance { get; set; }
public List<Admin> Admins { get; private set; } public List<Admin> Admins { get; private set; }
public List<Utilisateur> Utilisateurs { 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 Utilisateur UtilisateurActuel { get; set; }
public bool isAdmin { get; set; } public bool isAdmin { get; set; }

@ -20,12 +20,13 @@
<VerticalStackLayout <VerticalStackLayout
VerticalOptions="Center"> VerticalOptions="Center">
<SearchBar Placeholder="Recherche" <SearchBar
CancelButtonColor="Orange" Placeholder="Recherche"
TextColor="Black" TextChanged="OnTextChanged"
BackgroundColor="White" TextColor="Black"
HorizontalTextAlignment="Center" BackgroundColor="White"
Margin="30" HorizontalTextAlignment="Center"
Margin="30"
/> />
<!--<HorizontalStackLayout BindableLayout.ItemsSource="{Binding Oeuvres}" Spacing="100" HorizontalOptions="Center"> <!--<HorizontalStackLayout BindableLayout.ItemsSource="{Binding Oeuvres}" Spacing="100" HorizontalOptions="Center">
@ -43,7 +44,7 @@
</HorizontalStackLayout>--> </HorizontalStackLayout>-->
<ScrollView> <ScrollView >
<Grid x:Name="grille"> <Grid x:Name="grille">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
@ -62,6 +63,8 @@
</Grid> </Grid>
</ScrollView> </ScrollView>
<!--<ListView x:Name="a1" ItemsSource="{Binding Utilisateurs}"> <!--<ListView x:Name="a1" ItemsSource="{Binding Utilisateurs}">

@ -1,12 +1,14 @@
namespace MangaMap.Views; namespace MangaMap.Views;
using MangaMap.Model; using MangaMap.Model;
using System.Collections.ObjectModel;
public partial class homePage : ContentPage public partial class homePage : ContentPage
{ {
public Manager my_manager => (App.Current as App).MyManager; public Manager my_manager => (App.Current as App).MyManager;
private ObservableCollection<Oeuvre> filteredOeuvres = new ObservableCollection<Oeuvre>();
public homePage() public homePage()
{ {
InitializeComponent(); 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