<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
             xmlns:views="clr-namespace:GameAtlas.Views.Composants"
             x:Class="GameAtlas.Views.PageAcceuil"
             Title="ACCUEIL">
             <!--  WidthRequest="390" HeightRequest="844"> -->



    <Grid>

        <Grid.Background>
            <LinearGradientBrush EndPoint="1,0">
                <GradientStop Color="#DFE4FF"
                          Offset="0.1" />
                <GradientStop Color="#FDF7E6"
                          Offset="1.0" />
            </LinearGradientBrush>
        </Grid.Background>

        <ScrollView VerticalScrollBarVisibility="Never">

            <Grid
                RowDefinitions="auto, auto, auto, auto, auto, auto, *">


                <Grid HorizontalOptions="Start" Padding="25,20,0,20">
                    <HorizontalStackLayout Spacing="10">
                        <Frame Grid.Row="0" WidthRequest="50" HeightRequest="50" CornerRadius="25" VerticalOptions="Start" >
                            <Frame.Background>
                                <LinearGradientBrush EndPoint="1,0">
                                    <GradientStop Color="#C57CFF"
                                      Offset="0.1" />
                                    <GradientStop Color="#8F00FF"
                                      Offset="1.0" />
                                </LinearGradientBrush>
                            </Frame.Background>
                            <Frame HeightRequest="48" WidthRequest="48" CornerRadius="24" VerticalOptions="Center" HorizontalOptions="Center" IsClippedToBounds="True">
                                <Image Source="default_user.png" Aspect="AspectFill"/>
                            </Frame>
                        </Frame>
                        <Label Text="{Binding AccueilManager.ConnectedUser.Pseudo}" FontSize="18" FontFamily="AladinRegular" TextColor="{StaticResource Black}" VerticalTextAlignment="Center"/>
                    </HorizontalStackLayout>
                </Grid>

                
                <Label
                Text="Parcourir les jeux"
                FontFamily="PTSansCaption-Bold"
                FontSize="24"
                Grid.Row="3"
                Padding="25,25,0,25"
                />

                <ScrollView Orientation="Horizontal" Grid.Row="4" Padding="20,0,20,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalScrollBarVisibility="Never">
                    <HorizontalStackLayout BindableLayout.ItemsSource="{Binding AccueilManager.ListJeuxAffiches}" Spacing="15">
                        <BindableLayout.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Frame CornerRadius="10" HeightRequest="160" WidthRequest="290">
                                        <ImageButton Source="{Binding Image}" HeightRequest="160" WidthRequest="290" Aspect="AspectFill" Clicked="OnButtonClicked"/>
                                    </Frame>
                                    <BoxView
                                        Color="Black"
                                        Opacity="0.3"
                                        CornerRadius="10"
                                        HeightRequest="65"
                                        VerticalOptions="End"/>
                                    <HorizontalStackLayout Margin="25,100,0,0" Spacing="5">
                                        <Image Style="{StaticResource BigStar}"/>
                                        <Image Style="{StaticResource BigStar}"/>
                                        <Image Style="{StaticResource BigStar}"/>
                                        <Image Style="{StaticResource BigStar}"/>
                                        <Image Style="{StaticResource BigStar}"/>
                                    </HorizontalStackLayout>
                                    <Label Text="{Binding Nom}"
                                           TextColor="White"
                                           FontFamily="PTSansCaption-Bold"
                                           FontSize="12"
                                           Padding="25,115,0,0"/>
                                    <Image Source="download.png"
                                           HorizontalOptions="Start"
                                           HeightRequest="20"
                                           WidthRequest="20"
                                           Margin="23,125,0,0"/>
                                
                                    <Label FontSize="8" FontFamily="PTSansCaption-Bold" TextColor="{StaticResource White}" Padding="46,138,0,0">
                                        <Label.FormattedText>
                                            <FormattedString>
                                                <Span Text="{Binding NbTelechargement}"/>
                                                <Span Text="k de téléchargements"/>
                                            </FormattedString>
                                        </Label.FormattedText>
                                    </Label>
                                </Grid>
                            </DataTemplate>
                        </BindableLayout.ItemTemplate>
                    </HorizontalStackLayout>
                </ScrollView>

                <Label
                Text="Jeux les mieux notés"
                FontFamily="PTSansCaption-Bold"
                FontSize="24"
                Grid.Row="5"
                Padding="25,25,0,25"
                />

                <Grid Grid.Row="6">
                    <VerticalStackLayout Spacing="30" BindableLayout.ItemsSource="{Binding AccueilManager.TopRatedGames}">
                        <BindableLayout.ItemTemplate>
                            <DataTemplate>
                                <Grid ColumnDefinitions="auto,*,auto">
                                    <Frame Grid.Column="0" CornerRadius="5" HeightRequest="60" WidthRequest="100" Margin="25,0,0,0">
                                        <Image Source="{Binding Image}" Aspect="AspectFill" />
                                    </Frame>
                                    <StackLayout Grid.Column="1" Spacing="25" Padding="20,0">
                                        <Label Text="{Binding Nom}" FontFamily="PTSansNarrow-Bold" FontSize="13" LineBreakMode="TailTruncation" MaxLines="2"/>
                                        <HorizontalStackLayout>
                                            <Image Style="{StaticResource Star}"/>
                                            <Label TextColor="#7C7C7C" FontFamily="PTSansNarrow-Bold" FontSize="12" Margin="6,0,15,0">
                                                <Label.FormattedText>
                                                    <FormattedString>
                                                        <Span Text="{Binding Note}"/>
                                                        <Span Text="/10" FontSize="8"/>
                                                    </FormattedString>
                                                </Label.FormattedText>
                                            </Label>
                                            <Image Style="{StaticResource DownloadBlue}"/>
                                            <Label FontSize="12" FontFamily="PTSansNarrow-Bold" TextColor="#7C7C7C" Margin="6,0,0,0">
                                                <Label.FormattedText>
                                                    <FormattedString>
                                                        <Span Text="{Binding NbTelechargement}"/>
                                                        <Span Text="k"/>
                                                    </FormattedString>
                                                </Label.FormattedText>
                                            </Label>
                                        </HorizontalStackLayout>
                                    </StackLayout>
                                    <views:BoutonVoir Grid.Column="2"/>
                                </Grid>
                            </DataTemplate>
                        </BindableLayout.ItemTemplate>
                    </VerticalStackLayout>
                </Grid>


            </Grid>

        </ScrollView>
    </Grid>

</ContentPage>