<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="CafeTerrace.Views.CategoryPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:forms="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
    xmlns:model="clr-namespace:CafeTerrace.Models;assembly=CafeTerrace"
    xmlns:prism="http://prismlibrary.com"
    prism:ViewModelLocator.AutowireViewModel="True"
    BackgroundColor="{StaticResource Gray-200}"
    FlowDirection="RightToLeft"
    NavigationPage.HasNavigationBar="False">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*" />
            <RowDefinition Height="10*" />
        </Grid.RowDefinitions>
        <Frame
            Grid.Row="0"
            Margin="0,-15,0,2"
            Padding="0"
            CornerRadius="15">
            <Grid>
                <forms:CachedImage Aspect="AspectFill" Source="{Binding Path=HeaderImage}" />
                <Grid Padding="20,30,20,0" BackgroundColor="#70000000">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Label
                        Grid.Column="0"
                        FontFamily="{StaticResource ShabnameBold}"
                        FontSize="22"
                        Text="{Binding Title}"
                        TextColor="White"
                        VerticalOptions="Center" />

                    <Button
                        Grid.Column="1"
                        Padding="0"
                        BackgroundColor="#95000000"
                        Command="{Binding BackButtonCommand}"
                        CornerRadius="25"
                        FontFamily="{StaticResource MaterialFontFamily}"
                        FontSize="35"
                        HeightRequest="45"
                        Text="{x:Static model:MaterialIconFont.ChevronLeft}"
                        TextColor="{StaticResource Gray-100}"
                        VerticalOptions="Center"
                        WidthRequest="45" />
                </Grid>
            </Grid>
        </Frame>

        <ScrollView Grid.Row="1">
            <FlexLayout
                AlignContent="Start"
                BindableLayout.ItemsSource="{Binding Path=Categories}"
                HorizontalOptions="Center"
                JustifyContent="Center"
                VerticalOptions="Fill"
                Wrap="Wrap">
                <BindableLayout.ItemTemplate>

                    <DataTemplate>

                        <Grid HeightRequest="170" WidthRequest="170">
                            <Grid>
                                <Frame
                                    Margin="4"
                                    Padding="0"
                                    CornerRadius="10"
                                    HeightRequest="150"
                                    HorizontalOptions="Center"
                                    VerticalOptions="Center"
                                    WidthRequest="170">
                                    <forms:CachedImage Aspect="AspectFill" Source="{Binding ImageBase64}" />
                                </Frame>
                                <Frame
                                    Margin="2"
                                    Padding="15,4"
                                    BackgroundColor="{StaticResource PrimaryColor}"
                                    CornerRadius="50"
                                    HorizontalOptions="Center"
                                    VerticalOptions="End">
                                    <Label
                                        FontFamily="{StaticResource Shabname}"
                                        FontSize="14"
                                        HorizontalOptions="Center"
                                        Text="{Binding CategoryName}"
                                        TextColor="Accent"
                                        VerticalOptions="Center" />
                                </Frame>
                                <Grid.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="CategoryItem_OnTapped" />
                                </Grid.GestureRecognizers>
                            </Grid>

                            <Frame
                                Margin="4"
                                Padding="0"
                                BackgroundColor="#90000000"
                                CornerRadius="10"
                                HeightRequest="130"
                                IsVisible="{Binding DontShow}"
                                VerticalOptions="Center"
                                WidthRequest="140">
                                <StackLayout HorizontalOptions="Center" VerticalOptions="Center">

                                    <Label
                                        FontFamily="{StaticResource MaterialFontFamily}"
                                        FontSize="60"
                                        HorizontalOptions="Center"
                                        Text="{x:Static model:MaterialIconFont.CloseCircle}"
                                        TextColor="OrangeRed"
                                        VerticalOptions="Center" />
                                    <Label
                                        FontFamily="{StaticResource ShabnameBold}"
                                        FontSize="16"
                                        HorizontalOptions="Center"
                                        HorizontalTextAlignment="Center"
                                        Text="دسته بندی غیرفعال است"
                                        TextColor="White"
                                        VerticalOptions="Center" />
                                </StackLayout>
                            </Frame>
                        </Grid>
                    </DataTemplate>
                </BindableLayout.ItemTemplate>
            </FlexLayout>
        </ScrollView>

    </Grid>

</ContentPage>