fix recipe view

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

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

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

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

Loading…
Cancel
Save