<?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:d="http://xamarin.com/schemas/2014/forms/design"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               xmlns:u="clr-namespace:Pixiview.UI"
               xmlns:util="clr-namespace:Pixiview.Utils"
               xmlns:r="clr-namespace:Pixiview.Resources"
               mc:Ignorable="d"
               x:Class="Pixiview.MainPage"
               BackgroundColor="{DynamicResource WindowColor}"
               OrientationChanged="Page_OrientationChanged"
               util:StatusBar.StatusBarStyle="{DynamicResource StatusBarStyle}">
    <NavigationPage.TitleView>
        <u:NavigationTitle Title="{r:Text Follow}"
                           IsLeftButtonVisible="True"
                           LeftButtonClicked="NavigationTitle_LeftButtonClicked"
                           RightButtonClicked="NavigationTitle_RightButtonClicked"/>
    </NavigationPage.TitleView>
    <Grid>
        <ScrollView HorizontalOptions="Fill" Padding="{Binding StatusBarPadding}">
            <u:FlowLayout ItemsSource="{Binding Illusts}"
                          HorizontalOptions="Fill" Column="{Binding Columns}"
                          Margin="16" RowSpacing="16" ColumnSpacing="16">
                <u:FlowLayout.ItemTemplate>
                    <DataTemplate>
                        <u:CardView Padding="0" Margin="0" CornerRadius="10"
                                    ShadowColor="#20000000"
                                    ShadowOffset="2, 2"
                                    BackgroundColor="{DynamicResource SubColor}">
                            <Grid HorizontalOptions="Fill">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <u:RoundImage BackgroundColor="LightGray"
                                              CornerRadius="10"
                                              CornerMasks="Top"
                                              Source="{Binding Image}"
                                              HorizontalOptions="Fill"
                                              Aspect="AspectFit"/>
                                <u:RoundLabel Text="R-18" BackgroundColor="#fd4363" Margin="6, 6, 0, 0"
                                              Padding="6, 2" CornerRadius="4"
                                              HorizontalOptions="Start" VerticalOptions="Start"
                                              FontSize="Micro" TextColor="White"
                                              IsVisible="{Binding IsRestrict}"/>
                                <u:RoundLabel Text="{Binding PageCountText}"
                                              FontFamily="{DynamicResource IconSolidFontFamily}"
                                              BackgroundColor="#50000000" Margin="0, 6, 6, 0"
                                              Padding="6, 4" CornerRadius="6"
                                              HorizontalOptions="End" VerticalOptions="Start"
                                              FontSize="Micro" TextColor="White"
                                              IsVisible="{Binding IsPageVisible}"/>
                                <Label Grid.Row="1" Text="{Binding Title}"
                                       Padding="8, 2"
                                       TextColor="{DynamicResource TextColor}"
                                       HorizontalOptions="Start"
                                       LineBreakMode="TailTruncation"
                                       FontSize="Small"/>
                                <StackLayout Grid.Row="2" Orientation="Horizontal" Padding="8, 0, 8, 8">
                                    <u:CircleImage WidthRequest="30" HeightRequest="30" Aspect="AspectFill"
                                                   Source="{Binding ProfileImage}"/>
                                    <Label Text="{Binding UserName}"
                                           VerticalOptions="Center"
                                           TextColor="{DynamicResource SubTextColor}"
                                           LineBreakMode="TailTruncation"
                                           FontSize="Micro"/>
                                </StackLayout>
                            </Grid>
                        </u:CardView>
                    </DataTemplate>
                </u:FlowLayout.ItemTemplate>
            </u:FlowLayout>
        </ScrollView>
        <ActivityIndicator IsRunning="True" IsEnabled="True" IsVisible="{Binding Loading}"
                           Margin="20"
                           HorizontalOptions="Center" VerticalOptions="Start"/>
    </Grid>
</u:AdaptedPage>