<?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.LoginPage"
             xmlns:custom="clr-namespace:GMCabsDriverAssistantSolution.CustomControls"
             Title="LoginPage"
             Shell.FlyoutBehavior="Disabled"
             Shell.NavBarIsVisible="False">
    <ContentPage.Content>
        <StackLayout Orientation="Vertical" BackgroundColor="#DCDCDC">
            <StackLayout.Padding>
                <OnPlatform x:TypeArguments="Thickness">
                    <On Platform="Android">20</On>
                    <On Platform="iOS">20,60</On>
                </OnPlatform>
            </StackLayout.Padding>
            <Image Source="{StaticResource GMImage}" Style="{StaticResource ImageStyle}"/>
            <Frame Style="{StaticResource NoUnderlineEntryFrameStyle}" Margin="{StaticResource FrameCustomMargin}">
                <Grid MinimumHeightRequest="50" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="36"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="phone_image.png"
                           HeightRequest="36"
                           WidthRequest="36"
                           Aspect="AspectFit"/>
                    <custom:NoUnderlineEntry Grid.Column="1"
                                             x:Name="PhoneNumber"
                                             FontSize="20"
                                             Keyboard="Telephone"
                                             MaxLength="10"
                                             Text="{Binding PhoneNumber}"
                                             Placeholder="Mobile Number"
                                             Style="{StaticResource EntryStyle}"
                                             Margin="0,0,0,-8"/>
                </Grid>
            </Frame>
            <Frame Style="{StaticResource NoUnderlineEntryFrameStyle}" Margin="{StaticResource FrameCustomMargin}">
                <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="Driver Pin"
                                             IsPassword="True"
                                             MaxLength="8"
                                             Style="{StaticResource EntryStyle}"/>
                </Grid>
            </Frame>
            <Grid Margin="{StaticResource LoginGridCustomMargin}"
                  MinimumHeightRequest="40">
                <ActivityIndicator IsRunning="True" IsVisible="{Binding IsBusy}"/>
                <Button Text="Login" 
                        FontSize="20"
                        Command="{Binding LoginCommand}"
                        IsVisible="{Binding IsBusy}"
                        MinimumHeightRequest="40"
                        Margin="{StaticResource LoginButtonMargin}">
                    <Button.Triggers>
                        <DataTrigger TargetType="Button" Binding="{Binding IsBusy}" Value="False">
                            <Setter Property="IsVisible" Value="True" />
                        </DataTrigger>
                        <DataTrigger TargetType="Button" Binding="{Binding IsBusy}" Value="True">
                            <Setter Property="IsVisible" Value="False" />
                        </DataTrigger>
                    </Button.Triggers>
                </Button>
            </Grid>
            <!--<Label Text="Send Driver Pin" 
                   HorizontalTextAlignment="Center" 
                   Margin="0,32,0,22" 
                   FontSize="Title" 
                   TextColor="{StaticResource Primary}" 
                   FontAttributes="Bold">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding ResetDriverPin}" />
                </Label.GestureRecognizers>
            </Label>-->
            <Label Text="Register" 
                   HorizontalTextAlignment="Center" 
                   Margin="{StaticResource RegisterLabelMargin}" 
                   FontSize="Title" 
                   TextColor="{StaticResource Primary}" 
                   FontAttributes="Bold">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding Register}" />
                </Label.GestureRecognizers>
            </Label>
            <Label Text="{Binding ErrorMessage}" 
                   Margin="{StaticResource ErrorLabelMargin}"
                   HorizontalTextAlignment="Center" 
                   FontSize="20" 
                   TextColor="Red"/>

            <Label Text="{StaticResource GMCabsInformationMessageText}"
                   HorizontalTextAlignment="Center"
                   VerticalOptions="End"
                   Margin="{StaticResource InformationLabelMargin}"
                   FontSize="15"
                   TextColor="#555"/>
            <Label Text="02 9667 2028" 
                   HorizontalTextAlignment="Center" 
                   VerticalOptions="EndAndExpand"
                   Margin="0,0,0,5"
                   TextColor="Black"
                   FontAttributes="Bold"
                   FontSize="20"
                   IsVisible="{Binding ShowSupportNumber}"/>
            <Label Text="{Binding InstalledImei}" 
                   HorizontalTextAlignment="Center" 
                   VerticalOptions="EndAndExpand"
                   Margin="0,0,0,5"
                   TextColor="Black"
                   FontAttributes="Bold"
                   FontSize="20"
                   IsVisible="{Binding ShowInstalledImei}"/>
            <Button Text="ADMIN SETUP"
                    FontSize="20"
                    Margin="{StaticResource AdminSetUpButtonMargin}"
                    ImageSource="adminlock.png"
                    ContentLayout="Left,20"
                    Command="{Binding AdminSetUpCommand}"/>

        </StackLayout>
    </ContentPage.Content>

</ContentPage>