<base:LivePartitionDetailPageBase
    x:Class="Bili.App.Pages.Xbox.Overlay.LivePartitionDetailPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Bili.App.Controls.App"
    xmlns:base="using:Bili.App.Pages.Base"
    xmlns:behaviors="using:Bili.App.Behaviors"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:live="using:Bili.Models.Data.Live"
    xmlns:liveControl="using:Bili.App.Controls.Live"
    xmlns:liveModel="using:Bili.ViewModels.Interfaces.Live"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    mc:Ignorable="d">

    <interactivity:Interaction.Behaviors>
        <behaviors:InitializeBehavior />
    </interactivity:Interaction.Behaviors>

    <Grid x:Name="RootContainer">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <app:PageHeader>
            <app:PageHeader.Title>
                <StackPanel Orientation="Horizontal" Spacing="12">
                    <controls:CommonImageEx
                        x:Name="PartitionLogo"
                        Width="32"
                        ImageUrl="{x:Bind ViewModel.OriginPartition.Image.Uri, Mode=OneWay}" />
                    <TextBlock
                        x:Name="PartitionName"
                        Style="{StaticResource SubtitleTextBlockStyle}"
                        FontWeight="Bold"
                        Text="{x:Bind ViewModel.OriginPartition.Name, Mode=OneWay}" />
                </StackPanel>
            </app:PageHeader.Title>
        </app:PageHeader>


        <muxc:NavigationView
            x:Name="DetailNavigationView"
            Style="{StaticResource XboxSideNavigationViewStyle}"
            Grid.Row="1"
            ItemInvoked="OnTagItemInvoked"
            MenuItemsSource="{x:Bind ViewModel.Tags}"
            SelectedItem="{x:Bind ViewModel.CurrentTag, Mode=OneWay}">
            <muxc:NavigationView.MenuItemTemplate>
                <DataTemplate x:DataType="live:LiveTag">
                    <muxc:NavigationViewItem Content="{x:Bind}">
                        <muxc:NavigationViewItem.ContentTemplate>
                            <DataTemplate x:DataType="live:LiveTag">
                                <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{x:Bind Name}" />
                            </DataTemplate>
                        </muxc:NavigationViewItem.ContentTemplate>
                    </muxc:NavigationViewItem>
                </DataTemplate>
            </muxc:NavigationView.MenuItemTemplate>

            <ScrollViewer
                x:Name="ContentScrollViewer"
                Padding="{x:Bind CoreViewModel.PageHorizontalPadding, Converter={StaticResource HorizontalThicknessConverter}, Mode=OneWay}"
                HorizontalScrollMode="Disabled"
                IsTabStop="False"
                VerticalScrollBarVisibility="Auto">
                <Grid x:Name="ContentGrid" Visibility="{x:Bind ViewModel.IsReloading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                    <controls:VerticalRepeaterView
                        x:Name="VideoView"
                        Margin="0,0,0,12"
                        HeaderText="{loc:Locale Name=Live}"
                        ItemsSource="{x:Bind ViewModel.Items}"
                        MinWideItemHeight="208"
                        MinWideItemWidth="200">
                        <interactivity:Interaction.Behaviors>
                            <behaviors:IncrementalBehavior />
                        </interactivity:Interaction.Behaviors>
                        <controls:VerticalRepeaterView.AdditionalContent>
                            <Button
                                x:Name="SeeAllTagsButton"
                                Style="{StaticResource AccentButtonStyle}"
                                Command="{x:Bind ViewModel.SeeAllPartitionsCommand}"
                                Content="{loc:Locale Name=TotalTags}" />
                        </controls:VerticalRepeaterView.AdditionalContent>
                        <controls:VerticalRepeaterView.ItemTemplate>
                            <DataTemplate x:DataType="liveModel:ILiveItemViewModel">
                                <liveControl:LiveItem ViewModel="{x:Bind}" />
                            </DataTemplate>
                        </controls:VerticalRepeaterView.ItemTemplate>
                    </controls:VerticalRepeaterView>
                </Grid>
            </ScrollViewer>
        </muxc:NavigationView>



        <controls:OverlayLoadingPanel
            Grid.Row="2"
            IsBarActive="{x:Bind ViewModel.IsIncrementalLoading, Mode=OneWay}"
            IsRingActive="{x:Bind ViewModel.IsReloading, Mode=OneWay}" />
        <controls:ErrorPanel
            x:Name="ErrorPanel"
            Grid.Row="2"
            ActionContent="{loc:Locale Name=Refresh}"
            Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
            Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}">
            <interactivity:Interaction.Behaviors>
                <behaviors:ReloadBehavior />
            </interactivity:Interaction.Behaviors>
        </controls:ErrorPanel>
        <controls:ErrorPanel
            Grid.Row="2"
            Text="{loc:Locale Name=NoSpecificData}"
            Visibility="{x:Bind ViewModel.IsEmpty, Mode=OneWay}" />
    </Grid>
</base:LivePartitionDetailPageBase>
