<?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.CouponsPage"
             xmlns:models="clr-namespace:GMCabsDriverAssistantSolution.ViewModels"
             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">
            <StackLayout Orientation="Horizontal"
                         Margin="20,40,20,30">
                <Label Text="Available Coupons"
                       FontSize="25"
                       TextColor="Black"
                       VerticalTextAlignment="Center"
                       HorizontalOptions="StartAndExpand"/>
                <ImageButton Source="sync.png"
                             HeightRequest="30"
                             BackgroundColor="Transparent"
                             HorizontalOptions="EndAndExpand"
                             Command="{Binding SyncCouponCommand}"/>
            </StackLayout>
            <CarouselView 
                ItemsSource="{Binding Coupons}"
                Loop="False"
                EmptyView ="{Binding EmptyViewMessage}" 
                PeekAreaInsets="40">
                <!--<CarouselView.EmptyView>
                    <ContentView >
                        <StackLayout 
                                Orientation="Vertical" 
                                HorizontalOptions="CenterAndExpand"
                                VerticalOptions="CenterAndExpand"
                                
                            >
                            <Image
                                    Source="support"
                                    HorizontalOptions="Center"
                                    HeightRequest="70"/>
                            <Label
                                    Text="{Binding EmptyViewMessage}"
                                    TextColor="Black"
                                    FontSize="20"
                                    HorizontalTextAlignment="Center"
                                    VerticalTextAlignment="Center"/>
                        </StackLayout>
                    </ContentView>
                </CarouselView.EmptyView>-->
                <CarouselView.ItemTemplate>
                    <DataTemplate>
                        <StackLayout>
                            <Frame 
                                HasShadow="True"
                                BorderColor="DarkGray" 
                                CornerRadius="12" 
                                Margin="8" 
                                HorizontalOptions="Center" 
                                VerticalOptions="StartAndExpand"
                                BackgroundColor="White">
                                <StackLayout>
                                    <Label 
                                        Text="{Binding ExpiryDate, StringFormat='Expires: {0:dd/MM/yyyy}'}" 
                                        HorizontalOptions="Center"
                                        VerticalOptions="Center"
                                        MaxLines="1"
                                        TextColor="Black"
                                        FontSize="16"/>
                                    <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 Text="{Binding Amount, StringFormat='${0:#.00}'}"
                                       TextColor="Black"
                                       HorizontalOptions="Center"
                                       FontSize="28"/>
                                </StackLayout>
                            </Frame>
                        </StackLayout>
                    </DataTemplate>
                </CarouselView.ItemTemplate>
            </CarouselView>
            <Button VerticalOptions="EndAndExpand"
                    Margin="40,0,40,15"
                    Text="View History"
                    FontSize="20"
                    Clicked="OnCouponHistoryViewClicked"/>
        </StackLayout>

    </ContentPage.Content>

</ContentPage>