<UserControl x:Class="UniGetUI.Avalonia.Views.Pages.SettingsPages.Updates"
             xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:automation="clr-namespace:Avalonia.Automation;assembly=Avalonia.Controls"
             xmlns:vm="using:UniGetUI.Avalonia.ViewModels.Pages.SettingsPages"
             xmlns:settings="using:UniGetUI.Avalonia.Views.Controls.Settings"
             xmlns:t="using:UniGetUI.Avalonia.MarkupExtensions"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:DataType="vm:UpdatesViewModel">

    <ScrollViewer HorizontalScrollBarVisibility="Disabled">
        <StackPanel Orientation="Vertical" Spacing="0">

            <settings:TranslatedTextBlock Text="Update checking"
                                          FontSize="14"
                                          FontWeight="SemiBold"
                                          Margin="44,32,4,8"
                                          automation:AutomationProperties.HeadingLevel="2"/>

            <settings:CheckboxCard x:Name="UpdatesCheckingCard"
                                   SettingName="DisableAutoCheckforUpdates"
                                   Text="{t:Translate Check for package updates periodically}"
                                   StateChangedCommand="{Binding UpdateAutoCheckEnabledCommand}"
                                   CornerRadius="8,8,0,0"/>

            <settings:ComboboxCard x:Name="UpdatesCheckIntervalSelector"
                                   SettingName="UpdatesCheckInterval"
                                   Text="{t:Translate Check for updates every:}"
                                   ValueChangedCommand="{Binding ShowRestartRequiredCommand}"
                                   BorderThickness="1,0"
                                   CornerRadius="0,0,8,8"
                                   IsEnabled="{Binding IsAutoCheckEnabled}"/>

            <settings:TranslatedTextBlock Text="Automatic updates"
                                          FontSize="14"
                                          FontWeight="SemiBold"
                                          Margin="44,32,4,8"
                                          automation:AutomationProperties.HeadingLevel="2"/>

            <settings:CheckboxCard x:Name="UpdatesAutomaticCard"
                                   SettingName="AutomaticallyUpdatePackages"
                                   Text="{t:Translate Install available updates automatically}"
                                   CornerRadius="8,8,0,0"
                                   IsEnabled="{Binding IsAutoCheckEnabled}"/>

            <settings:CheckboxCard x:Name="AUPMeteredCard"
                                   SettingName="DisableAUPOnMeteredConnections"
                                   ForceInversion="True"
                                   Text="{t:Translate Do not automatically install updates when the network connection is metered}"
                                   BorderThickness="1,0"
                                   CornerRadius="0"
                                   IsEnabled="{Binding IsAutoCheckEnabled}"/>

            <settings:CheckboxCard x:Name="AUPBatteryCard"
                                   SettingName="DisableAUPOnBattery"
                                   ForceInversion="True"
                                   Text="{t:Translate Do not automatically install updates when the device runs on battery}"
                                   BorderThickness="1,1,1,0"
                                   CornerRadius="0"
                                   IsEnabled="{Binding IsAutoCheckEnabled}"/>

            <settings:CheckboxCard x:Name="AUPBatterySaverCard"
                                   SettingName="DisableAUPOnBatterySaver"
                                   ForceInversion="True"
                                   Text="{t:Translate Do not automatically install updates when the battery saver is on}"
                                   CornerRadius="0,0,8,8"
                                   IsEnabled="{Binding IsAutoCheckEnabled}"/>

            <settings:TranslatedTextBlock Text="Update security"
                                          FontSize="14"
                                          FontWeight="SemiBold"
                                          Margin="44,32,4,8"
                                          automation:AutomationProperties.HeadingLevel="2"/>

            <settings:ComboboxCard x:Name="MinimumUpdateAgeSelector"
                                   SettingName="MinimumUpdateAge"
                                   Text="{t:Translate Minimum age for updates}"
                                   Description="{t:Translate Only show updates that are at least the specified number of days old}"
                                   CornerRadius="8,8,8,8"/>

            <settings:TextboxCard x:Name="MinimumUpdateAgeCustomInput"
                                  SettingName="MinimumUpdateAgeCustom"
                                  Text="{t:Translate Custom minimum age (days)}"
                                  Placeholder="{t:Translate e.g. 10}"
                                  IsNumericOnly="True"
                                  IsVisible="{Binding IsCustomAgeSelected}"
                                  BorderThickness="1,0,1,1"
                                  CornerRadius="0,0,8,8"/>

            <settings:CheckboxCard x:Name="InstallerHostWarningCard"
                                   SettingName="DisableInstallerHostChangeWarning"
                                   Text="{t:Translate Text='Warn me when the installer URL host changes between the installed version and the new version (WinGet only)'}"
                                   CornerRadius="8"
                                   Margin="0,8,0,0"/>

            <ContentControl x:Name="ReleaseDateCompatTableHolder"
                            Margin="0,8,0,0"/>

            <settings:TranslatedTextBlock Text="Related settings"
                                          FontSize="14"
                                          FontWeight="SemiBold"
                                          Margin="44,32,4,8"
                                          automation:AutomationProperties.HeadingLevel="2"/>

            <settings:SettingsCard BorderThickness="1,1,1,0"
                                   CornerRadius="8,8,0,0"
                                   IsClickEnabled="True"
                                   Command="{Binding NavigateToOperationsCommand}"
                                   Header="{t:Translate Package operation preferences}"
                                   Description="{t:Translate Text='Change how UniGetUI handles install, update and uninstall operations.'}"/>

            <settings:SettingsCard CornerRadius="0,0,8,8"
                                   IsClickEnabled="True"
                                   Command="{Binding NavigateToAdministratorCommand}"
                                   Header="{t:Translate Administrator rights and other dangerous settings}"
                                   Description="{t:Translate Text='Reduce UAC prompts, elevate installations by default, unlock certain dangerous features, etc.'}"/>

        </StackPanel>
    </ScrollViewer>

</UserControl>
