big probleme with the bindable property TITLE.
continuous-integration/drone/push Build is passing Details

pull/53/head
Roxane ROSSETTO 2 years ago
parent 0aee8f070e
commit e88eb58e70

@ -38,7 +38,8 @@ namespace DataPersistence
}), }),
new Recipe( new Recipe(
authorMail: "admin@mctg.fr", authorMail: "admin@mctg.fr",
title: "Cookies au chocolat", id: null, title: "Cookies au chocolat",
id: null,
preparationSteps: new[] preparationSteps: new[]
{ {
new PreparationStep(1, "Moulinez la pâte."), new PreparationStep(1, "Moulinez la pâte."),

@ -40,6 +40,8 @@ namespace Model
[DataMember(Name = "authorMail")] [DataMember(Name = "authorMail")]
public string? AuthorMail { get; private set; } public string? AuthorMail { get; private set; }
public string Toto { get; set; } = "Coucou";
/// <summary> /// <summary>
/// The Title of the recipe. <br/> /// The Title of the recipe. <br/>
/// Set to "No title." when the value passed is null, empty or contain white spaces. /// Set to "No title." when the value passed is null, empty or contain white spaces.
@ -144,17 +146,17 @@ namespace Model
{ {
} }
///// <summary> /// <summary>
///// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/> /// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
///// </summary> /// </summary>
///// <param _name="title">The title of the recipe.</param> /// <param _name="title">The title of the recipe.</param>
///// <param _name="id">The id of the recipe. If not given, get a new id.</param> /// <param _name="id">The id of the recipe. If not given, get a new id.</param>
///// <param _name="picture">Image that reppresent the recipe.</param> /// <param _name="picture">Image that reppresent the recipe.</param>
///// <param _name="preparationSteps">The steps of the preparation of the meal.</param> /// <param _name="preparationSteps">The steps of the preparation of the meal.</param>
//public Recipe(string title, int? id, string picture, params PreparationStep[] preparationSteps) public Recipe()
// : this(title, id, null, picture, new List<Review>(), new List<Ingredient>(), preparationSteps) : this("", null, null, null, new List<Review>(), new List<Ingredient>(),new PreparationStep[0])
//{ {
//} }
#endregion #endregion

@ -8,6 +8,10 @@ using DataPersistence;
using Model; using Model;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Model.Managers; using Model.Managers;
using Microsoft.Maui.Controls;
using System.Linq;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Views namespace Views
{ {
@ -15,9 +19,21 @@ namespace Views
{ {
//Point d'entrée de l'application //Point d'entrée de l'application
public MasterManager MasterMgr { get; private set; } = new MasterManager(new Stubs()); public MasterManager MasterMgr { get; private set; } = new MasterManager(new Stubs());
//L'utilisateur courant de l'application //L'utilisateur courant de l'application
public User CurrentUser { get; set; } public User CurrentUser { get; set; }
private Recipe currentRecipe { get; set; }
public Recipe CurrentRecipe
{
get => currentRecipe;
set
{
currentRecipe = value;
OnPropertyChanged(nameof(CurrentRecipe));
}
}
//collection de recette de l'application //collection de recette de l'application
public RecipeCollection AllRecipes { get; set; } public RecipeCollection AllRecipes { get; set; }
@ -29,7 +45,7 @@ namespace Views
{ {
CurrentUser = MasterMgr.DataMgr.GetUsers().Last(); CurrentUser = MasterMgr.DataMgr.GetUsers().Last();
AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes"); AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes");
CurrentRecipe = MasterMgr.DataMgr.GetRecipes().First();
InitializeComponent(); InitializeComponent();
// Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) => // Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
@ -51,5 +67,6 @@ namespace Views
MainPage = new Home(); MainPage = new Home();
//MainPage = new MyPosts(); //MainPage = new MyPosts();
} }
} }
} }

@ -68,9 +68,10 @@
CaseImageSource="room_service_icon.png" CaseImageSource="room_service_icon.png"
Title="{Binding Title}"/>--> Title="{Binding Title}"/>-->
<Image <ImageButton
Grid.Row="0" VerticalOptions="Fill" Grid.Row="0" VerticalOptions="Fill"
Source="{Binding Image}"/> Source="{Binding Image}"
Clicked="OnImageClicked"/>
<Label <Label
Text="{Binding Title}" FontSize="18" Text="{Binding Title}" FontSize="18"

@ -1,4 +1,5 @@
using DataPersistence; //using Android.Media;
using DataPersistence;
using Model; using Model;
using Model.Managers; using Model.Managers;
@ -8,7 +9,7 @@ namespace Views
{ {
public MasterManager MasterMgr => (App.Current as App).MasterMgr; public MasterManager MasterMgr => (App.Current as App).MasterMgr;
public User user => (App.Current as App).CurrentUser; public User user => (App.Current as App).CurrentUser;
public Recipe recipe => (App.Current as App).CurrentRecipe;
public RecipeCollection AllRecipes => (App.Current as App).AllRecipes; public RecipeCollection AllRecipes => (App.Current as App).AllRecipes;
public Home() public Home()
{ {
@ -18,5 +19,12 @@ namespace Views
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
} }
public void OnImageClicked(object sender, EventArgs e)
{
(App.Current as App).CurrentRecipe = (Recipe)(sender as ImageButton).BindingContext;
Navigation.PushModalAsync(new ViewRecette());
}
} }
} }

@ -10,7 +10,7 @@
WidthRequest="60" WidthRequest="60"
/> />
<Label Grid.Column="1" <Label Grid.Column="1"
Text="{Binding TitleMini, Source={Reference miniheader}}" Text="{Binding TitleMini, Source={x:Reference miniheader}}"
FontSize="Medium" FontSize="Medium"
FontAttributes="Bold" FontAttributes="Bold"
LineBreakMode="WordWrap" LineBreakMode="WordWrap"

@ -8,10 +8,10 @@ public partial class MiniHeader : ContentView
} }
public readonly BindableProperty TitleMiniProperty = public readonly BindableProperty TitleMiniProperty =
BindableProperty.Create("TitleMini", typeof(string), typeof(MiniHeader), "Erreur de titre"); BindableProperty.Create(nameof(TitleMini), typeof(string), typeof(MiniHeader), "Erreur de titre");
public string TitleMini public string TitleMini
{ {
get => (string)GetValue(TitleMiniProperty); get => (string)GetValue(TitleMiniProperty);
set => SetValue(TitleMiniProperty, value); set => SetValue(TitleMiniProperty, value);
} }

@ -5,13 +5,13 @@
xmlns:local="clr-namespace:Views" xmlns:local="clr-namespace:Views"
Title="ViewRecette" Title="ViewRecette"
x:Name="nrecipe"> x:Name="nrecipe">
<VerticalStackLayout> <VerticalStackLayout BindingContext="{Binding Recipe}">
<local:MiniHeader <local:MiniHeader
TitleMini="Cookies aux Pépites de chocolat" TitleMini="{Binding Toto}"
NeedReturn="True" NeedReturn="True"
HeightRequest="100"/> HeightRequest="100"/>
<Image <Image
Source="entete.jpg" Source="{Binding Image}"
HeightRequest="150" HeightRequest="150"
Aspect="AspectFill"/> Aspect="AspectFill"/>
<Grid ColumnDefinitions="200,*"> <Grid ColumnDefinitions="200,*">

@ -1,13 +1,21 @@
namespace Views; using Model.Managers;
/// <summary> using Model;
/// Classe de la page contenant le detail de la recette
/// namespace Views;
/// </summary> /// <summary>
public partial class ViewRecette : ContentPage /// Classe de la page contenant le detail de la recette
{ ///
public ViewRecette() /// </summary>
{ public partial class ViewRecette : ContentPage
InitializeComponent(); {
} public MasterManager MasterMgr => (App.Current as App).MasterMgr;
public User user => (App.Current as App).CurrentUser;
public Recipe Recipe => (App.Current as App).CurrentRecipe;
public RecipeCollection AllRecipes => (App.Current as App).AllRecipes;
public ViewRecette()
{
InitializeComponent();
BindingContext = this;
}
} }
Loading…
Cancel
Save