<?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.CouponsV2Page"
             Title="{Binding Title}"
             Shell.FlyoutBehavior="Disabled">
    <ContentPage.Resources>
        <ResourceDictionary>
            <Color x:Key="Accent">#96d1ff</Color>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Orientation="Vertical"
                     BackgroundColor="#DCDCDC">
            <Grid Margin="40,40,40,20">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="4*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Button
                    x:Name="BackButton"
                    Text="Back"
                    ImageSource="back_arrow.png"
                    Command="{Binding BackCouponCommand}"
                    IsVisible="{Binding IsBackButton}"
                    Grid.Row="0" Grid.Column="0"                    
                    TextColor="Black"
                    BackgroundColor="Transparent"
                    BorderColor="Transparent"
                    Visual="Default"/>
                <ImageButton 
                    Source="sync.png"
                    HeightRequest="30"
                    BackgroundColor="Transparent"
                    HorizontalOptions="CenterAndExpand"
                    Command="{Binding SyncCouponCommand}"
                    Grid.Row="0" Grid.Column="1"/>
                <Button
                    x:Name="NextButton"
                    Text="Next"
                    ImageSource="next_arrow.png"
                    Command="{Binding NextCouponCommand}"
                    IsVisible="{Binding IsNextButton}"
                    Grid.Row="0" Grid.Column="2"
                    TextColor="Black"                 
                    BackgroundColor="Transparent"
                    BorderColor="Transparent"
                    Visual="Default"/>
            </Grid>
            <StackLayout IsVisible="{Binding HasCoupons}">
                <Frame 
                    HasShadow="True"
                    BorderColor="DarkGray" 
                    CornerRadius="12" 
                    Margin="8" 
                    HorizontalOptions="Center" 
                    VerticalOptions="StartAndExpand"
                    BackgroundColor="White">
                    <StackLayout>
                        <Grid HeightRequest="240"
                            WidthRequest="240">
                            <ActivityIndicator IsRunning="True" 
                                IsVisible="true"
                                Scale="0.5"/>
                            <Image 
                                Source="{Binding Image}" 
                                Aspect="AspectFit"
                                HorizontalOptions="Center"
                                Margin="8,0" />
                        </Grid>
                        <Label
                            HorizontalOptions="Center">
                            <Label.FormattedText>
                                <FormattedString>
                                    <Span Text="Redemption Details"
                                          TextColor="Blue"                                          
                                          TextDecorations="Underline"
                                          FontSize="20">
                                        <Span.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding RedemptionDetails}"/>
                                        </Span.GestureRecognizers>
                                    </Span>
                                </FormattedString>
                            </Label.FormattedText>
                        </Label>
                    </StackLayout>
                </Frame>
            </StackLayout>
            <StackLayout IsVisible="{Binding HasEmptyMessage}">
                <Label Text="{Binding EmptyViewMessage}"
                       FontSize="25"
                       TextColor="Black"
                       HorizontalOptions="Center"/>
            </StackLayout>
            <Button VerticalOptions="EndAndExpand"
                    Margin="40,0,40,15"
                    Text="View History"
                    FontSize="20"
                    Clicked="OnCouponHistoryViewClicked"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>