<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="NotesNet8.Views.AllNotesPage"
             xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:viewModels="clr-namespace:NotesNet8.ViewModels"
             Title="AllNotesPage"
             NavigatedTo="ContentPage_NavigatedTo">
    <ContentPage.BindingContext>
        <viewModels:NotesViewModel />
    </ContentPage.BindingContext>

    <ContentPage.ToolbarItems>
        <ToolbarItem Command="{Binding NewCommand}"
                     IconImageSource="{FontImage Glyph='+',
                                                 Color=Black,
                                                 Size=22}"
                     Text="Add" />
    </ContentPage.ToolbarItems>

    <CollectionView x:Name="notesCollection"
                    Margin="20"
                    ItemsSource="{Binding AllNotes}"
                    SelectionMode="Single"
                    SelectionChangedCommand="{Binding SelectNoteCommand}"
                    SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
        <CollectionView.ItemsLayout>
            <LinearItemsLayout ItemSpacing="10" Orientation="Vertical" />
        </CollectionView.ItemsLayout>

        <CollectionView.ItemTemplate>
            <DataTemplate>
                <StackLayout>
                    <Label FontSize="22" Text="{Binding Text}" />
                    <Label FontSize="14"
                           Text="{Binding Date}"
                           TextColor="Silver" />
                </StackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>