<ui:UiPage x:Class="Bloxstrap.UI.Elements.Settings.Pages.BloxstrapPage"
      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:ui="http://schemas.lepo.co/wpfui/2022/xaml"
      xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Settings.Pages"
      xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
      xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels.Settings"
      xmlns:resources="clr-namespace:Bloxstrap.Resources"
      d:DataContext="{d:DesignInstance Type=models:BloxstrapViewModel}"
      mc:Ignorable="d" 
      d:DesignHeight="600" d:DesignWidth="800"
      Title="BehaviourPage"
      Scrollable="True">

    <StackPanel Margin="0,0,14,14">
        <TextBlock Margin="0,0,0,8" Text="{x:Static resources:Strings.Menu_Bloxstrap_Description}" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

        <controls:OptionControl 
            Header="{x:Static resources:Strings.Menu_Behaviour_AutoUpdate_Title}"
            Description="{x:Static resources:Strings.Menu_Behaviour_AutoUpdate_Description}">
            <ui:ToggleSwitch IsChecked="{Binding UpdateCheckingEnabled, Mode=TwoWay}" />
        </controls:OptionControl>

        <controls:OptionControl 
            Header="{x:Static resources:Strings.Menu_Bloxstrap_Analytics_Title}"
            Description="{Binding Source={x:Static resources:Strings.Menu_Bloxstrap_Analytics_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/bloxstraplabs/bloxstrap/wiki/Privacy-Policy#analytical-functionality'}">
            <ui:ToggleSwitch IsChecked="{Binding AnalyticsEnabled, Mode=TwoWay}" />
        </controls:OptionControl>

        <ui:CardExpander Margin="0,8,0,0" IsExpanded="True">
            <ui:CardExpander.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0">
                        <TextBlock FontSize="14" Text="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_Title}" />
                        <TextBlock FontSize="12" Text="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_Description}" Foreground="{DynamicResource TextFillColorTertiaryBrush}" TextWrapping="Wrap" />
                    </StackPanel>
                    <ui:Button Grid.Column="1" MinWidth="100" Margin="0,0,16,0" Icon="CopySelect20" Content="{x:Static resources:Strings.Common_Export}" Command="{Binding ExportDataCommand}">
                        <ui:Button.Style>
                            <Style TargetType="ui:Button" BasedOn="{StaticResource {x:Type ui:Button}}">
                                <Style.Triggers>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding ElementName=ShouldExportConfig, Path=IsChecked}" Value="False" />
                                            <Condition Binding="{Binding ElementName=ShouldExportLogs, Path=IsChecked}" Value="False" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="IsEnabled" Value="False" />
                                    </MultiDataTrigger>
                                </Style.Triggers>
                                <Setter Property="IsEnabled" Value="True" />
                            </Style>
                        </ui:Button.Style>
                    </ui:Button>
                </Grid>
            </ui:CardExpander.Header>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <CheckBox Grid.Column="0" Name="ShouldExportConfig" Content="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_ExportConfig}" IsChecked="{Binding ShouldExportConfig}" />
                <CheckBox Grid.Column="1" Name="ShouldExportLogs" Content="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_ExportLogs}" IsChecked="{Binding ShouldExportLogs}" />
            </Grid>
        </ui:CardExpander>
    </StackPanel>
</ui:UiPage>
