<?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="GMCabsDriverAssistantSolution.Views.UserRegistrationUpdateDriverPinPage"
             xmlns:vm="clr-namespace:GMCabsDriverAssistantSolution.ViewModels"
             xmlns:custom="clr-namespace:GMCabsDriverAssistantSolution.CustomControls"
             Shell.FlyoutBehavior="Disabled">
    <ContentPage.BindingContext>
        <vm:UserRegistrationUpdateDriverPinViewModel />
    </ContentPage.BindingContext>
    <ContentPage.Resources>
        <ResourceDictionary>
            <Style x:Key="EntryStyle" TargetType="Entry">
                <Setter Property="TextColor" Value="#000"></Setter>
                <Setter Property="PlaceholderColor" Value="#9999"></Setter>
                <Setter Property="TranslationY"  Value="1" />
                <Setter Property="MinimumHeightRequest" Value="36" />
            </Style>
            <Style x:Key="NoUnderlineEntryFrameStyle" TargetType="Frame">
                <Setter Property="Padding">
                    <OnPlatform x:TypeArguments="Thickness">
                        <On Platform="Android">16,4</On>
                        <On Platform="iOS">16</On>
                    </OnPlatform>
                </Setter>
                <Setter Property="CornerRadius" Value="12"></Setter>
                <Setter Property="Margin" Value="0,16,0,0"></Setter>
                <Setter Property="HasShadow" Value="True"></Setter>
                <Setter Property="MinimumHeightRequest" Value="50" />
                <Setter Property="BackgroundColor" Value="White" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Padding="16"
                     Orientation="Vertical" 
                     BackgroundColor="#DCDCDC">
            <Label Text="User Registration"
                   FontSize="Title"
                   TextColor="Black"
                   HorizontalOptions="CenterAndExpand"/>
            <Label Text="Enter Driver Pin and Register"
                   FontSize="Medium"
                   Margin="0,16,0,0"
                   TextColor="Gray"
                   HorizontalOptions="CenterAndExpand"/>
            <Frame Style="{StaticResource NoUnderlineEntryFrameStyle}" Margin="{OnIdiom Tablet='270,0,270,0'}">
                <Grid MinimumHeightRequest="50">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="36"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="key_pad_image.png"
                           HeightRequest="36"
                           WidthRequest="36"
                           Aspect="AspectFit"/>
                    <custom:NoUnderlineEntry x:Name="Pin"
                                             Grid.Column="1"                                             
                                             FontSize="20"
                                             Keyboard="Numeric"                                             
                                             Text="{Binding Pin}"
                                             Placeholder="Pin"
                                             IsPassword="True"
                                             Style="{StaticResource EntryStyle}"/>
                </Grid>
            </Frame>
            <Frame Style="{StaticResource NoUnderlineEntryFrameStyle}" Margin="{OnIdiom Tablet='270,0,270,0'}">
                <Grid MinimumHeightRequest="50">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="36"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="key_pad_image.png"
                           HeightRequest="36"
                           WidthRequest="36"
                           Aspect="AspectFit"/>
                    <custom:NoUnderlineEntry x:Name="ConfirmPin"
                                             Grid.Column="1"                                             
                                             FontSize="20"
                                             Keyboard="Numeric"                                             
                                             Text="{Binding ConfirmPin}"
                                             Placeholder="Confirm Pin"
                                             IsPassword="True"
                                             Style="{StaticResource EntryStyle}"/>
                </Grid>
            </Frame>
            <Button Text="Register"
                    FontSize="20"
                    Margin="{OnIdiom Phone='0,32,0,0',Tablet='270,0,270,0'}"
                    VerticalOptions="EndAndExpand"
                    Command="{Binding Register}"/>
            <Label Text="{Binding ErrorMessage}"
                   TextColor="Red"
                   HorizontalTextAlignment="Center"
                   FontSize="20"
                   VerticalOptions="EndAndExpand"/>
            <Button Text="Back"
                    FontSize="20"
                    Margin="{OnIdiom Phone='0,16,0,0',Tablet='270,0,270,0'}"
                    Command="{Binding Back}"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>