<?xml version="1.0" encoding="utf-8" ?>
<local:HeaderAccountControlBase
    x:Class="BiliCopilot.UI.Controls.Components.HeaderAccountControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    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.Controls.Components"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <ProgressRing
            x:Name="LoadingRing"
            Width="20"
            Height="20"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            IsActive="{x:Bind ViewModel.IsInitializing, Mode=OneWay}" />
        <Button Style="{StaticResource AvatarButtonStyle}">
            <PersonPicture
                Width="28"
                Height="28"
                DisplayName="{x:Bind ViewModel.MyProfile.User.Name, Mode=OneWay}"
                ProfilePicture="{x:Bind ViewModel.MyProfile.User.Avatar.Uri, Mode=OneWay, Converter={StaticResource BitmapConverter}}"
                Visibility="{x:Bind ViewModel.MyProfile, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}" />
            <Button.Flyout>
                <MenuFlyout
                    Opened="OnFlyoutOpened"
                    Placement="BottomEdgeAlignedRight"
                    ShouldConstrainToRootBounds="False">
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate>
                                <local:AccountCard Width="300" />
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                    <MenuFlyoutSeparator />
                    <MenuFlyoutItem
                        Command="{x:Bind ViewModel.ShowMomentsCommand}"
                        KeyboardAcceleratorTextOverride="{x:Bind ViewModel.MomentCount, Mode=OneWay, Converter={StaticResource CountConverter}}"
                        Text="{ext:Locale Name=MyDynamic}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="DesignIdeas" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem
                        Command="{x:Bind ViewModel.ShowFollowsCommand}"
                        KeyboardAcceleratorTextOverride="{x:Bind ViewModel.FollowCount, Mode=OneWay, Converter={StaticResource CountConverter}}"
                        Text="{ext:Locale Name=MyFollow}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="PeopleEye" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem
                        Command="{x:Bind ViewModel.ShowFansCommand}"
                        KeyboardAcceleratorTextOverride="{x:Bind ViewModel.FansCount, Mode=OneWay, Converter={StaticResource CountConverter}}"
                        Text="{ext:Locale Name=MyFans}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="PeopleCommunity" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutSeparator />
                    <MenuFlyoutItem Command="{x:Bind ViewModel.OpenPersonalWebsiteCommand}" Text="{ext:Locale Name=Personal}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="Person" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem Command="{x:Bind ViewModel.ShowFavoritesCommand}" Text="{ext:Locale Name=MyFavorite}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="StarLineHorizontal3" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem Command="{x:Bind ViewModel.ShowViewLaterCommand}" Text="{ext:Locale Name=ViewLater}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="CalendarClock" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem Command="{x:Bind ViewModel.ShowHistoryCommand}" Text="{ext:Locale Name=ViewHistory}">
                        <MenuFlyoutItem.Icon>
                            <ic:SymbolIcon Symbol="History" />
                        </MenuFlyoutItem.Icon>
                    </MenuFlyoutItem>
                </MenuFlyout>
            </Button.Flyout>
        </Button>
    </Grid>
</local:HeaderAccountControlBase>
