<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:icons="using:Richasy.FluentIcon.Uwp"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.Pgc">

    <MenuFlyout x:Key="DefaultSeasonItemContextFlyout">
        <MenuFlyoutItem
            x:Name="OpenInBroswerItem"
            AutomationProperties.Name="{loc:Locale Name=OpenInBroswer}"
            Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.OpenInBroswerCommand}"
            Text="{loc:Locale Name=OpenInBroswer}">
            <MenuFlyoutItem.Icon>
                <icons:RegularFluentIcon Symbol="Globe16" />
            </MenuFlyoutItem.Icon>
        </MenuFlyoutItem>
    </MenuFlyout>

    <Style x:Key="DefaultSeasonItemStyle" TargetType="local:SeasonItem">
        <Setter Property="CoverWidth" Value="120" />
        <Setter Property="CoverHeight" Value="160" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SeasonItem">
                    <controls:CardPanel
                        x:Name="RootCard"
                        AutomationProperties.Name="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}"
                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayCommand}"
                        ContextFlyout="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ContextFlyout, TargetNullValue={StaticResource DefaultSeasonItemContextFlyout}}"
                        IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsSelected}"
                        IsEnableCheck="False"
                        IsEnableHoverAnimation="False">
                        <Grid Padding="12" ColumnSpacing="12">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid VerticalAlignment="Center" CornerRadius="{ThemeResource ControlCornerRadius}">
                                <controls:CommonImageEx
                                    x:Name="CoverImage"
                                    Width="{TemplateBinding CoverWidth}"
                                    Height="{TemplateBinding CoverHeight}"
                                    ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Cover.Uri}" />
                            </Grid>
                            <Grid Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid x:Name="TitleContainer" Height="48">
                                    <TextBlock
                                        x:Name="TitleBlock"
                                        Style="{StaticResource SubtitleTextBlockStyle}"
                                        HorizontalAlignment="Left"
                                        FontSize="14"
                                        MaxLines="2"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}" IsEnabled="{Binding ElementName=TitleBlock, Path=IsTextTrimmed}" />
                                        </ToolTipService.ToolTip>
                                    </TextBlock>
                                </Grid>

                                <TextBlock
                                    Style="{StaticResource CaptionTextBlockStyle}"
                                    Grid.Row="1"
                                    HorizontalAlignment="Left"
                                    MaxLines="1"
                                    Opacity="0.6"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Subtitle}"
                                    ToolTipService.ToolTip="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Subtitle}" />

                                <Grid
                                    Grid.Row="2"
                                    Margin="0,4,0,0"
                                    HorizontalAlignment="Left"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.HighlightTitle, Converter={StaticResource ObjectToVisibilityConverter}}">
                                    <Rectangle
                                        Fill="{ThemeResource AccentBadgeBackground}"
                                        RadiusX="4"
                                        RadiusY="4" />
                                    <TextBlock
                                        Style="{StaticResource CaptionTextBlockStyle}"
                                        Margin="6,4"
                                        FontSize="10"
                                        Foreground="{ThemeResource AccentFillColorDefaultBrush}"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.HighlightTitle}" />
                                </Grid>

                                <TextBlock
                                    Style="{StaticResource CaptionTextBlockStyle}"
                                    Grid.Row="4"
                                    Margin="0,4,0,4"
                                    HorizontalAlignment="Left"
                                    MaxLines="2"
                                    Opacity="0.6"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Description}"
                                    ToolTipService.ToolTip="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Description}"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Description, Converter={StaticResource ObjectToVisibilityConverter}}" />

                                <Grid Grid.Row="5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Tags, Converter={StaticResource ObjectToVisibilityConverter}}">
                                        <TextBlock
                                            Style="{StaticResource CaptionTextBlockStyle}"
                                            VerticalAlignment="Bottom"
                                            Opacity="0.6"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Tags}" />
                                    </Grid>
                                    <TextBlock
                                        Grid.RowSpan="2"
                                        Grid.Column="1"
                                        Margin="12,0,0,0"
                                        VerticalAlignment="Bottom"
                                        FontSize="28"
                                        FontWeight="Bold"
                                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.CommunityInformation.Score, Mode=OneWay}"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowRating}" />
                                </Grid>
                            </Grid>
                        </Grid>
                    </controls:CardPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SlimSeasonItemStyle" TargetType="local:SeasonItem">
        <Setter Property="CoverWidth" Value="100" />
        <Setter Property="CoverHeight" Value="140" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SeasonItem">
                    <controls:CardPanel
                        x:Name="RootCard"
                        AutomationProperties.Name="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}"
                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayCommand}"
                        ContextFlyout="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ContextFlyout, TargetNullValue={StaticResource DefaultSeasonItemContextFlyout}}"
                        IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsSelected}"
                        IsEnableCheck="False"
                        IsEnableHoverAnimation="False">

                        <Grid Padding="12" ColumnSpacing="12">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid VerticalAlignment="Center" CornerRadius="{ThemeResource ControlCornerRadius}">
                                <controls:CommonImageEx
                                    x:Name="CoverImage"
                                    Width="{TemplateBinding CoverWidth}"
                                    Height="{TemplateBinding CoverHeight}"
                                    ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Cover.Uri}" />
                            </Grid>
                            <Grid Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid x:Name="TitleContainer" Height="28">
                                    <TextBlock
                                        x:Name="TitleBlock"
                                        Style="{StaticResource SubtitleTextBlockStyle}"
                                        HorizontalAlignment="Left"
                                        FontSize="14"
                                        MaxLines="2"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}" IsEnabled="{Binding ElementName=TitleBlock, Path=IsTextTrimmed}" />
                                        </ToolTipService.ToolTip>
                                    </TextBlock>
                                </Grid>

                                <TextBlock
                                    Style="{StaticResource CaptionTextBlockStyle}"
                                    Grid.Row="1"
                                    HorizontalAlignment="Left"
                                    MaxLines="2"
                                    Opacity="0.6"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Description}"
                                    ToolTipService.ToolTip="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Description}" />

                                <Grid
                                    Grid.Row="2"
                                    Margin="0,8,0,0"
                                    HorizontalAlignment="Left"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.HighlightTitle, Converter={StaticResource ObjectToVisibilityConverter}}">
                                    <Rectangle
                                        Fill="{ThemeResource AccentBadgeBackground}"
                                        RadiusX="4"
                                        RadiusY="4" />
                                    <TextBlock
                                        Style="{StaticResource CaptionTextBlockStyle}"
                                        Margin="6,4"
                                        FontSize="10"
                                        Foreground="{ThemeResource AccentFillColorDefaultBrush}"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.HighlightTitle}" />
                                </Grid>

                                <Grid Grid.Row="4">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid VerticalAlignment="Bottom" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Tags, Converter={StaticResource ObjectToVisibilityConverter}}">
                                        <TextBlock
                                            Style="{StaticResource CaptionTextBlockStyle}"
                                            Opacity="0.6"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Tags}" />
                                    </Grid>

                                    <TextBlock
                                        Grid.RowSpan="2"
                                        Grid.Column="1"
                                        Margin="12,0,0,0"
                                        VerticalAlignment="Bottom"
                                        FontSize="28"
                                        FontWeight="Bold"
                                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.CommunityInformation.Score, Mode=OneWay}"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowRating}" />
                                </Grid>
                            </Grid>
                        </Grid>
                    </controls:CardPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style BasedOn="{StaticResource DefaultSeasonItemStyle}" TargetType="local:SeasonItem" />
</ResourceDictionary>
