You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.2 KiB
87 lines
3.2 KiB
using Model;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace Views
|
|
{
|
|
public partial class Home : ContentPage
|
|
{
|
|
public MasterManager Master => (Application.Current as App).Master;
|
|
|
|
private readonly RecipeCollection _recipesDisplayed;
|
|
public ReadOnlyObservableCollection<Recipe> RecipesDisplayed { get; private set; }
|
|
|
|
public static readonly BindableProperty IsNotConnectedProperty =
|
|
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(bool));
|
|
|
|
|
|
|
|
|
|
public Home()
|
|
{
|
|
_recipesDisplayed = Master.Recipe.GetAllRecipes();
|
|
RecipesDisplayed = new ReadOnlyObservableCollection<Recipe>(_recipesDisplayed);
|
|
|
|
InitializeComponent();
|
|
|
|
BindingContext = this;
|
|
|
|
//container_base.IsConnected = Master.User.CurrentConnected is not null;
|
|
Master.User.LogIn("admin@mctg.fr", "admin");
|
|
}
|
|
|
|
|
|
private void ModifyRecipesDisplayed(RecipeCollection recipes)
|
|
{
|
|
_recipesDisplayed.Clear();
|
|
_recipesDisplayed.Description = recipes.Description;
|
|
foreach (Recipe recipe in recipes)
|
|
{
|
|
_recipesDisplayed.Add(recipe);
|
|
}
|
|
}
|
|
|
|
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
|
{
|
|
string searchStr = (sender as SearchBar).Text;
|
|
ModifyRecipesDisplayed(Master.Recipe.SearchRecipeByTitle(searchStr));
|
|
}
|
|
public void OnImageClicked(object sender, EventArgs e)
|
|
{
|
|
Master.Recipe.CurrentSelected = (Recipe)(sender as ImageButton).BindingContext;
|
|
Navigation.PushModalAsync(new ViewRecette());
|
|
}
|
|
|
|
private void Entrees_Clicked(object sender, EventArgs e)
|
|
{
|
|
ModifyRecipesDisplayed(new RecipeCollection("Entrées",
|
|
Master.Recipe.GetAllRecipes()
|
|
.ToList()
|
|
.FindAll(r => r.Type == RecipeType.Starter)
|
|
.ToArray()));
|
|
}
|
|
|
|
private void Plats_Clicked(object sender, EventArgs e)
|
|
{
|
|
ModifyRecipesDisplayed(new RecipeCollection("Plats",
|
|
Master.Recipe.GetAllRecipes()
|
|
.ToList()
|
|
.FindAll(r => r.Type == RecipeType.Dish)
|
|
.ToArray()));
|
|
}
|
|
|
|
private void Desserts_Clicked(object sender, EventArgs e)
|
|
{
|
|
ModifyRecipesDisplayed(new RecipeCollection("Desserts",
|
|
Master.Recipe.GetAllRecipes()
|
|
.ToList()
|
|
.FindAll(r => r.Type == RecipeType.Dessert)
|
|
.ToArray()));
|
|
}
|
|
|
|
private void AllRecipes_Clicked(object sender, EventArgs e)
|
|
{
|
|
ModifyRecipesDisplayed(Master.Recipe.GetAllRecipes());
|
|
}
|
|
}
|
|
}
|