|
|
|
@ -11,16 +11,18 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
private readonly IAccountRecipesPreferences preferences;
|
|
|
|
|
private readonly IUserNotifier notifier;
|
|
|
|
|
|
|
|
|
|
public Recipe Recipe { get; init; }
|
|
|
|
|
|
|
|
|
|
private uint note;
|
|
|
|
|
private bool isFavorite;
|
|
|
|
|
private bool isInMyList;
|
|
|
|
|
|
|
|
|
|
public Recipe Recipe { get; init; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand StarCommand => new Command<string>(count => SetNote(uint.Parse(count)));
|
|
|
|
|
|
|
|
|
|
public RecipePage(Recipe recipe, IUserNotifier notifier, IAccountRecipesPreferences preferences, uint amount)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Recipe = recipe;
|
|
|
|
|
BindingContext = this;
|
|
|
|
|
|
|
|
|
@ -36,12 +38,10 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
|
|
|
|
|
SetFavorite(isFavorite);
|
|
|
|
|
SetNote(note);
|
|
|
|
|
SetIsInMyListState(preferences.IsInWeeklyList(recipe.Info));
|
|
|
|
|
|
|
|
|
|
Counter.Count = amount;
|
|
|
|
|
|
|
|
|
|
if (recipe.Info.Image != null)
|
|
|
|
|
RecipeImage.Source = ImageSource.FromUri(recipe.Info.Image);
|
|
|
|
|
|
|
|
|
|
foreach (Ingredient ingredient in recipe.Ingredients)
|
|
|
|
|
IngredientList.Add(new IngredientView(ingredient));
|
|
|
|
|
|
|
|
|
@ -58,6 +58,19 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetIsInMyListState(bool isInMyList)
|
|
|
|
|
{
|
|
|
|
|
this.isInMyList = isInMyList;
|
|
|
|
|
if (isInMyList)
|
|
|
|
|
{
|
|
|
|
|
MyListStateButton.Text = "Remove From My List";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MyListStateButton.Text = "Add To My List";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetNote(uint note)
|
|
|
|
|
{
|
|
|
|
|
this.note = note;
|
|
|
|
@ -89,12 +102,37 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
notifier.Success("Your review has been successfuly submited");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAddToMyListClicked(object o, EventArgs e)
|
|
|
|
|
private void OnFooterButtonClicked(object o, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetIsInMyListState(!isInMyList);
|
|
|
|
|
if (isInMyList)
|
|
|
|
|
RemoveFromMyList();
|
|
|
|
|
else
|
|
|
|
|
AddToMyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveFromMyList()
|
|
|
|
|
{
|
|
|
|
|
if (!preferences.RemoveFromWeeklyList(Recipe.Info))
|
|
|
|
|
{
|
|
|
|
|
notifier.Notice("This recipe does not figures in your personnal list");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
notifier.Success("Recipe added to your weekly list.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddToMyList()
|
|
|
|
|
{
|
|
|
|
|
if (!preferences.AddToWeeklyList(Recipe.Info, Counter.Count))
|
|
|
|
|
{
|
|
|
|
|
notifier.Notice("You already added this recipe to you weekly list!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
notifier.Success("Recipe added to your weekly list.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetFavorite(bool isFavorite)
|
|
|
|
|