<?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:view="clr-namespace:LivreLand.View"
             xmlns:contentView="clr-namespace:LivreLand.View.ContentViews"
             xmlns:viewModel="clr-namespace:ViewModels;assembly=ViewModels"
             x:Class="LivreLand.View.FiltrageNoteView"
             Title="FiltrageNoteView">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <view:HeaderPage Grid.Row="0"
                         HeaderTitle="Note"
                         HeaderBackButtonText="Mes livres"
                         HeaderPlusButtonVisible="False"
                         HeaderSwitchButtonVisible="True"
                         ButtonPlusTappedCommand="{Binding FiltrageNoteVM.Navigator.PopupHomePlusNavigationCommand}"
                         ButtonBackTappedCommand="{Binding FiltrageNoteVM.Navigator.PopupBackButtonNavigationCommand}"/>

        <VerticalStackLayout BackgroundColor="{DynamicResource Light}"
                             Spacing="10"
                             Grid.Row="2">
            <contentView:SeparatorEntireView/>

            <contentView:SearchBarView Grid.Row="2"/>
        </VerticalStackLayout>

        <ScrollView Grid.Row="4">
            <VerticalStackLayout Grid.Row="2">
                <contentView:SeparatorEntireView/>

                <CollectionView ItemsSource="{Binding FiltrageNoteVM.Manager.AllRatings}"
                                SelectionMode="Single"
                                SelectedItem="{Binding FiltrageNoteVM.Manager.SelectedRating}"
                                SelectionChangedCommand="{Binding FiltrageNoteVM.NavigateRatingPageCommand}">
                    <CollectionView.ItemTemplate>
                        <DataTemplate x:DataType="viewModel:RatingsVM">
                            <VerticalStackLayout>
                                <contentView:HomeButtonView ButtonTitle="{Binding Average}"
                                                            ButtonIcon="book.png"
                                                            ButtonNumber="{Binding NbBooksWritten}"
                                                            ButtonRedIconVisible="True"
                                                            ButtonBlackIconVisible="False"/>

                                <contentView:SeparatorBigCutStartView/>
                                <contentView:SeparatorBigCutStartView/>
                            </VerticalStackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
            </VerticalStackLayout>
        </ScrollView>
    </Grid>
    
</ContentPage>