<?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.FiltrageDateView"
             Title="FiltrageDateView">

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

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

        <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 FiltrageDateVM.Manager.AllPublishDates}"
                                SelectionMode="Single"
                                SelectedItem="{Binding FiltrageDateVM.Manager.SelectedDate}"
                                SelectionChangedCommand="{Binding FiltrageDateVM.NavigateDatePageCommand}">
                    <CollectionView.ItemTemplate>
                        <DataTemplate x:DataType="viewModel:PublishDateVM">
                            <VerticalStackLayout>
                                <contentView:HomeButtonView ButtonTitle="{Binding PublishDate, StringFormat='{}{0:yyyy}'}"
                                                            ButtonIcon="book.png"
                                                            ButtonNumber="1"
                                                            ButtonRedIconVisible="True"
                                                            ButtonBlackIconVisible="False"/>
                                <contentView:SeparatorBigCutStartView/>
                            </VerticalStackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
            </VerticalStackLayout>
        </ScrollView>
    </Grid>
    
</ContentPage>