<?xml version="1.0" encoding="UTF-8"?>
<u:AdaptedPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               xmlns:mdl="clr-namespace:Pixiview.Illust"
               xmlns:u="clr-namespace:Pixiview.UI"
               xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
               x:Class="Pixiview.Illust.ViewIllustPage"
               ios:Page.UseSafeArea="False"
               Shell.TabBarIsVisible="False"
               BackgroundColor="{DynamicResource WindowColor}"
               Title="{Binding IllustItem.Title}">
    <ContentPage.ToolbarItems>
        <ToolbarItem Order="Primary" Clicked="Favorite_Clicked"
                     IconImageSource="{Binding IsFavorite}"/>
    </ContentPage.ToolbarItems>
    <Grid Padding="{Binding PageTopMargin}">
        <CarouselView ItemsSource="{Binding Illusts}" HorizontalScrollBarVisibility="Never"
                      PositionChanged="CarouselView_PositionChanged">
            <CarouselView.ItemsLayout>
                <LinearItemsLayout Orientation="Horizontal" ItemSpacing="20"/>
            </CarouselView.ItemsLayout>
            <CarouselView.ItemTemplate>
                <DataTemplate x:DataType="mdl:IllustDetailItem">
                    <Grid>
                        <Image Source="{Binding Image}"
                               HorizontalOptions="Fill" VerticalOptions="Fill"
                               Aspect="AspectFit"/>
                        <Frame HasShadow="False" Margin="0" Padding="20" CornerRadius="8"
                               IsVisible="{Binding Loading}"
                               HorizontalOptions="Center" VerticalOptions="Center"
                               BackgroundColor="{DynamicResource MaskColor}">
                            <ActivityIndicator IsRunning="True" IsVisible="True"
                                               Color="{DynamicResource WindowColor}"/>
                        </Frame>
                        <ActivityIndicator IsRunning="True" IsVisible="{Binding Downloading}"
                                           Margin="10"
                                           HorizontalOptions="Start" VerticalOptions="Start"
                                           Color="{DynamicResource TextColor}"/>
                    </Grid>
                </DataTemplate>
            </CarouselView.ItemTemplate>
        </CarouselView>

        <u:RoundLabel Text="{Binding PagePositionText}"
                      BackgroundColor="{DynamicResource MaskColor}" Margin="0, 6, 6, 0"
                      Padding="6, 4" CornerRadius="6"
                      HorizontalOptions="End" VerticalOptions="Start"
                      FontSize="Micro" TextColor="White"
                      IsVisible="{Binding IsPageVisible}"/>
    </Grid>
</u:AdaptedPage>
