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

    <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="Auteur"
                         HeaderBackButtonText="Mes livres"
                         HeaderPlusButtonVisible="False"
                         HeaderSwitchButtonVisible="True"
                         ButtonPlusTappedCommand="{Binding FiltrageAuteurVM.Navigator.PopupHomePlusNavigationCommand}"
                         ButtonBackTappedCommand="{Binding FiltrageAuteurVM.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 FiltrageAuteurVM.Manager.AllAuthors}"
                                SelectionMode="Single" 
                                SelectedItem="{Binding FiltrageAuteurVM.Manager.SelectedAuthor}"
                                SelectionChangedCommand="{Binding FiltrageAuteurVM.NavigateAuthorPageCommand}">
                    <CollectionView.ItemTemplate>
                        <DataTemplate x:DataType="viewModel:AuthorVM">
                            <VerticalStackLayout>
                                <contentView:HomeButtonView ButtonTitle="{Binding Name}"
                                                            ButtonIcon="book.png"
                                                            ButtonNumber="{Binding NbBooksWritten}"
                                                            ButtonRedIconVisible="True"
                                                            ButtonBlackIconVisible="False"/>
                                <contentView:SeparatorBigCutStartView/>
                            </VerticalStackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
                
            </VerticalStackLayout>
        </ScrollView>
    </Grid>
    
</ContentPage>