<local:MyFollowsPageBase
    x:Class="Bili.App.Pages.Desktop.MyFollowsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:account="using:Bili.ViewModels.Interfaces.Account"
    xmlns:app="using:Bili.App.Controls.App"
    xmlns:behaviors="using:Bili.App.Behaviors"
    xmlns:community="using:Bili.Models.Data.Community"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Pages.Desktop"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    xmlns:user="using:Bili.App.Controls.User"
    mc:Ignorable="d">

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

    <Grid RowSpacing="8">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <app:PageHeader RefreshCommand="{x:Bind ViewModel.ReloadCommand}">
            <app:PageHeader.Title>
                <TextBlock
                    Style="{StaticResource TitleTextBlockStyle}"
                    Margin="0,0,0,8"
                    HorizontalAlignment="Left"
                    TextTrimming="CharacterEllipsis">
                    <Run
                        FontWeight="Bold"
                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                        Text="{x:Bind ViewModel.UserName, Mode=OneWay}" />
                    <Run Text="{loc:Locale Name=FollowsSuffix}" />
                </TextBlock>
            </app:PageHeader.Title>
        </app:PageHeader>


        <muxc:NavigationView
            Style="{StaticResource TopNavigationViewStyle}"
            Grid.Row="1"
            Margin="{x:Bind CoreViewModel.PageHorizontalPadding, Converter={StaticResource HorizontalThicknessConverter}, Mode=OneWay}"
            ItemInvoked="OnNavItemInvoked"
            MenuItemsSource="{x:Bind ViewModel.Groups}"
            SelectedItem="{x:Bind ViewModel.CurrentGroup, Mode=OneWay}">
            <muxc:NavigationView.MenuItemTemplate>
                <DataTemplate x:DataType="community:FollowGroup">
                    <muxc:NavigationViewItem Content="{x:Bind}">
                        <muxc:NavigationViewItem.ContentTemplate>
                            <DataTemplate x:DataType="community:FollowGroup">
                                <TextBlock Text="{x:Bind Name}" />
                            </DataTemplate>
                        </muxc:NavigationViewItem.ContentTemplate>
                    </muxc:NavigationViewItem>
                </DataTemplate>
            </muxc:NavigationView.MenuItemTemplate>

        </muxc:NavigationView>

        <ScrollViewer
            x:Name="ContentScrollViewer"
            Grid.Row="2"
            Padding="{x:Bind CoreViewModel.PageHorizontalPadding, Converter={StaticResource HorizontalThicknessConverter}, Mode=OneWay}"
            HorizontalScrollMode="Disabled"
            VerticalScrollBarVisibility="Auto">
            <controls:VerticalRepeaterView
                Margin="0,0,0,12"
                HeaderVisibility="Collapsed"
                ItemsSource="{x:Bind ViewModel.Items}"
                MinWideItemHeight="220"
                MinWideItemWidth="180">
                <interactivity:Interaction.Behaviors>
                    <behaviors:IncrementalBehavior />
                </interactivity:Interaction.Behaviors>
                <controls:VerticalRepeaterView.ItemTemplate>
                    <DataTemplate x:DataType="account:IUserItemViewModel">
                        <user:UserItem ViewModel="{x:Bind}" />
                    </DataTemplate>
                </controls:VerticalRepeaterView.ItemTemplate>
            </controls:VerticalRepeaterView>
        </ScrollViewer>

        <Grid Grid.Row="2">
            <controls:OverlayLoadingPanel IsBarActive="False" IsRingActive="{x:Bind ViewModel.IsSwitching, Mode=OneWay}" />
            <controls:OverlayLoadingPanel IsBarActive="{x:Bind ViewModel.IsIncrementalLoading, Mode=OneWay}" IsRingActive="{x:Bind ViewModel.IsReloading, Mode=OneWay}" />
            <controls:ErrorPanel
                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 Text="{loc:Locale Name=NoFollows}" Visibility="{x:Bind ViewModel.IsCurrentGroupEmpty, Mode=OneWay}" />
        </Grid>
    </Grid>
</local:MyFollowsPageBase>
