From d5d25d045366d909405049019ffe70e8c4977741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoan=20BRUGI=C3=88RE?= Date: Wed, 24 May 2023 13:28:01 +0200 Subject: [PATCH] Nouveau header collection view --- Sources/Model/Manager.cs | 36 +++++++++- Sources/Ohara/AppShell.xaml | 4 +- Sources/Ohara/PageBestiaire.xaml | 43 ++++-------- Sources/Ohara/PageFDD.xaml | 43 ++++-------- Sources/Ohara/PageFavoris.xaml | 106 +++++++++++++++--------------- Sources/Ohara/PageFavoris.xaml.cs | 8 ++- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index 7ffb8a8..8dfaa81 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -1,6 +1,8 @@ -using Model.Stub; +using Microsoft.VisualBasic; +using Model.Stub; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,9 +14,10 @@ namespace Model { public IDataManager DataManager { get; set; } - + public ObservableCollection Bateaux { get; private set; } public Manager() { + Bateaux = new ObservableCollection(); DataManager = new StubManager(); } @@ -84,7 +87,36 @@ namespace Model } return listeFDD; } + public List RechercheObjetOhara(string text, List liste) + { + if (text == "") + { + return liste; + } + foreach (ObjetOhara f in liste.ToList()) + { + bool correspondance = false; + int textPos = 0; + for (int i = 0; i < (f.Nom.Length); i++) + { + if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase)) + { + textPos++; + } + if (textPos == text.Length) + { + correspondance = true; + break; + } + } + if (!correspondance) + { + liste.Remove(f); + } + } + return liste; + } public List GetFavoris() { List listeFavoris = new List(); diff --git a/Sources/Ohara/AppShell.xaml b/Sources/Ohara/AppShell.xaml index 36a8ef4..3ba963e 100644 --- a/Sources/Ohara/AppShell.xaml +++ b/Sources/Ohara/AppShell.xaml @@ -17,13 +17,13 @@ - - + diff --git a/Sources/Ohara/PageBestiaire.xaml b/Sources/Ohara/PageBestiaire.xaml index 5fb9aae..1173da4 100644 --- a/Sources/Ohara/PageBestiaire.xaml +++ b/Sources/Ohara/PageBestiaire.xaml @@ -9,37 +9,18 @@ - - - - - - - - - - - - - - - + + + + + diff --git a/Sources/Ohara/PageFDD.xaml b/Sources/Ohara/PageFDD.xaml index 318705f..1145731 100644 --- a/Sources/Ohara/PageFDD.xaml +++ b/Sources/Ohara/PageFDD.xaml @@ -11,37 +11,18 @@ - - - - - - - - - - - - - - - + + + + + diff --git a/Sources/Ohara/PageFavoris.xaml b/Sources/Ohara/PageFavoris.xaml index 1234d22..367b89d 100644 --- a/Sources/Ohara/PageFavoris.xaml +++ b/Sources/Ohara/PageFavoris.xaml @@ -1,55 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Ohara/PageFavoris.xaml.cs b/Sources/Ohara/PageFavoris.xaml.cs index 7b17aa6..f02747e 100644 --- a/Sources/Ohara/PageFavoris.xaml.cs +++ b/Sources/Ohara/PageFavoris.xaml.cs @@ -10,7 +10,13 @@ public partial class PageFavoris : ContentPage public PageFavoris() { InitializeComponent(); - listeFavs.ItemsSource = manager.GetFavoris(); + listeFavs.ItemsSource = manager.GetFavoris(); + void OnTextChanged(object sender, EventArgs e) + { + SearchBar searchBar = (SearchBar)sender; + listeFavs.ItemsSource = manager.RechercheObjetOhara(searchBar.Text, manager.GetFavoris()); + } + searchBar.TextChanged += OnTextChanged; } async void listeFavs_SelectionChanged(object sender, SelectionChangedEventArgs e)