diff --git a/MCTG/Model/Managers/MasterManager.cs b/MCTG/Model/Managers/MasterManager.cs
index a1a1b20..d9efaf1 100644
--- a/MCTG/Model/Managers/MasterManager.cs
+++ b/MCTG/Model/Managers/MasterManager.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -12,14 +14,28 @@ namespace Model.Managers
///
/// The Main manager of the model.
///
- public class MasterManager
+ public class MasterManager : INotifyPropertyChanged
{
#region Attributes & Properties
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ private RecipeCollection _recipesInSearch = new RecipeCollection("");
+
///
/// The currently connected user. 'null' if no user is connected.
///
public User? CurrentConnectedUser { get; private set; }
+ public RecipeCollection RecipesInSearch
+ {
+ get => _recipesInSearch;
+ set
+ {
+ _recipesInSearch = value;
+ OnPropertyChange();
+ }
+ }
+
///
/// The collection of all recipes loaded.
///
@@ -46,6 +62,7 @@ namespace Model.Managers
DataMgr = new DataManager(dataManager);
CurrentConnectedUser = null;
Recipes = DataMgr.GetRecipes("all recipes");
+ RecipesInSearch = DataMgr.GetRecipes("search on");
Users = DataMgr.GetUsers();
}
#endregion
@@ -132,6 +149,13 @@ namespace Model.Managers
public RecipeCollection GetCurrentUserRecipes()
=> new RecipeCollection("User recipes",
DataMgr.GetRecipes().FindAll(r => r.AuthorMail == CurrentConnectedUser?.Mail).ToArray());
+
+ ///
+ /// Notify property change handler.
+ ///
+ /// the name of the property that change.
+ public void OnPropertyChange([CallerMemberName] string propertyName = "")
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
diff --git a/MCTG/Views/ContainerFlyout.xaml b/MCTG/Views/ContainerFlyout.xaml
index 21b1ec4..2bfe91d 100644
--- a/MCTG/Views/ContainerFlyout.xaml
+++ b/MCTG/Views/ContainerFlyout.xaml
@@ -42,7 +42,6 @@
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
-
diff --git a/MCTG/Views/Home.xaml b/MCTG/Views/Home.xaml
index be4cc25..9647a99 100644
--- a/MCTG/Views/Home.xaml
+++ b/MCTG/Views/Home.xaml
@@ -4,10 +4,12 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:local="clr-namespace:Views"
xmlns:model="clr-namespace:Model;assembly=Model"
- x:Class="Views.Home">
+ x:Class="Views.Home"
+ x:Name="homepage">
+ IsNotConnected="{Binding IsNotConnected, Source={x:Reference homepage}}"
+ NeedReturn="{Binding NeedReturn, Source={x:Reference homepage}}">
diff --git a/MCTG/Views/Home.xaml.cs b/MCTG/Views/Home.xaml.cs
index 990c0b2..020fb39 100644
--- a/MCTG/Views/Home.xaml.cs
+++ b/MCTG/Views/Home.xaml.cs
@@ -11,19 +11,50 @@ namespace Views
public User? user => (App.Current as App).CurrentUser;
public RecipeCollection AllRecipe => (App.Current as App).AllRecipes;
- public RecipeCollection RecipesDisplayed { get; private set; }
+ public RecipeCollection RecipesDisplayed { get; set; }
+
+
+ public static readonly BindableProperty IsNotConnectedProperty =
+ BindableProperty.Create("IsNotConnected", typeof(bool), typeof(bool));
+
+ public bool IsNotConnected
+ {
+ get => (bool)GetValue(IsNotConnectedProperty);
+ set => SetValue(IsNotConnectedProperty, value);
+ }
+
+ public static readonly BindableProperty NeedReturnProperty =
+ BindableProperty.Create("NeedReturn", typeof(bool), typeof(bool));
+
+ public bool NeedReturn
+ {
+ get => (bool)GetValue(NeedReturnProperty);
+ set => SetValue(NeedReturnProperty, value);
+ }
+
public Home()
{
- RecipesDisplayed = AllRecipe;
+ RecipesDisplayed = MasterMgr.DataMgr.GetRecipes("Suggestions");
+ InitializeComponent();
+ BindingContext = this;
+ IsNotConnected = true;
+ NeedReturn = false;
+ }
+ public Home(RecipeCollection recipesDisplayed)
+ {
+ RecipesDisplayed = recipesDisplayed;
InitializeComponent();
BindingContext = this;
+ IsNotConnected = true;
+ NeedReturn = true;
}
- private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
+ private async void SearchBar_SearchButtonPressed(object sender, EventArgs e)
{
- RecipesDisplayed = AllRecipe.ResearchByName((sender as SearchBar).Text);
+ string searchStr = (sender as SearchBar).Text;
+ await Navigation.PushModalAsync(new Home(AllRecipe.ResearchByName(searchStr)));
}
}
}
diff --git a/MCTG/Views/RecipeCase.xaml b/MCTG/Views/RecipeCase.xaml
index 7d94ef0..312d057 100644
--- a/MCTG/Views/RecipeCase.xaml
+++ b/MCTG/Views/RecipeCase.xaml
@@ -14,7 +14,7 @@
Clicked="ImageButton_Clicked"/>