etoiles et average en content view

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
parent 5d8bb4d688
commit f26b307edb

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Stim"
x:Class="Stim.DetailledPage" x:Class="Stim.DetailledPage"
Title="{Binding Name}" Title="{Binding Name}"
Background="{StaticResource Secondary}"> Background="{StaticResource Secondary}">
@ -30,15 +31,9 @@
<CollectionView Grid.Row="1" ItemsSource="{Binding Tags}" ItemTemplate="{StaticResource tagsTemplate}"/> <CollectionView Grid.Row="1" ItemsSource="{Binding Tags}" ItemTemplate="{StaticResource tagsTemplate}"/>
</Grid> </Grid>
<Label Grid.Column="1" Grid.Row="3" Text="{Binding Lien}"/> <Label Grid.Column="1" Grid.Row="3" Text="{Binding Lien, FallbackValue='Default'}"/>
<HorizontalStackLayout Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="3" HorizontalOptions="End">
<Label Padding="0,5,0,0" FontSize="25" Text="{Binding Average, StringFormat='{0}/5'}"/> <local:StarsContainer Rate="{Binding Average, FallbackValue='0'}" Grid.Column="4" Grid.Row="3"/>
<Image Style="{StaticResource star}" Source="{Binding Average, Converter={StaticResource DoubleToStar}, ConverterParameter='1'}"/>
<Image Style="{StaticResource star}" Source="{Binding Average, Converter={StaticResource DoubleToStar}, ConverterParameter='2'}"/>
<Image Style="{StaticResource star}" Source="{Binding Average, Converter={StaticResource DoubleToStar}, ConverterParameter='3'}"/>
<Image Style="{StaticResource star}" Source="{Binding Average, Converter={StaticResource DoubleToStar}, ConverterParameter='4'}"/>
<Image Style="{StaticResource star}" Source="{Binding Average, Converter={StaticResource DoubleToStar}, ConverterParameter='5'}"/>
</HorizontalStackLayout>
<VerticalStackLayout Grid.ColumnSpan="4" Grid.Row="4"> <VerticalStackLayout Grid.ColumnSpan="4" Grid.Row="4">
<Label Text="Avis de la communauté :" FontSize="30"/> <Label Text="Avis de la communauté :" FontSize="30"/>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:conv="clr-namespace:Stim.Converter"
x:Class="Stim.StarsContainer"
x:Name="StarsContainerView">
<ContentView.Resources>
<conv:DoubleToStar x:Key="DoubleToStar" EtoilePleine="etoile_pleine.png" EtoileMiPleine="etoile_mi_pleine.png" EtoileVide="etoile_vide.png"/>
</ContentView.Resources>
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" BindingContext="{x:Reference StarsContainerView}">
<Label Text="{Binding Rate, FallbackValue='0', StringFormat='{0}/5'}" FontSize="20"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='1'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='2'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='3'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='4'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='5'}"/>
</HorizontalStackLayout>
</ContentView>

@ -0,0 +1,18 @@
namespace Stim;
public partial class StarsContainer : ContentView
{
public static readonly BindableProperty RateProperty =
BindableProperty.Create(nameof(Rate), typeof(double), typeof(StarsContainer), double.NaN);
public double Rate
{
get => (double)GetValue(StarsContainer.RateProperty);
set => SetValue(StarsContainer.RateProperty, value);
}
public StarsContainer()
{
InitializeComponent();
}
}
Loading…
Cancel
Save