<?xml version="1.0" encoding="utf-8" ?>
<local:WebDavPlayerPageBase
    x:Class="BiliCopilot.UI.Pages.Overlay.WebDavPlayerPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="using:Richasy.WinUIKernel.Share.Base"
    xmlns:components="using:BiliCopilot.UI.Controls.Components"
    xmlns:core="using:BiliCopilot.UI.Controls.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:BiliCopilot.UI.Pages.Overlay"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:player="using:BiliCopilot.UI.Controls.Player"
    xmlns:webdav="using:BiliCopilot.UI.Controls.WebDav"
    mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition x:Name="HeaderRow" Height="56" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{x:Bind ViewModel.NavColumnWidth, Mode=OneWay, Converter={StaticResource GridLengthConverter}}" />
        </Grid.ColumnDefinitions>
        <Grid.ChildrenTransitions>
            <RepositionThemeTransition IsStaggeringEnabled="False" />
        </Grid.ChildrenTransitions>
        <Border
            x:Name="HeaderDivider"
            Grid.Row="1"
            Grid.ColumnSpan="3"
            Height="1"
            HorizontalAlignment="Stretch"
            Background="{ThemeResource DividerStrokeColorDefaultBrush}" />

        <webdav:WebDavPlayerMainHeader x:Name="MainHeader" ViewModel="{x:Bind ViewModel, Mode=OneWay}" />

        <Grid
            x:Name="VerticalHolderContainer"
            Grid.Row="2"
            Grid.Column="1" />

        <Grid
            x:Name="PlayerContainer"
            Grid.Row="2"
            Margin="0,0,-6,0">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <core:BiliPlayer
                x:Name="BiliPlayer"
                VerticalAlignment="Stretch"
                ViewModel="{x:Bind ViewModel.Player, Mode=OneWay}" />
            <core:ExternalTransportControl
                Grid.Row="1"
                Margin="0,12"
                ViewModel="{x:Bind ViewModel.Player, Mode=OneWay}"
                Visibility="{x:Bind ViewModel.Player.IsExternalPlayer, Mode=OneWay}">
                <core:ExternalTransportControl.LeftContent>
                    <Button
                        VerticalAlignment="Center"
                        Command="{x:Bind ViewModel.PlayNextVideoCommand, Mode=OneWay}"
                        Style="{StaticResource CircleIconButtonStyle}"
                        ToolTipService.ToolTip="{x:Bind ViewModel.NextVideoTip, Mode=OneWay}"
                        Visibility="{x:Bind ViewModel.HasNextVideo, Mode=OneWay}">
                        <ic:SymbolIcon
                            FontSize="14"
                            IconVariant="Filled"
                            Symbol="Next" />
                    </Button>
                </core:ExternalTransportControl.LeftContent>
            </core:ExternalTransportControl>
        </Grid>


        <TextBlock
            x:Name="SideHeader"
            Grid.Column="2"
            Margin="16,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Center"
            Text="{ext:Locale Name=Playlist}"
            Visibility="{x:Bind ViewModel.IsNavColumnManualHide, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />

        <webdav:WebDavPlayerSideBody
            x:Name="SideBody"
            Grid.Row="2"
            Grid.Column="2"
            VerticalAlignment="Stretch"
            ViewModel="{x:Bind ViewModel, Mode=OneWay}"
            Visibility="{x:Bind ViewModel.IsNavColumnManualHide, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />

        <!--  右侧分栏大小控制器  -->
        <base:ColumnSplitter
            x:Name="SideSplitter"
            Grid.RowSpan="3"
            Grid.Column="1"
            ColumnWidth="{x:Bind ViewModel.NavColumnWidth, Mode=TwoWay}"
            HideTip="{ext:Locale Name=Show}"
            IsHide="{x:Bind ViewModel.IsNavColumnManualHide, Mode=OneWay}"
            IsHideButtonEnabled="False"
            IsInvertDirection="True"
            MaxColumnWidth="500"
            MinColumnWidth="300"
            ShowTip="{ext:Locale Name=Hide}" />

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="DefaultState" />
                <VisualState x:Name="PlayerHostState">
                    <VisualState.Setters>
                        <Setter Target="HeaderRow.Height" Value="Auto" />
                        <Setter Target="MainHeader.Visibility" Value="Collapsed" />
                        <Setter Target="HeaderDivider.Visibility" Value="Collapsed" />
                        <Setter Target="SideSplitter.Visibility" Value="Collapsed" />
                        <Setter Target="SideHeader.Visibility" Value="Collapsed" />
                        <Setter Target="SideBody.Visibility" Value="Collapsed" />
                        <Setter Target="PlayerContainer.(Grid.ColumnSpan)" Value="3" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</local:WebDavPlayerPageBase>
