<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="CafeTerrace.Views.PaymentPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:model="clr-namespace:CafeTerrace.Models"
    xmlns:prism="http://prismlibrary.com"
    prism:ViewModelLocator.AutowireViewModel="True"
    BackgroundColor="{StaticResource PrimaryColor}"
    NavigationPage.HasNavigationBar="False">
    <ScrollView>
        <StackLayout
            Margin="20,40,20,20"
            FlowDirection="RightToLeft"
            VerticalOptions="Center">
            <Frame Margin="3" CornerRadius="8">
                <StackLayout>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Margin="0,0,0,-2"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            FontSize="20"
                            Text="{x:Static model:MaterialIconFont.ClockOutline}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="1"
                            FontSize="14"
                            Text="زمان آماده شدن سفارش"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="2"
                            FontSize="18"
                            Text="{Binding Path=PraparingMenuiets, StringFormat='{0:N} دقیقه '}"
                            VerticalOptions="Center" />
                    </Grid>

                    <Grid Margin="0,10,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Margin="0,0,0,0"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            FontSize="20"
                            Text="{x:Static model:MaterialIconFont.ChairSchool}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="1"
                            FontSize="14"
                            Text="شماره میز"
                            VerticalOptions="Center" />

                        <Entry
                            Grid.Column="2"
                            Margin="0,-8,0,0"
                            FontSize="12"
                            HorizontalTextAlignment="Center"
                            Keyboard="Numeric"
                            Placeholder="شماره صندلی خود را وارد کنید"
                            Text="{Binding DeskNumber, Mode=OneWayToSource}"
                            VerticalOptions="Center" />
                    </Grid>
                </StackLayout>
            </Frame>
            <Frame
                Margin="3"
                Padding="10"
                CornerRadius="8">
                <ScrollView>

                    <StackLayout BindableLayout.ItemsSource="{Binding Foods}">
                        <BindableLayout.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="8">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="40" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Button
                                        Padding="0"
                                        BackgroundColor="Accent"
                                        Clicked="RemoveButton_OnClicked"
                                        CornerRadius="15"
                                        FontFamily="{StaticResource MaterialFontFamily}"
                                        HeightRequest="20"
                                        HorizontalOptions="Start"
                                        Text="{x:Static model:MaterialIconFont.Close}"
                                        TextColor="{StaticResource PrimaryColor}"
                                        VerticalOptions="Center"
                                        WidthRequest="20" />
                                    <Label
                                        Grid.Column="1"
                                        FontFamily="{StaticResource ShabnameBold}"
                                        FontSize="12"
                                        Text="{Binding Path=Food.Name}"
                                        VerticalOptions="Center" />
                                    <Label
                                        Grid.Column="2"
                                        FontSize="12"
                                        HorizontalOptions="Center"
                                        Text="{Binding Path=CountFood}"
                                        VerticalOptions="Center" />
                                    <StackLayout
                                        Grid.Column="3"
                                        HorizontalOptions="End"
                                        Orientation="Horizontal"
                                        VerticalOptions="Center">

                                        <Label
                                            FontSize="14"
                                            Text="{Binding Path=CountAmount, StringFormat='{0:N0}'}"
                                            TextColor="{StaticResource Orange}"
                                            VerticalOptions="Center" />

                                        <Label
                                            FontSize="12"
                                            Text="ریال"
                                            TextColor="{StaticResource Orange}"
                                            VerticalOptions="Center" />
                                    </StackLayout>
                                </Grid>
                            </DataTemplate>
                        </BindableLayout.ItemTemplate>
                    </StackLayout>
                </ScrollView>
            </Frame>
            <Frame Margin="3" CornerRadius="8">
                <StackLayout>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Margin="0,0,0,0"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            FontSize="20"
                            Text="{x:Static model:MaterialIconFont.Coin}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="1"
                            FontSize="14"
                            Text="مبلغ بدون تخفیف"
                            VerticalOptions="Center" />
                        <StackLayout
                            Grid.Column="2"
                            Orientation="Horizontal"
                            VerticalOptions="Center">

                            <Label
                                FontSize="19"
                                Text="{Binding Path=UnOfferedAmount, StringFormat='{0:N0}'}"
                                TextColor="{StaticResource Orange}" />

                            <Label
                                FontSize="12"
                                Text="ریال"
                                TextColor="{StaticResource Orange}"
                                VerticalOptions="Center" />
                        </StackLayout>
                    </Grid>
                    <Grid Margin="0,10,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Margin="0,0,0,0"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            FontSize="20"
                            Text="{x:Static model:MaterialIconFont.Coins}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="1"
                            FontSize="14"
                            Text="کد تخفف"
                            VerticalOptions="Center" />

                        <Entry
                            x:Name="offerCodeEntry"
                            Grid.Column="2"
                            Margin="0,-5,0,0"
                            FontSize="12"
                            HorizontalTextAlignment="Center"
                            Placeholder="کد تخفیف خود را وارد کنید"
                            Text="{Binding OfferCode, Mode=TwoWay}"
                            VerticalOptions="Center" />
                        <Button
                            Grid.Column="3"
                            Padding="0"
                            BackgroundColor="Accent"
                            Command="{Binding CheckOfferCodeButtonCommand}"
                            CommandParameter="{Binding Source={x:Reference offerCodeEntry}, Path=Text}"
                            CornerRadius="15"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            HeightRequest="25"
                            HorizontalOptions="Start"
                            Text="{x:Static model:MaterialIconFont.Check}"
                            TextColor="{StaticResource PrimaryColor}"
                            VerticalOptions="Center"
                            WidthRequest="25" />
                    </Grid>
                </StackLayout>
            </Frame>
            <Frame Margin="3" CornerRadius="8">
                <StackLayout VerticalOptions="Center">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Label
                            Margin="0,0,0,0"
                            FontFamily="{StaticResource MaterialFontFamily}"
                            FontSize="20"
                            Text="{x:Static model:MaterialIconFont.Coin}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="1"
                            FontSize="18"
                            Text="مبلغ کل"
                            VerticalOptions="Center" />
                        <StackLayout
                            Grid.Column="2"
                            Orientation="Horizontal"
                            VerticalOptions="Center">

                            <Label
                                FontSize="24"
                                Text="{Binding FinalAmount, StringFormat='{0:N0}'}"
                                TextColor="{StaticResource Orange}" />

                            <Label
                                FontSize="15"
                                Text="ریال"
                                TextColor="{StaticResource Orange}"
                                VerticalOptions="Center" />
                        </StackLayout>
                    </Grid>
                </StackLayout>
            </Frame>
            <Button
                BackgroundColor="Accent"
                Command="{Binding SubmitOrderButtonCommand}"
                CornerRadius="8"
                FontSize="24"
                Text="تایید سفارش"
                TextColor="{StaticResource PrimaryColor}" />
        </StackLayout>
    </ScrollView>
</ContentPage>