<!--  Copyright (c) Microsoft Corporation and Contributors.  -->
<!--  Licensed under the MIT License.  -->

<Page
    x:Class="Microsoft.PowerToys.Settings.UI.Flyout.AppsListPage"
    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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
    xmlns:viewmodels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
    mc:Ignorable="d">

    <Page.Resources>
        <tkconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
        <tkconverters:BoolToVisibilityConverter
            x:Key="BoolToInvertedVisibilityConverter"
            FalseValue="Visible"
            TrueValue="Collapsed" />
    </Page.Resources>
    <Grid Background="{ThemeResource LayerOnAcrylicFillColorDefaultBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Padding="24,32,24,0">
            <TextBlock
                x:Uid="AllAppsTxt"
                VerticalAlignment="Center"
                Style="{StaticResource BodyStrongTextBlockStyle}" />
            <Button
                x:Uid="BackBtn"
                Padding="8,4,8,4"
                HorizontalAlignment="Right"
                VerticalAlignment="Center"
                Click="BackButton_Click">
                <Button.Content>
                    <StackPanel
                        VerticalAlignment="Center"
                        Orientation="Horizontal"
                        Spacing="12">
                        <FontIcon
                            Margin="0,2,0,0"
                            FontSize="12"
                            Glyph="&#xe76b;" />
                        <TextBlock x:Uid="BackLabel" Style="{StaticResource CaptionTextBlockStyle}" />
                    </StackPanel>
                </Button.Content>
            </Button>
        </Grid>
        <ListView
            Grid.Row="1"
            Margin="0,16,0,0"
            ItemsSource="{x:Bind ViewModel.FlyoutMenuItems}"
            SelectionMode="None">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Padding="0,0,0,16" Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>

            <ListView.ItemTemplate>
                <DataTemplate x:DataType="viewmodels:FlyoutMenuItem">
                    <Grid Height="40" Padding="24,0,24,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <!--<ViewBox VerticalAlignment="Center">-->
                        <Image
                            Width="20"
                            Margin="0,0,16,0"
                            VerticalAlignment="Center">
                            <Image.Source>
                                <BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
                            </Image.Source>
                        </Image>
                        <!--</ViewBox>-->
                        <TextBlock
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            Text="{x:Bind Label, Mode=OneWay}"
                            TextTrimming="CharacterEllipsis" />
                        <FontIcon
                            Grid.Column="2"
                            Width="20"
                            VerticalAlignment="Center"
                            FontSize="16"
                            Glyph="&#xE72E;"
                            Visibility="{x:Bind IsLocked, Converter={StaticResource BoolToInvertedVisibilityConverter}, ConverterParameter=True, Mode=OneWay}">
                            <ToolTipService.ToolTip>
                                <TextBlock x:Uid="GPO_SettingIsManaged_ToolTip" TextWrapping="WrapWholeWords" />
                            </ToolTipService.ToolTip>
                        </FontIcon>
                        <ToggleSwitch
                            Grid.Column="3"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            AutomationProperties.Name="{x:Bind Label, Mode=OneWay}"
                            IsEnabled="{x:Bind IsLocked, Converter={StaticResource BoolNegationConverter}, ConverterParameter=True, Mode=OneWay}"
                            IsOn="{x:Bind IsEnabled, Mode=TwoWay}"
                            OffContent=""
                            OnContent=""
                            Style="{StaticResource RightAlignedCompactToggleSwitchStyle}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Page>
