<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
               xmlns:viewmodels="clr-namespace:Dollet.ViewModels.Popups"
               Color="Transparent"
               CanBeDismissedByTappingOutsideOfPopup="True"
               x:Class="Dollet.Pages.Popups.DateRangePopup"
               x:DataType="viewmodels:DateRangePopupViewModel"
               x:Name="This">

    <Border 
        Stroke="{StaticResource Primary}" 
        StrokeShape="RoundRectangle 20" 
        StrokeThickness="2"
        BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray600}}">

        <VerticalStackLayout Padding="20">
            <Grid ColumnDefinitions="auto, auto, auto">
                <Label Text="From:" HorizontalOptions="Center" FontAttributes="Italic"/>
                <Label Grid.Column="2" Text="To:" HorizontalOptions="Center" FontAttributes="Italic"/>

                <DatePicker Grid.Row="1" Date="{Binding DateFrom, Mode=TwoWay}" MaximumDate="{Binding MaxDateFrom}" FontSize="22" Margin="5"/>
                <Label Grid.Row="1" Grid.Column="1" Text="-" FontSize="22" Margin="5" VerticalOptions="Center"/>
                <DatePicker 
                    Grid.Row="1" 
                    Grid.Column="2" 
                    Date="{Binding DateTo, Mode=TwoWay}" 
                    MinimumDate="{Binding DateFrom}" 
                    MaximumDate="{Binding MaxDateTo}" 
                    FontSize="22" 
                    Margin="5"/>
            </Grid>

            <HorizontalStackLayout HorizontalOptions="Center" Spacing="10">
                <Button 
                    Text="Apply" 
                    FontSize="18"
                    MinimumWidthRequest="30"
                    BorderColor="{AppThemeBinding Dark={StaticResource PrimaryDark}}"
                    BorderWidth="1"
                    Command="{Binding ConfirmCommand}"
                    CommandParameter="{Binding Source={x:Reference This}}"/>

                <Button 
                    Text="Dismiss" 
                    FontSize="18"
                    MinimumWidthRequest="30"
                    BackgroundColor="White" 
                    TextColor="{StaticResource Primary}"
                    BorderColor="{StaticResource Primary}" 
                    BorderWidth="1"
                    Command="{Binding DismissCommand}"
                    CommandParameter="{Binding Source={x:Reference This}}"/>
            </HorizontalStackLayout>
        </VerticalStackLayout>
    </Border>
</toolkit:Popup>