Ajout des étoiles pour les notes

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
parent 138437793a
commit 3b65744d36

@ -16,8 +16,8 @@ namespace Model
{
_persistance = persistance;
Games.Add(new("Elden Ring", "description", 2010, new List<string> { "1","2","3"}, "elden_ring.jpg"));
Games[0].AddReview(new(4.5f, "C'est trop bien"));
Games[0].AddReview(new( 3, "C'est bien"));
Games[0].AddReview(new(5, "C'est trop bien"));
Games[0].AddReview(new(3.5f, "C'est bien"));
Games[0].AddReview(new(1.5f, "C'est pas bien"));
Games.Add(new("Minecraft", "description", 2010, new List<string> { "1", "2", "3" }, "minecraft.jpeg"));
Games.Add(new("Celeste", "description", 2010, new List<string> { "1", "2" }, "celeste.png"));

@ -62,13 +62,8 @@
</VerticalStackLayout>
<Label Grid.Row="3" Grid.ColumnSpan="4" VerticalOptions="End" TextDecorations="Underline" TextColor="White" Text="https://idhaklzhdkhazkdhaz.fr&#10;https://ioghzilghieriugo.fr"/>
<HorizontalStackLayout Grid.Row="3" Grid.Column="2" VerticalOptions="End" HorizontalOptions="End">
<Image Source="etoile_pleine.png" WidthRequest="25"/>
<Image Source="etoile_pleine.png" WidthRequest="25"/>
<Image Source="etoile_pleine.png" WidthRequest="25"/>
<Image Source="etoile_mi_pleine.png" WidthRequest="25"/>
<Image Source="etoile_vide.png" WidthRequest="25"/>
<Label Padding="5" HorizontalTextAlignment="End" FontAttributes="Bold" FontSize="20" TextColor="White" Text="3.5/5"/>
<HorizontalStackLayout Grid.Row="3" Grid.Column="2" VerticalOptions="End" HorizontalOptions="End" x:Name="starsContainer">
<Label Padding="5" HorizontalTextAlignment="End" FontAttributes="Bold" FontSize="20" TextColor="White" x:Name="avgLabel"/>
</HorizontalStackLayout>
</Grid>
@ -78,13 +73,8 @@
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout Margin="20,20,0,0">
<HorizontalStackLayout Grid.Column="1" Padding="0,0,0,5" VerticalOptions="Start" HorizontalOptions="Start">
<Label Margin="0, 0, 5, 0" FontSize="20" TextColor="White" Text="{Binding AuthorName}"/>
<Image Source="etoile_pleine.png" WidthRequest="25"/>
<Image Source="etoile_pleine.png" WidthRequest="25"/>
<Image Source="etoile_vide.png" WidthRequest="25"/>
<Image Source="etoile_vide.png" WidthRequest="25"/>
<Image Source="etoile_vide.png" WidthRequest="25"/>
<HorizontalStackLayout Grid.Column="1" Padding="0,0,0,5" VerticalOptions="Start" HorizontalOptions="Start" BindingContextChanged="AddStars">
<Label Margin="0, 0, 5, 0" FontSize="20" TextColor="White" Text="Avis 1"/>
</HorizontalStackLayout>
<Label TextColor="White" Text="{Binding Text}"/>
</VerticalStackLayout>

@ -9,7 +9,25 @@ public partial class DetailledPage : ContentPage
{
InitializeComponent();
BindingContext = game;
avgLabel.Text = game.Average.ToString();
AddStars(starsContainer, game.Average);
}
private void AddStars(object sender, EventArgs e)
{
HorizontalStackLayout layout = sender as HorizontalStackLayout;
Review rev = layout.BindingContext as Review;
AddStars(layout, rev.Rate);
}
private void AddStars(HorizontalStackLayout container, float rate)
{
for (int i = 0; i < (int)rate; i++) container.Children.Add(new Image { Source = "etoile_pleine.png", WidthRequest = 25 });
if ((int)rate!=rate) container.Children.Add(new Image { Source = "etoile_mi_pleine.png", WidthRequest = 25 });
while (container.Children.Count != 6) container.Children.Add(new Image { Source = "etoile_vide.png", WidthRequest = 25 });
}
private async void goToMainPage(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new MainPage());

Loading…
Cancel
Save