<?xml version="1.0" encoding="utf-8" ?>
<local:SearchPageBase
    x:Class="BiliCopilot.UI.Pages.Overlay.SearchPage"
    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:components1="using:BiliCopilot.UI.ViewModels.Components"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:local="using:BiliCopilot.UI.Pages.Overlay"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:search="using:BiliCopilot.UI.Controls.Search"
    mc:Ignorable="d">

    <Page.Resources>
        <DataTemplate x:Key="VideoSectionTemplate" x:DataType="components1:VideoSearchSectionDetailViewModel">
            <search:VideoSectionDetailControl ViewModel="{x:Bind}" />
        </DataTemplate>

        <DataTemplate x:Key="PgcSectionTemplate" x:DataType="components1:PgcSearchSectionDetailViewModel">
            <search:PgcSectionDetailControl ViewModel="{x:Bind}" />
        </DataTemplate>

        <DataTemplate x:Key="LiveSectionTemplate" x:DataType="components1:LiveSearchSectionDetailViewModel">
            <search:LiveSectionDetailControl ViewModel="{x:Bind}" />
        </DataTemplate>

        <DataTemplate x:Key="UserSectionTemplate" x:DataType="components1:UserSearchSectionDetailViewModel">
            <search:UserSectionDetailControl ViewModel="{x:Bind}" />
        </DataTemplate>

        <DataTemplate x:Key="ArticleSectionTemplate" x:DataType="components1:ArticleSearchSectionDetailViewModel">
            <search:ArticleSectionDetailControl ViewModel="{x:Bind}" />
        </DataTemplate>

        <ext:SearchSectionTemplateSelector
            x:Key="SectionSelector"
            ArticleTemplate="{StaticResource ArticleSectionTemplate}"
            LiveTemplate="{StaticResource LiveSectionTemplate}"
            PgcTemplate="{StaticResource PgcSectionTemplate}"
            UserTemplate="{StaticResource UserSectionTemplate}"
            VideoTemplate="{StaticResource VideoSectionTemplate}" />
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="56" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{x:Bind ViewModel.NavColumnWidth, Mode=OneWay, Converter={StaticResource GridLengthConverter}}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.ChildrenTransitions>
            <RepositionThemeTransition IsStaggeringEnabled="False" />
        </Grid.ChildrenTransitions>

        <Border
            Grid.Row="1"
            Grid.ColumnSpan="3"
            Height="1"
            HorizontalAlignment="Stretch"
            Background="{ThemeResource DividerStrokeColorDefaultBrush}" />

        <search:SearchHeader Grid.ColumnSpan="3" />

        <search:SearchSideBody
            Grid.Row="2"
            Margin="0,0,-6,0"
            Visibility="{x:Bind ViewModel.IsNavColumnManualHide, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />

        <ContentControl
            Grid.Row="2"
            Grid.Column="2"
            Margin="-6,0,0,0"
            Content="{x:Bind ViewModel.SelectedSection, Mode=OneWay}"
            ContentTemplateSelector="{StaticResource SectionSelector}"
            Style="{StaticResource AppContentControlStyle}" />

        <!--  左侧分栏大小控制器  -->
        <base:ColumnSplitter
            Grid.Row="1"
            Grid.RowSpan="2"
            Grid.Column="1"
            ColumnWidth="{x:Bind ViewModel.NavColumnWidth, Mode=TwoWay}"
            HideTip="{ext:Locale Name=Show}"
            IsHide="{x:Bind ViewModel.IsNavColumnManualHide, Mode=TwoWay}"
            ShowTip="{ext:Locale Name=Hide}" />
    </Grid>
</local:SearchPageBase>
