fix recipe view

pull/27/head
maxime.BATISTA@etu.uca.fr 2 years ago
parent 9c0cbc874a
commit 4050dbcb3e

@ -38,16 +38,16 @@
Direction="Row" Direction="Row"
Wrap="Wrap"> Wrap="Wrap">
<views:RecipeView Margin="5" Note="4.5"/> <views:RecipeView Margin="5" Note="4.5" Title="Spaghetti Bolognese" Subtitle="30 min"/>
<views:RecipeView Margin="5" Note="3"/> <views:RecipeView Margin="5" Note="3" Title="Chickend Curry" Subtitle="45 min"/>
<views:RecipeView Margin="5" Note="0.2"/> <views:RecipeView Margin="5" Note="0.2" Title="Beef Stroganoff" Subtitle="10 min"/>
<views:RecipeView Margin="5" Note="1.6"/> <views:RecipeView Margin="5" Note="1.6" Title="Fish And Ships" Subtitle="15 min"/>
<views:RecipeView Margin="5" Note="5"/> <views:RecipeView Margin="5" Note="5" Title="Caesar Salad" Subtitle="20 min"/>
<views:RecipeView Margin="5" Note="3.5"/> <views:RecipeView Margin="5" Note="3.5" Title="Vegetables" Subtitle="60 min"/>
<views:RecipeView Margin="5" Note="4.6"/> <views:RecipeView Margin="5" Note="4.6" Title="Guacamole" Subtitle="90 min"/>
<views:RecipeView Margin="5" Note="4"/> <views:RecipeView Margin="5" Note="4" Title="Pad Thai" Subtitle="10 min"/>
<views:RecipeView Margin="5" Note="3"/> <views:RecipeView Margin="5" Note="3" Title="French Toast" Subtitle="5 min"/>
<views:RecipeView Margin="5" Note="2"/> <views:RecipeView Margin="5" Note="2" Title="Margherita Pizza" Subtitle="2 min"/>
</FlexLayout> </FlexLayout>
</ScrollView> </ScrollView>
</Grid> </Grid>

@ -48,10 +48,10 @@
<VerticalStackLayout Grid.Row="1"> <VerticalStackLayout Grid.Row="1">
<Label <Label
TextColor="{StaticResource TextColorPrimary}" TextColor="{StaticResource TextColorPrimary}"
Text="Recipe Name"/> x:Name="TitleLabel"/>
<Label <Label
TextColor="{StaticResource TextColorSecondary}" TextColor="{StaticResource TextColorSecondary}"
Text="Preparation time"/> x:Name="SubtitleLabel"/>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>
</Border> </Border>

@ -3,32 +3,35 @@ namespace ShoopNCook.Views;
public partial class RecipeView : ContentView public partial class RecipeView : ContentView
{ {
private readonly BindableProperty NoteProperty;
public RecipeView(): this(5, "Title", "Subtitle")
{}
public float Note { public RecipeView(float note, string title, string subtitle)
get => (float) GetValue(NoteProperty); {
set => SetValue(NoteProperty, value); InitializeComponent();
Note = note;
Title = title;
Subtitle = subtitle;
} }
public RecipeView(): this(5) public float Note
{} {
set => SetNote(value);
}
public RecipeView(float note) public string Title
{ {
InitializeComponent(); set => TitleLabel.Text = value;
NoteProperty = BindableProperty.Create( }
nameof(Note),
typeof(float),
typeof(RecipeView),
0F,
propertyChanged: (_, _, v) => UpdateNotes((float) v)
);
Note = note; public string Subtitle
{
set => SubtitleLabel.Text = value;
} }
private void UpdateNotes(float note)
private void SetNote(float note)
{ {
int i = 1; int i = 1;
foreach (Image img in Stars.Children) foreach (Image img in Stars.Children)

Loading…
Cancel
Save