Barre de Recherche #59

Merged
yvan.calatayud merged 1 commits from yvan into master 2 years ago

@ -11,10 +11,24 @@ namespace GameAtlas.Models
{
public class Manager : INotifyPropertyChanged
{
public ObservableCollection<Jeu> ListJeux { get; private set; }
public List<Admin> Admins { get; private set; }
public List<Utilisateur> Utilisateurs { get; private set; }
private ObservableCollection<Jeu> listJeux;
public ObservableCollection<Jeu> ListJeux
{
get
{
return listJeux;
}
set
{
listJeux = value;
OnPropertyChanged();
}
}
public IPersistanceManager Persistance { get; set; }
public Utilisateur ConnectedUser

@ -25,6 +25,7 @@
BackgroundColor="White"
TextColor="Black"
HorizontalOptions="Center"
TextChanged="SearchBar_TextChanged"
/>
<Label
@ -36,7 +37,7 @@
/>
<Grid>
<CollectionView ItemsSource="{Binding ListJeux}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never">
<CollectionView ItemsSource="{Binding ListJeux}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never" x:Name="searchResults">
<CollectionView.ItemTemplate>
<DataTemplate>
<Border HeightRequest="97.5" StrokeShape="RoundRectangle 5" VerticalOptions="Start" HorizontalOptions="Center">

@ -1,6 +1,7 @@
namespace GameAtlas.Views;
using GameAtlas.Models;
using System.Collections.ObjectModel;
public partial class PageParcourir : ContentPage
{
@ -27,4 +28,16 @@ public partial class PageParcourir : ContentPage
{
await Navigation.PopAsync();
}
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
if(string.IsNullOrWhiteSpace(e.NewTextValue))
{
searchResults.ItemsSource = ParcourirManager.ListJeux;
}
else
{
searchResults.ItemsSource = ParcourirManager.ListJeux.Where(i => i.Nom.ToLower().Contains(e.NewTextValue.ToLower()));
}
}
}
Loading…
Cancel
Save