<Page
    x:Class="Microsoft.PowerToys.Settings.UI.Flyout.LaunchPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:animatedVisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
    xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
    xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:viewModels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
    mc:Ignorable="d">
    <Page.Resources>
        <Style
            x:Key="FlyoutButtonStyle"
            BasedOn="{StaticResource SubtleButtonStyle}"
            TargetType="Button">
            <Setter Property="Padding" Value="6" />
            <Setter Property="Width" Value="32" />
            <Setter Property="Height" Value="32" />
            <Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
        </Style>

        <tkconverters:StringVisibilityConverter x:Key="StringVisibilityConverter" />
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="48" />
        </Grid.RowDefinitions>
        <Grid
            Background="{ThemeResource LayerOnAcrylicFillColorDefaultBrush}"
            BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
            BorderThickness="0,0,0,1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Grid Padding="36,32,36,0">
                <TextBlock
                    x:Uid="QuickAccessTxt"
                    VerticalAlignment="Center"
                    Style="{StaticResource BodyStrongTextBlockStyle}" />
                <Button
                    x:Uid="MoreBtn"
                    Padding="8,4,8,4"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    Click="AllAppButton_Click">
                    <Button.Content>
                        <StackPanel
                            VerticalAlignment="Center"
                            Orientation="Horizontal"
                            Spacing="12">

                            <TextBlock x:Uid="MoreLabel" Style="{StaticResource CaptionTextBlockStyle}" />
                            <FontIcon
                                Margin="0,2,0,0"
                                FontSize="12"
                                Glyph="&#xe76c;" />
                        </StackPanel>
                    </Button.Content>
                </Button>
            </Grid>
            <Grid Grid.Row="1">
                <ItemsControl
                    Margin="12,26,12,24"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Top"
                    ItemsSource="{x:Bind ViewModel.FlyoutMenuItems}"
                    TabNavigation="Local">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <tkcontrols:WrapPanel HorizontalAlignment="Stretch" VerticalSpacing="12" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate x:DataType="viewModels:FlyoutMenuItem">
                            <controls:FlyoutMenuButton
                                AutomationProperties.Name="{x:Bind Label}"
                                Click="ModuleButton_Click"
                                Tag="{x:Bind Tag}"
                                Visibility="{x:Bind Visible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolToVisibilityConverter}}">
                                <controls:FlyoutMenuButton.Content>
                                    <TextBlock
                                        Style="{StaticResource CaptionTextBlockStyle}"
                                        Text="{x:Bind Label}"
                                        TextAlignment="Center"
                                        TextWrapping="Wrap" />
                                </controls:FlyoutMenuButton.Content>
                                <controls:FlyoutMenuButton.Icon>
                                    <Image>
                                        <Image.Source>
                                            <BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
                                        </Image.Source>
                                    </Image>
                                </controls:FlyoutMenuButton.Icon>
                                <ToolTipService.ToolTip>
                                    <ToolTip Content="{x:Bind ToolTip}" Visibility="{x:Bind ToolTip, Converter={StaticResource StringVisibilityConverter}}" />
                                </ToolTipService.ToolTip>
                            </controls:FlyoutMenuButton>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Grid>
        <Grid Grid.Row="2">
            <InfoBar
                x:Uid="UpdateAvailable"
                IsClosable="False"
                IsOpen="{x:Bind ViewModel.IsUpdateAvailable, Mode=OneWay}"
                Severity="Success" />

            <StackPanel
                Grid.Row="1"
                Margin="0,0,12,0"
                HorizontalAlignment="Right"
                Orientation="Horizontal"
                Spacing="8">
                <Button
                    x:Name="DocsBtn"
                    x:Uid="DocsBtn"
                    Click="DocsBtn_Click"
                    Content="{ui:FontIcon Glyph=&#xE8A5;,
                                          FontSize=16}"
                    Style="{StaticResource FlyoutButtonStyle}">
                    <ToolTipService.ToolTip>
                        <TextBlock x:Uid="DocsTooltip" />
                    </ToolTipService.ToolTip>
                </Button>
                <Button
                    x:Name="ReportBugBtn"
                    x:Uid="BugReportBtn"
                    Click="ReportBugBtn_Click"
                    Content="{ui:FontIcon Glyph=&#xebe8;,
                                          FontSize=16}"
                    Style="{StaticResource FlyoutButtonStyle}">
                    <ToolTipService.ToolTip>
                        <TextBlock x:Uid="BugReportTooltip" />
                    </ToolTipService.ToolTip>
                </Button>
                <Button
                    x:Name="SettingsBtn"
                    x:Uid="SettingsBtn"
                    Padding="8"
                    Click="SettingsBtn_Click"
                    Style="{StaticResource FlyoutButtonStyle}">
                    <ToolTipService.ToolTip>
                        <TextBlock x:Uid="SettingsTooltip" />
                    </ToolTipService.ToolTip>
                    <AnimatedIcon x:Name="SearchAnimatedIcon">
                        <AnimatedIcon.Source>
                            <animatedVisuals:AnimatedSettingsVisualSource />
                        </AnimatedIcon.Source>
                        <AnimatedIcon.FallbackIconSource>
                            <SymbolIconSource Symbol="Setting" />
                        </AnimatedIcon.FallbackIconSource>
                    </AnimatedIcon>
                </Button>
                <!--<AppBarSeparator />
                <Button
                    x:Name="QuitBtn"
                    Style="{StaticResource FlyoutButtonStyle}"
                    ToolTipService.ToolTip="Quit"
                    Click="QuitButton_Click">
                    <FontIcon FontSize="16" Glyph="&#xe894;" />
                </Button>-->
            </StackPanel>
        </Grid>
    </Grid>
</Page>
