<?xml version="1.0" encoding="utf-8" ?>
<l:AppContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:l="clr-namespace:Blahblah.FlowerApp"
    xmlns:ctl="clr-namespace:Blahblah.FlowerApp.Controls"
    x:Class="Blahblah.FlowerApp.LoginPage"
    x:Name="loginPage"
    x:DataType="l:LoginPage">

    <Grid RowDefinitions="*,Auto,*" BindingContext="{x:Reference loginPage}">
        <Image Grid.RowSpan="3" Aspect="AspectFill" Source="{AppThemeBinding Light=loginbg.png, Dark=loginbg_dark.png}"/>
        <Frame Grid.Row="1" Margin="40,0" HasShadow="True" BorderColor="Transparent">
            <Frame.Shadow>
                <Shadow Brush="{AppThemeBinding Light={StaticResource Gray200Brush}, Dark={StaticResource Gray500Brush}}"
                        Offset="5,5"
                        Radius="40"
                        Opacity="0.6"/>
            </Frame.Shadow>
            <VerticalStackLayout Spacing="12">
                <Entry Text="{Binding UserId}" IsEnabled="{Binding IsEnabled}" Keyboard="Email" Placeholder="{l:Lang userId, Default=User ID}"/>
                <Entry Text="{Binding Password}" IsEnabled="{Binding IsEnabled}" IsPassword="True" Placeholder="{l:Lang password, Default=Password}"/>
                <Label Text="{l:Lang forgotPassword, Default=Forgot password?}" Margin="0,20,0,0" TextColor="Gray"/>
                <Label Text="{Binding ErrorMessage}" Margin="0,10"
                       TextColor="{AppThemeBinding Light={StaticResource Red100Accent}, Dark={StaticResource Red300Accent}}"
                       IsVisible="{Binding ErrorMessage, Converter={StaticResource notNullConverter}}"/>
                <Button CornerRadius="6" Text="{l:Lang logIn, Default=Log In}" IsEnabled="{Binding IsEnabled}" BackgroundColor="#007bfc"
                        Clicked="Login_Clicked"/>
            </VerticalStackLayout>
        </Frame>
        <Frame Grid.Row="1" x:Name="loading" BorderColor="Transparent" Margin="0" Padding="20" BackgroundColor="#40000000"
                   IsVisible="False" Opacity="0" HorizontalOptions="Center" VerticalOptions="Center">
            <ActivityIndicator HorizontalOptions="Center" VerticalOptions="Center" IsRunning="True"/>
        </Frame>
    </Grid>

</l:AppContentPage>