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

    <Grid RowDefinitions="*,9*" RowSpacing="10">
        <StackLayout Grid.Row="0"
                     Margin="10"
                     BackgroundColor=" Transparent" Orientation="Horizontal">
            <Button BorderColor=" White" BorderWidth="1" Clicked="LastButton_Clicked" HorizontalOptions="StartAndExpand"
                    Text="Go to Last" TextColor=" White" />
            <Button BorderColor=" White" BorderWidth="1" Clicked="TopButton_Clicked" HorizontalOptions="EndAndExpand"
                    Text="Back to Top" TextColor=" White" />
        </StackLayout>

        <CollectionView x:Name="mainCollectionView"
                        Grid.Row="1"
                        ItemsSource="{Binding Players}">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <ContentView>
                        <Frame Margin="10"
                               BackgroundColor="#2b2b2b" CornerRadius="14">
                            <Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto">
                                <Image Grid.RowSpan="2"
                                       Margin="0,0,10,0"
                                       HeightRequest="60"
                                       Source="{Binding PlayerImage}"
                                       WidthRequest="60">
                                    <Image.Clip>
                                        <EllipseGeometry Center="30,30" RadiusX="30" RadiusY="30" />
                                    </Image.Clip>
                                </Image>
                                <Label Grid.Column="1"
                                       FontAttributes="Bold"
                                       Text="{Binding PlayerName}"
                                       TextColor=" White" />
                                <Label Grid.Row="1" Grid.Column="1"
                                       FontAttributes="Italic"
                                       Text="{Binding Country}"
                                       TextColor=" White" VerticalOptions="End" />
                            </Grid>
                        </Frame>
                    </ContentView>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </Grid>
</ContentPage>