<Page x:Class="ModernFlyouts.Navigation.GeneralSettingsPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:ModernFlyouts" xmlns:ui="http://schemas.modernwpf.com/2019"
      xmlns:controls="clr-namespace:ModernFlyouts.Controls"
      xmlns:toolkit="http://schemas.modernwpf.com/toolkit"
      xmlns:utils="clr-namespace:ModernFlyouts.Utilities" xmlns:helpers="clr-namespace:ModernFlyouts.Helpers"
      xmlns:resx="clr-namespace:ModernFlyouts.Properties"
      mc:Ignorable="d"
      d:DesignHeight="450" d:DesignWidth="800" DataContext="{x:Static local:FlyoutHandler.Instance}">
    <controls:ScrollViewerEx VerticalScrollBarVisibility="Auto">
        <StackPanel Margin="20,10">
            <GroupBox Header="{x:Static resx:Strings.Settings_Behavior}">
                <ui:SimpleStackPanel Spacing="10">
                    <ui:ToggleSwitch Header="{x:Static resx:Strings.Settings_RunAtStartup}" IsOn="{Binding RunAtStartup}"
                                     OnContent="{x:Static resx:Strings.Settings_On}"
                                     OffContent="{x:Static resx:Strings.Settings_Off}" />
                    <ComboBox ItemsSource="{x:Static helpers:LocalizationHelper.SupportedLanguages}"
                              SelectedItem="{Binding Path=(helpers:LocalizationHelper.CurrentLanguage)}"
                              MinWidth="240">
                        <ui:ControlHelper.Header>
                            <ui:SimpleStackPanel Orientation="Horizontal" Spacing="4"
                                                 ToolTip="{x:Static resx:Strings.Settings_LanguageDescription}">
                                <TextBlock Text="{x:Static resx:Strings.Settings_Language}" />
                                <ui:FontIcon FontSize="14" Glyph="{x:Static utils:CommonGlyphs.Info}" />
                            </ui:SimpleStackPanel>
                        </ui:ControlHelper.Header>
                    </ComboBox>
                </ui:SimpleStackPanel>
            </GroupBox>

            <GroupBox Header="{x:Static resx:Strings.Settings_DefaultFlyout}">
                <ui:SimpleStackPanel Spacing="10">
                    <ui:RadioButtons x:Name="DefaultFlyoutSelector"
                        Header="{x:Static resx:Strings.Settings_DefaultFlyoutDescription}"
                        ItemTemplate="{StaticResource LocalizedEnumItemTemplate}"
                        ItemsSource="{toolkit:EnumValues Type=local:DefaultFlyout}"
                        SelectedItem="{Binding DefaultFlyout}" />
                    <ui:SimpleStackPanel x:Name="WarningPanel" Spacing="10"
                                         Visibility="{Binding ElementName=DefaultFlyoutSelector, Path=SelectedIndex,
                                            Converter={StaticResource IndexToVisibilityConverter}}">
                        <TextBlock Margin="0,5" Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}"
                                   TextWrapping="Wrap" Text="{x:Static resx:Strings.Settings_DefaultFlyoutWarningMessage}" />
                        <Button Content="{x:Static resx:Strings.ExitItemDescription}"
                                Command="{x:Static utils:CommonCommands.ExitAppCommand}" />
                    </ui:SimpleStackPanel>
                </ui:SimpleStackPanel>
            </GroupBox>

            <GroupBox Header="{x:Static resx:Strings.Settings_Additional}">
                <Button Style="{DynamicResource ButtonRevealStyle}"
                        Content="{x:Static resx:Strings.Settings_ResetToDefaults}"
                        Command="{x:Static utils:CommonCommands.ResetAppDataCommand}" />
            </GroupBox>
        </StackPanel>
    </controls:ScrollViewerEx>
</Page>
