<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignWidth="800"
             d:DesignHeight="450"
             x:Class="MayShow.Views.StartNewChooseReport"
             xmlns:models="clr-namespace:MayShow.Models"
             xmlns:vm="clr-namespace:MayShow.ViewModels"
             xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
             x:DataType="vm:StartNewChooseReportViewModel">
    <Grid ColumnDefinitions="100, *, 100"
          RowDefinitions="Auto, Auto, Auto, Auto, Auto, *">
        <TextBlock HorizontalAlignment="Center"
                   FontSize="36"
                   FontWeight="Bold"
                   Margin="0,16,0,0"
                   Grid.Column="1"
                   Grid.Row="0">
            MayShow <Run Text="{Binding Version}"/>
        </TextBlock>
        <Image Source="avares://MayShow/Assets/MayShowIcon.png" 
               Width="125"
               Margin="0,24,0,0"
               HorizontalAlignment="Center"
               Grid.Column="1"
               Grid.Row="1" />
        <Label Content="Start New Report"
               HorizontalAlignment="Left"
               FontSize="18"
               FontWeight="Bold"
               Margin="0,24,0,0"
               Grid.Column="1"
               Grid.Row="2"/>
        <Grid HorizontalAlignment="Stretch"
              ColumnDefinitions="*, Auto"
              Margin="0,8,0,0"
              Grid.Column="1"
              Grid.Row="3">
            <TextBox Watermark="Feb 2024 Report"
                     Classes="clearButton"
                     Text="{Binding CreatingReportTitle}"
                     VerticalAlignment="Stretch"
                     HorizontalAlignment="Stretch"
                     TextWrapping="Wrap"
                     Margin="0,0,16,0"
                     Grid.Column="0" />
            <Button Command="{Binding StartReport}"
                    Classes="accent"
                    Grid.Column="1">
                <TextBlock>
                    <Run Text="&#xe494;"
                        FontFamily="{StaticResource FontAwesomeSolid}" /> Create and Start Report</TextBlock>
            </Button>
        </Grid>
        <Label Content="Load Existing Report"
               FontSize="18"
               FontWeight="Bold"
               HorizontalAlignment="Left"
               Margin="0,16,0,0"
               Grid.Column="1"
               Grid.Row="4"/>
        <ScrollViewer Margin="0,8,0,32"
                      Grid.Column="1"
                      Grid.Row="5"
                      VerticalScrollBarVisibility="Visible"
                      AllowAutoHide="False"
                      HorizontalScrollBarVisibility="Disabled">
            <ItemsControl ItemsSource="{Binding SavedReports}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate x:DataType="models:PDFReportInfo">
                        <StackPanel Orientation="Vertical"
                                    Margin="12,4,4,8"
                                    Spacing="4">
                            <TextBlock Text="{Binding Title}" />
                            <!-- <TextBlock Text="{Binding BaseFolder}" 
                                       Foreground="Gray"
                                       TextWrapping="Wrap" /> -->
                            <TextBlock Foreground="Gray"
                                       TextWrapping="Wrap">
                                Last saved on: <Run Text="{Binding LastSaved, StringFormat='{}{0:yyyy-MM-dd}'}"/>
                            </TextBlock>
                            <StackPanel Orientation="Horizontal"
                                        Spacing="8">
                                <Button Command="{Binding $parent[UserControl].((vm:StartNewChooseReportViewModel)DataContext).LoadExistingReport}"
                                        CommandParameter="{Binding}"
                                        Classes="accent"
                                        Grid.Column="1">
                                    <TextBlock>
                                        <Run Text="&#xf56f;"
                                            FontFamily="{StaticResource FontAwesomeSolid}" /> Load Report</TextBlock>
                                </Button>
                                <Button Command="{Binding $parent[UserControl].((vm:StartNewChooseReportViewModel)DataContext).DeleteExistingReport}"
                                        CommandParameter="{Binding}"
                                        Classes="Danger"
                                        Grid.Column="1">
                                    <TextBlock>
                                        <Run Text="&#xf1f8;"
                                            FontFamily="{StaticResource FontAwesomeSolid}" /> Delete Report</TextBlock>
                                </Button>
                            </StackPanel>
                            <Rectangle Fill="Gray" Height="2" HorizontalAlignment="Stretch" Margin="0,8,0,0"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>