<?xml version="1.0" encoding="utf-8" ?>
<local:HistoryPageBase
    x:Class="BiliCopilot.UI.Pages.Overlay.HistoryPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:components="using:BiliCopilot.UI.ViewModels.Components"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:history="using:BiliCopilot.UI.Controls.History"
    xmlns:local="using:BiliCopilot.UI.Pages.Overlay"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <DataTemplate x:Key="VideoTemplate" x:DataType="components:VideoHistorySectionDetailViewModel">
            <history:VideoHistorySection ViewModel="{x:Bind}" />
        </DataTemplate>
        <DataTemplate x:Key="LiveTemplate" x:DataType="components:LiveHistorySectionDetailViewModel">
            <history:LiveHistorySection ViewModel="{x:Bind}" />
        </DataTemplate>
        <DataTemplate x:Key="ArticleTemplate" x:DataType="components:ArticleHistorySectionDetailViewModel">
            <history:ArticleHistorySection ViewModel="{x:Bind}" />
        </DataTemplate>

        <ext:HistorySectionTemplateSelector
            x:Key="TemplateSelector"
            ArticleTemplate="{StaticResource ArticleTemplate}"
            LiveTemplate="{StaticResource LiveTemplate}"
            VideoTemplate="{StaticResource VideoTemplate}" />
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="56" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <history:HistoryHeader />
        <Border
            Grid.Row="1"
            Height="1"
            HorizontalAlignment="Stretch"
            Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
        <ContentControl
            Grid.Row="2"
            Content="{x:Bind ViewModel.SelectedSection, Mode=OneWay}"
            ContentTemplateSelector="{StaticResource TemplateSelector}"
            Style="{StaticResource AppContentControlStyle}"
            Visibility="{x:Bind ViewModel.IsSearchMode, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
        <history:HistoryVideoSearchSection Grid.Row="2" Visibility="{x:Bind ViewModel.IsSearchMode, Mode=OneWay}" />
    </Grid>
</local:HistoryPageBase>
