<?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="WorkFlowCheck.MAUI.Pages.CheckList.CheckListPage"
             Title="Ellenőrzések"
             BackgroundColor="#f0f0f0">
    <Grid RowDefinitions="*,*" Padding="30,30">
        <Frame Grid.Row="0"
               BorderColor="Gray" 
               Padding="5" 
               Margin="1" 
               CornerRadius="10"
               HasShadow="True">
            <ScrollView >
                <VerticalStackLayout>
                    <Label Text="Megkezdett ellenőrzések" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" />
                    <CollectionView x:Name="CheckList">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
                                    <StackLayout>
                                        <Label Text="{Binding DocumentNumber}" FontSize="16" FontAttributes="Bold" />
                                        <Label Text="{Binding DateExecution}" FontSize="14" />
                                        <HorizontalStackLayout HorizontalOptions="End">
                                            <Button Text="Folytatás" 
                                                    Margin="5,0,0,0"
                                                    BackgroundColor="Blue"
                                                    Command="{Binding BindingContext.ContinueCommand, Source={x:Reference CheckList}}" 
                                                    CommandParameter="{Binding .}" />
                                        </HorizontalStackLayout>
                                    </StackLayout>
                                </Frame>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </VerticalStackLayout>
            </ScrollView>
        </Frame>
        
            <Frame Grid.Row="1"
                   BorderColor="Gray" 
                   Padding="5" 
                   Margin="1" 
                   CornerRadius="10"
                   HasShadow="True">
            <ScrollView>
                <VerticalStackLayout>
                    <Label Text="Új ellenőrzés" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" />
                    <CollectionView x:Name="CheckListTemplate">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
                                    <StackLayout>
                                        <Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
                                        <Label Text="{Binding Description}" FontSize="14" />
                                        <HorizontalStackLayout HorizontalOptions="End">
                                            <Button Text="Új ellenőrzés" 
                                                    BackgroundColor="Green"
                                                    Margin="5,0,0,0"
                                                    Command="{Binding BindingContext.NewCommand, Source={x:Reference CheckListTemplate}}" 
                                                    CommandParameter="{Binding .}" />
                                        </HorizontalStackLayout>
                                    </StackLayout>
                                </Frame>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </VerticalStackLayout>
            </ScrollView>
        </Frame>
        <Grid BackgroundColor="#80000000"
              IsVisible="{Binding IsLoading}"
              Grid.Row="0"
              Grid.RowSpan="2"
              VerticalOptions="Fill"
              HorizontalOptions="Fill"
              ZIndex="1000">
                <ActivityIndicator IsRunning="{Binding IsLoading}"
                       HorizontalOptions="Center"
                       VerticalOptions="Center"
                       Color="White"
                       WidthRequest="50"
                       HeightRequest="50"/>
        </Grid>
    </Grid>

</ContentPage>