<?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"
             x:Class="MauiApp1.View.TransactionView"
             Title="Transactions">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Button x:Name="btnAddTransaction"
            Text="Add Transaction"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Margin="20, 10"
            Command="{Binding AddTransactionCommand}"/>

        <CollectionView ItemsSource="{Binding Transactions}" Grid.Row="1" >
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <SwipeView>
                        <SwipeView.RightItems>
                            <SwipeItems>
                                <SwipeItemView>
                                    <Frame BackgroundColor="LightGreen"
                                           Margin="5">
                                        <Label Text="Изменить"/>
                                    </Frame>
                                </SwipeItemView>

                                <SwipeItemView>
                                    <Frame BackgroundColor="LightCoral"
                                           Margin="5">
                                        <Label Text="Удалить"/>
                                    </Frame>
                                </SwipeItemView>
                            </SwipeItems>
                        </SwipeView.RightItems>
                        
                    <Frame CornerRadius="20" Margin="10" BackgroundColor="{AppThemeBinding Light={StaticResource FrameLight}, Dark={StaticResource FrameDark}}">
                        <StackLayout Orientation="Horizontal">
                            <Label Text="{Binding Category}" FontSize="Medium" HorizontalOptions="StartAndExpand"/>
                            <Label Text="{Binding Price}" FontSize="Medium" />
                        </StackLayout>
                    </Frame>
                    </SwipeView>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </Grid>
</ContentPage>