diff --git a/Views/Components/CounterView.xaml b/Views/Components/CounterView.xaml
index b460938..52b5890 100644
--- a/Views/Components/CounterView.xaml
+++ b/Views/Components/CounterView.xaml
@@ -1,52 +1,52 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Views/Components/CounterView.xaml.cs b/Views/Components/CounterView.xaml.cs
index 39b1b2f..0d52151 100644
--- a/Views/Components/CounterView.xaml.cs
+++ b/Views/Components/CounterView.xaml.cs
@@ -1,51 +1,51 @@
-namespace ShoopNCook.Views;
-
-public partial class CounterView : ContentView
-{
-
- private readonly BindableProperty CountProperty =
- BindableProperty.Create(nameof(CountLabel), typeof(uint), typeof(CounterView), default(uint) + 1);
-
- private readonly BindableProperty CounterLabelProperty =
- BindableProperty.Create(nameof(CounterLabel), typeof(string), typeof(CounterView), default(string));
-
- public CounterView()
- {
- InitializeComponent();
- CountLabel.BindingContext = this;
- CountLabel.SetBinding(Label.TextProperty, nameof(Count));
-
- CounterLabel.BindingContext = this;
- CounterLabel.SetBinding(Label.TextProperty, nameof(CounterText));
- }
-
- public uint Count
- {
- get => (uint)GetValue(CountProperty);
- set
- {
- SetValue(CountProperty, value <= 1 ? 1 : uint.Parse(value.ToString()));
- OnPropertyChanged(nameof(Count));
- }
- }
-
- public string CounterText
- {
- get => (string)GetValue(CounterLabelProperty);
- set
- {
- SetValue(CounterLabelProperty, value);
- OnPropertyChanged(nameof(CounterText));
- }
- }
-
- private void OnPlus(object o, EventArgs e)
- {
- Count += 1;
- }
-
- private void OnMinus(object o, EventArgs e)
- {
- Count -= 1;
- }
+namespace ShoopNCook.Views;
+
+public partial class CounterView : ContentView
+{
+
+ private readonly BindableProperty CountProperty =
+ BindableProperty.Create(nameof(CountLabel), typeof(uint), typeof(CounterView), default(uint) + 1);
+
+ private readonly BindableProperty CounterLabelProperty =
+ BindableProperty.Create(nameof(CounterLabel), typeof(string), typeof(CounterView), default(string));
+
+ public CounterView()
+ {
+ InitializeComponent();
+ CountLabel.BindingContext = this;
+ CountLabel.SetBinding(Label.TextProperty, nameof(Count));
+
+ CounterLabel.BindingContext = this;
+ CounterLabel.SetBinding(Label.TextProperty, nameof(CounterText));
+ }
+
+ public uint Count
+ {
+ get => (uint)GetValue(CountProperty);
+ set
+ {
+ SetValue(CountProperty, value <= 1 ? 1 : uint.Parse(value.ToString()));
+ OnPropertyChanged(nameof(Count));
+ }
+ }
+
+ public string CounterText
+ {
+ get => (string)GetValue(CounterLabelProperty);
+ set
+ {
+ SetValue(CounterLabelProperty, value);
+ OnPropertyChanged(nameof(CounterText));
+ }
+ }
+
+ private void OnPlus(object o, EventArgs e)
+ {
+ Count += 1;
+ }
+
+ private void OnMinus(object o, EventArgs e)
+ {
+ Count -= 1;
+ }
}
\ No newline at end of file
diff --git a/Views/HomePage.xaml b/Views/HomePage.xaml
index 38dcd43..fa9eae2 100644
--- a/Views/HomePage.xaml
+++ b/Views/HomePage.xaml
@@ -25,7 +25,9 @@
HeightRequest="65"/>
-
+
+ HeightRequest="30">
diff --git a/Views/HomePage.xaml.cs b/Views/HomePage.xaml.cs
index b74cfd2..69b42f9 100644
--- a/Views/HomePage.xaml.cs
+++ b/Views/HomePage.xaml.cs
@@ -7,15 +7,16 @@ using LocalEndpoint;
public partial class HomePage : ContentPage
{
+
public HomePage(Account account, IUserNotifier notifier, IEndpoint endpoint)
{
- InitializeComponent();
+ InitializeComponent();
+ BindingContext = account;
IRecipesService service = endpoint.RecipesService;
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
- //TODO this code can be factorised
void PushRecipe(Layout layout, RecipeInfo info)
{
layout.Children.Add(new RecipeView(info, () =>
@@ -29,7 +30,6 @@ public partial class HomePage : ContentPage
preferences.GetRecommendedRecipes().ForEach(recipe => PushRecipe(RecommendedList, recipe));
ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture);
- ProfilePictureName.Text = account.User.Name;
}
diff --git a/Views/MorePage.xaml b/Views/MorePage.xaml
index 704f24f..593ebc3 100644
--- a/Views/MorePage.xaml
+++ b/Views/MorePage.xaml
@@ -20,6 +20,7 @@
diff --git a/Views/ProfilePage.xaml.cs b/Views/ProfilePage.xaml.cs
index 5dee862..a7076d5 100644
--- a/Views/ProfilePage.xaml.cs
+++ b/Views/ProfilePage.xaml.cs
@@ -4,16 +4,21 @@ namespace ShoopNCook.Pages;
public partial class ProfilePage : ContentPage
{
+
+
public ProfilePage(Account account)
{
- InitializeComponent();
- }
+ BindingContext = account;
+ InitializeComponent();
+
+ ProfilePicture.Source = ImageSource.FromUri(account.User.ProfilePicture);
+ }
private async void OnBackButtonClicked(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
private async void ChangeMyPasswordClicked(object sender, EventArgs e)
{
- await Shell.Current.Navigation.PushAsync(new ChangePassword()) ;
+ await Shell.Current.Navigation.PushAsync(new ChangePassword());
}
}
\ No newline at end of file
diff --git a/Views/RecipePage.xaml b/Views/RecipePage.xaml
index 6cecce6..9cadc58 100644
--- a/Views/RecipePage.xaml
+++ b/Views/RecipePage.xaml
@@ -63,8 +63,8 @@
-
+
diff --git a/Views/RecipePage.xaml.cs b/Views/RecipePage.xaml.cs
index a7be6df..8b425dc 100644
--- a/Views/RecipePage.xaml.cs
+++ b/Views/RecipePage.xaml.cs
@@ -1,113 +1,113 @@
-using ShoopNCook.Views;
-using System.Windows.Input;
-using Models;
-using LocalEndpoint;
-using Endpoint;
-
-namespace ShoopNCook.Pages;
-
-public partial class RecipePage : ContentPage
-{
- private readonly IAccountRecipesPreferences preferences;
- private readonly IUserNotifier notifier;
-
+using ShoopNCook.Views;
+using System.Windows.Input;
+using Models;
+using LocalEndpoint;
+using Endpoint;
+
+namespace ShoopNCook.Pages;
+
+public partial class RecipePage : ContentPage
+{
+ private readonly IAccountRecipesPreferences preferences;
+ private readonly IUserNotifier notifier;
+
public Recipe Recipe { get; init; }
- private uint note;
- private bool isFavorite;
-
-
- public ICommand StarCommand => new Command(count => SetNote(uint.Parse(count)));
-
- public RecipePage(Recipe recipe, IUserNotifier notifier, IAccountRecipesPreferences preferences, uint amount)
- {
+ private uint note;
+ private bool isFavorite;
+
+
+ public ICommand StarCommand => new Command(count => SetNote(uint.Parse(count)));
+
+ public RecipePage(Recipe recipe, IUserNotifier notifier, IAccountRecipesPreferences preferences, uint amount)
+ {
Recipe = recipe;
- BindingContext = this;
+ BindingContext = this;
InitializeComponent();
-
- this.preferences = preferences;
- this.notifier = notifier;
-
- RecipeRate rate = preferences.GetRate(recipe.Info);
-
- note = rate.Rate;
- isFavorite = rate.IsFavorite;
-
- SetFavorite(isFavorite);
- SetNote(note);
-
- 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));
-
- //retrieves the app's styles
- var styles = Application.Current.Resources.MergedDictionaries.ElementAt(1);
-
- int count = 0;
- foreach (PreparationStep step in recipe.Steps) {
- //TODO display name of PreparationSteps.
- Label label = new Label();
- label.Style = (Style)styles["Small"];
- label.Text = "Step " + ++count + ": " + step.Description;
- StepList.Add(label);
- }
- }
-
- private void SetNote(uint note)
- {
- this.note = note;
- int i = 1;
- foreach (ImageButton img in Stars.Children)
- {
- if (i <= note)
- {
- img.Source = ImageSource.FromFile("star_full.svg");
- i++;
- }
- else
- img.Source = ImageSource.FromFile("star_empty.svg");
- }
- }
-
- private void OnFavorite(object o, EventArgs e)
- {
- SetFavorite(!isFavorite);
- if (isFavorite)
- preferences.AddToFavorites(Recipe.Info);
- else
- preferences.RemoveFromFavorites(Recipe.Info);
- }
-
- private void OnSubmitReviewClicked(object o, EventArgs e)
- {
- preferences.SetReviewScore(Recipe.Info, note);
- notifier.Success("Your review has been successfuly submited");
- }
-
- private void OnAddToMyListClicked(object o, EventArgs e)
- {
- 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)
- {
- this.isFavorite = isFavorite;
- if (isFavorite)
- Favorite.Source = ImageSource.FromFile("hearth_on.svg");
- else
- Favorite.Source = ImageSource.FromFile("hearth_off.svg");
- }
- private void OnBackButtonClicked(object sender, EventArgs e)
- {
- Navigation.PopAsync();
- }
-
+
+ this.preferences = preferences;
+ this.notifier = notifier;
+
+ RecipeRate rate = preferences.GetRate(recipe.Info);
+
+ note = rate.Rate;
+ isFavorite = rate.IsFavorite;
+
+ SetFavorite(isFavorite);
+ SetNote(note);
+
+ 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));
+
+ //retrieves the app's styles
+ var styles = Application.Current.Resources.MergedDictionaries.ElementAt(1);
+
+ int count = 0;
+ foreach (PreparationStep step in recipe.Steps) {
+ //TODO display name of PreparationSteps.
+ Label label = new Label();
+ label.Style = (Style)styles["Small"];
+ label.Text = "Step " + ++count + ": " + step.Description;
+ StepList.Add(label);
+ }
+ }
+
+ private void SetNote(uint note)
+ {
+ this.note = note;
+ int i = 1;
+ foreach (ImageButton img in Stars.Children)
+ {
+ if (i <= note)
+ {
+ img.Source = ImageSource.FromFile("star_full.svg");
+ i++;
+ }
+ else
+ img.Source = ImageSource.FromFile("star_empty.svg");
+ }
+ }
+
+ private void OnFavorite(object o, EventArgs e)
+ {
+ SetFavorite(!isFavorite);
+ if (isFavorite)
+ preferences.AddToFavorites(Recipe.Info);
+ else
+ preferences.RemoveFromFavorites(Recipe.Info);
+ }
+
+ private void OnSubmitReviewClicked(object o, EventArgs e)
+ {
+ preferences.SetReviewScore(Recipe.Info, note);
+ notifier.Success("Your review has been successfuly submited");
+ }
+
+ private void OnAddToMyListClicked(object o, EventArgs e)
+ {
+ 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)
+ {
+ this.isFavorite = isFavorite;
+ if (isFavorite)
+ Favorite.Source = ImageSource.FromFile("hearth_on.svg");
+ else
+ Favorite.Source = ImageSource.FromFile("hearth_off.svg");
+ }
+ private void OnBackButtonClicked(object sender, EventArgs e)
+ {
+ Navigation.PopAsync();
+ }
+
}
\ No newline at end of file