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.
83 lines
2.7 KiB
83 lines
2.7 KiB
//using Android.Media;
|
|
using DataPersistence;
|
|
using Model;
|
|
using Model.Managers;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
|
|
namespace Views
|
|
{
|
|
public partial class Home : ContentPage
|
|
{
|
|
public MasterManager MasterMgr => (App.Current as App).MasterMgr;
|
|
public User? user => (App.Current as App).CurrentUser;
|
|
public RecipeCollection AllRecipe => (App.Current as App).AllRecipes;
|
|
|
|
private readonly RecipeCollection _recipesDisplayed;
|
|
public ReadOnlyObservableCollection<Recipe> RecipesDisplayed { get; private 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 = (RecipeCollection)AllRecipe.Clone();
|
|
RecipesDisplayed = new ReadOnlyObservableCollection<Recipe>(_recipesDisplayed);
|
|
InitializeComponent();
|
|
BindingContext = this;
|
|
IsNotConnected = true;
|
|
NeedReturn = false;
|
|
}
|
|
|
|
public Home(RecipeCollection recipesDisplayed)
|
|
{
|
|
_recipesDisplayed = recipesDisplayed;
|
|
InitializeComponent();
|
|
BindingContext = this;
|
|
IsNotConnected = true;
|
|
NeedReturn = true;
|
|
}
|
|
|
|
private void ModifyRecipesDisplayed(RecipeCollection recipes)
|
|
{
|
|
_recipesDisplayed.Clear();
|
|
foreach (Recipe recipe in recipes)
|
|
{
|
|
_recipesDisplayed.Add(recipe);
|
|
}
|
|
}
|
|
|
|
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
|
{
|
|
string searchStr = (sender as SearchBar).Text;
|
|
ModifyRecipesDisplayed(AllRecipe.ResearchByName(searchStr));
|
|
}
|
|
public void OnImageClicked(object sender, EventArgs e)
|
|
{
|
|
(App.Current as App).CurrentRecipe = (Recipe)(sender as ImageButton).BindingContext;
|
|
Navigation.PushModalAsync(new ViewRecette());
|
|
}
|
|
|
|
private void Entrees_Clicked(object sender, EventArgs e)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|