diff --git a/Sources/Stim.Model/Manager.cs b/Sources/Stim.Model/Manager.cs index f2c6513..5985178 100644 --- a/Sources/Stim.Model/Manager.cs +++ b/Sources/Stim.Model/Manager.cs @@ -6,6 +6,7 @@ namespace Model { public IPersistance Mgrpersistance; public ObservableCollection GameList { get;} + public ObservableCollection ResearchedGame { get; set; } public User CurrentUser { get; set; } public Manager(IPersistance persistance) @@ -13,6 +14,7 @@ namespace Model Mgrpersistance = persistance; CurrentUser = new User(null,"username", "je suis née .... maintenat je fini à 19h30 à cause de l'IHM. GHGHTFCDXEFTGHYJKIJHNGFVCREDTGHNJIKJUHNYGVTFCREDZTGYHUNJIKJUHNYTGVFCREDRTYHUJIOUJNHYGVFRCCFTGYHUJIUJNHYTGBVCFDRRTGYHUI", "email@email.com", "password88"); GameList = persistance.LoadGame(); + ResearchedGame = persistance.LoadGame(); if (GameList == null) { GameList = new ObservableCollection();} } diff --git a/Sources/Stim/App.xaml.cs b/Sources/Stim/App.xaml.cs index 4c80b04..07f36d8 100644 --- a/Sources/Stim/App.xaml.cs +++ b/Sources/Stim/App.xaml.cs @@ -21,7 +21,6 @@ public partial class App : Application window.Stopped += (s, e) => { Manager.Mgrpersistance = new Persistance(FileSystem.Current.AppDataDirectory); - var test = Manager; Manager.SaveGames(); }; diff --git a/Sources/Stim/MainPage.xaml b/Sources/Stim/MainPage.xaml index 60b038e..e2d8316 100644 --- a/Sources/Stim/MainPage.xaml +++ b/Sources/Stim/MainPage.xaml @@ -37,12 +37,12 @@ - - - + + + - + diff --git a/Sources/Stim/MainPage.xaml.cs b/Sources/Stim/MainPage.xaml.cs index 445012a..99f85f8 100644 --- a/Sources/Stim/MainPage.xaml.cs +++ b/Sources/Stim/MainPage.xaml.cs @@ -3,6 +3,8 @@ using Model; using StimPersistance; using StimStub; using Microsoft.Maui.Storage; +using MailKit.Search; +using System.Linq; public partial class MainPage : ContentPage { @@ -21,4 +23,33 @@ public partial class MainPage : ContentPage { await Navigation.PushAsync(new AddGamePage()); } + + private void SearchBar_GameChanged(object sender, TextChangedEventArgs e) + { + SearchBar searchBar = (SearchBar)sender; + string GameText = Game.Text; + string Tag1Text = Tag1.Text; + string Tag2Text = Tag2.Text; + ((App)App.Current).Manager.ResearchedGame.Clear(); + var filteredGames = ((App)App.Current).Manager.GameList; + if (Game != null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0 + && + game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0) + && + game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (filteredGames ==null) + { + filteredGames = ((App)App.Current).Manager.GameList; + } + + foreach (var game in filteredGames) + { + ((App)App.Current).Manager.ResearchedGame.Add(game); + } + } } diff --git a/Sources/Stim/Stim.csproj b/Sources/Stim/Stim.csproj index d772458..8be7f62 100644 --- a/Sources/Stim/Stim.csproj +++ b/Sources/Stim/Stim.csproj @@ -50,6 +50,10 @@ + + + + diff --git a/Sources/TestProject1/TestUser.cs b/Sources/TestProject1/TestUser.cs index f19ba24..ccddb90 100644 --- a/Sources/TestProject1/TestUser.cs +++ b/Sources/TestProject1/TestUser.cs @@ -83,10 +83,6 @@ namespace Test Assert.NotNull(user); Assert.NotNull(game); - - // user.AddReview(game, 2.5f,"UwU"); - // Assert.Single(game.Reviews); - user.RemoveSelfReview(game, 2.5f, "UwU"); Assert.Empty(game.Reviews); }