<?xml version="1.0" encoding="UTF-8" ?>
<ContentView
    x:Class="CafeTerrace.Views.DialogBox.PersianDatePicker"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:model="clr-namespace:CafeTerrace.Models;assembly=CafeTerrace"
    Margin="15,80"
    FlowDirection="RightToLeft"
    VerticalOptions="Center"
    mc:Ignorable="d">
    <ContentView.Content>
        <Frame
            Padding="0"
            BackgroundColor="#eee"
            CornerRadius="8">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Frame Padding="8,12" BackgroundColor="Accent">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid VerticalOptions="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button
                                Margin="0,0"
                                Padding="0"
                                BackgroundColor="Transparent"
                                Clicked="NextMonthButton_OnClicked"
                                FontFamily="{StaticResource MaterialFontFamily}"
                                FontSize="30"
                                HeightRequest="26"
                                Text="{x:Static model:MaterialIconFont.ChevronRight}"
                                TextColor="{StaticResource PrimaryColor}"
                                VerticalOptions="Center"
                                WidthRequest="34" />
                            <Label
                                x:Name="monthLable"
                                Grid.Column="1"
                                FontSize="17"
                                HorizontalOptions="Center"
                                TextColor="{StaticResource PrimaryColor}"
                                VerticalOptions="Center" />

                            <Button
                                Grid.Column="2"
                                Margin="0,0"
                                Padding="0"
                                BackgroundColor="Transparent"
                                Clicked="PervMonthButton_OnClicked"
                                FontFamily="{StaticResource MaterialFontFamily}"
                                FontSize="30"
                                HeightRequest="26"
                                Text="{x:Static model:MaterialIconFont.ChevronLeft}"
                                TextColor="{StaticResource PrimaryColor}"
                                VerticalOptions="Center"
                                WidthRequest="34" />
                        </Grid>

                        <Grid Grid.Column="1" VerticalOptions="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button
                                Margin="0,0"
                                Padding="0"
                                BackgroundColor="Transparent"
                                Clicked="NextYearButton_OnClicked"
                                FontFamily="{StaticResource MaterialFontFamily}"
                                FontSize="30"
                                HeightRequest="35"
                                Text="{x:Static model:MaterialIconFont.ChevronRight}"
                                TextColor="{StaticResource PrimaryColor}"
                                VerticalOptions="Center"
                                WidthRequest="34" />
                            <Entry
                                x:Name="yearLable"
                                Grid.Column="1"
                                Focused="YearLable_OnFocused"
                                FontSize="20"
                                HorizontalOptions="Center"
                                Keyboard="Numeric"
                                TextChanged="YearLable_OnTextChanged"
                                TextColor="{StaticResource PrimaryColor}" />

                            <Button
                                Grid.Column="2"
                                Margin="0,0"
                                Padding="0"
                                BackgroundColor="Transparent"
                                Clicked="PervYearButton_OnClicked"
                                FontFamily="{StaticResource MaterialFontFamily}"
                                FontSize="30"
                                HeightRequest="35"
                                Text="{x:Static model:MaterialIconFont.ChevronLeft}"
                                TextColor="{StaticResource PrimaryColor}"
                                VerticalOptions="Center"
                                WidthRequest="34" />
                        </Grid>
                    </Grid>
                </Frame>
                <Grid Grid.Row="1" Margin="0,15">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Grid.Column="6"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="شنبه" />
                        <Label
                            Grid.Column="5"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="یک شنبه" />
                        <Label
                            Grid.Column="4"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="دو شنبه" />
                        <Label
                            Grid.Column="3"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="سه شنبه" />
                        <Label
                            Grid.Column="2"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="چهارشنبه" />
                        <Label
                            Grid.Column="1"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="پنج شنبه" />
                        <Label
                            Grid.Column="0"
                            FontSize="11"
                            HorizontalOptions="Center"
                            Text="جمعه" />

                    </Grid>
                    <ScrollView Grid.Row="1" HeightRequest="300">
                        <CollectionView x:Name="daysCollection">

                            <CollectionView.ItemTemplate>
                                <DataTemplate>
                                    <CollectionView
                                        FlowDirection="RightToLeft"
                                        HeightRequest="40"
                                        ItemsSource="{Binding .}">
                                        <CollectionView.ItemsLayout>
                                            <GridItemsLayout Orientation="Vertical" Span="7" />
                                        </CollectionView.ItemsLayout>
                                        <CollectionView.ItemTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Button
                                                        Margin="2"
                                                        Padding="0"
                                                        BackgroundColor="Transparent"
                                                        Clicked="DatePickerButton_OnClicked"
                                                        CornerRadius="50"
                                                        FontSize="16"
                                                        HeightRequest="35"
                                                        HorizontalOptions="Center"
                                                        IsEnabled="{Binding IsEnable}"
                                                        Text="{Binding PrDateTimeDate}"
                                                        TextColor="DimGray"
                                                        VerticalOptions="Center"
                                                        WidthRequest="35" />
                                                </Grid>
                                            </DataTemplate>
                                        </CollectionView.ItemTemplate>
                                    </CollectionView>
                                </DataTemplate>
                            </CollectionView.ItemTemplate>
                        </CollectionView>
                    </ScrollView>
                    <StackLayout Grid.Row="2" Orientation="Horizontal">
                        <Button
                            Margin="10,3"
                            Padding="15,4"
                            BackgroundColor="Accent"
                            Clicked="SubmitButton_OnClicked"
                            CornerRadius="8"
                            HeightRequest="35"
                            HorizontalOptions="Start"
                            Text="تایید"
                            TextColor="{StaticResource PrimaryColor}" />

                        <Button
                            Margin="10,3"
                            Padding="15,4"
                            BackgroundColor="Transparent"
                            Clicked="CloseButton_OnClicked"
                            CornerRadius="8"
                            HeightRequest="35"
                            HorizontalOptions="Start"
                            Text="بستن"
                            TextColor="Accent" />
                    </StackLayout>
                </Grid>
            </Grid>
        </Frame>
    </ContentView.Content>
</ContentView>