<ContentDialog
    x:Class="Nickvision.Parabolic.WinUI.Views.KeyringDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:community="using:CommunityToolkit.WinUI.Controls"
    xmlns:parabolic="using:Nickvision.Parabolic.WinUI.Helpers"
    xmlns:nickvision="using:Nickvision.Desktop.WinUI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Style="{StaticResource DefaultContentDialogStyle}"
    DefaultButton="Primary" Loaded="Dialog_Loaded">
    <Grid ColumnSpacing="24">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <AutoSuggestBox x:Name="SearchBox" Grid.Row="0" QueryIcon="Find" TextChanged="SearchBox_TextChanged"/>

        <CommandBar Grid.Row="1" DefaultLabelPosition="Right" OverflowButtonVisibility="Collapsed">
            <AppBarButton x:Name="BtnAdd" Click="Add">
                <AppBarButton.Icon>
                    <FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE710;"/>
                </AppBarButton.Icon>
            </AppBarButton>
        </CommandBar>

        <ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
            <nickvision:ViewStack x:Name="ViewStack">
                <nickvision:ViewStack.Pages>
                    <nickvision:StatusPage x:Name="StatusNone" Margin="0,24,0,24" Glyph="&#xF540;" IsCompact="True"/>

                    <nickvision:StatusPage x:Name="StatusNoneSearch" Margin="0,24,0,24" Glyph="&#xE721;" IsCompact="True"/>

                    <ListView x:Name="ListCredentials" SelectionMode="None">
                        <ListView.ItemTemplate>
                            <DataTemplate x:DataType="parabolic:BindableCredentialSelectionItem">
                                <community:SettingsCard Margin="-12,0,-12,0" Width="500" Header="{x:Bind Label, Mode=OneWay}" Description="{x:Bind Value.Url, Mode=OneWay}">
                                    <StackPanel Orientation="Horizontal" Spacing="6">
                                        <Button Click="Edit" Tag="{x:Bind Value, Mode=OneWay}">
                                            <Button.Content>
                                                <FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE70F;" FontSize="18"/>
                                            </Button.Content>
                                        </Button>

                                        <Button Click="Remove" Tag="{x:Bind Value, Mode=OneWay}">
                                            <Button.Content>
                                                <FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE74D;" FontSize="18"/>
                                            </Button.Content>
                                        </Button>
                                    </StackPanel>
                                </community:SettingsCard>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </nickvision:ViewStack.Pages>
            </nickvision:ViewStack>
        </ScrollViewer>
    </Grid>
</ContentDialog>
