<UserControl x:Class="UniGetUI.Avalonia.Views.Pages.HelpPage"
             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"
             xmlns:controls="using:UniGetUI.Avalonia.Views.Controls"
             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:HelpPageViewModel">

    <UserControl.Styles>
        <!-- Nav buttons: same as the toolbar's main action button (Button#MainToolbarButton) -->
        <Style Selector="Button.nav">
            <Setter Property="Background" Value="{DynamicResource SettingsCardBackground}"/>
            <Setter Property="BorderThickness" Value="1"/>
        </Style>
        <!-- Disabled: keep the card background (not the gray disabled brush), just fade it -->
        <Style Selector="Button.nav:disabled /template/ ContentPresenter">
            <Setter Property="Background" Value="{DynamicResource SettingsCardBackground}"/>
        </Style>
        <Style Selector="Button.nav:disabled">
            <Setter Property="Opacity" Value="0.5"/>
        </Style>
        <!-- Non-nav buttons: flat/transparent like the toolbar -->
        <Style Selector="Button.flat">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
        </Style>
    </UserControl.Styles>

    <Grid RowDefinitions="Auto,2,*" Margin="8,4,8,8">

        <!-- Toolbar -->
        <Grid Grid.Row="0" ColumnDefinitions="Auto,Auto,Auto,Auto,*,Auto" Margin="0,0,0,6">

            <Button Grid.Column="0"
                    x:Name="BackButton"
                    Classes="nav"
                    Width="35" Height="35" Padding="6"
                    CornerRadius="4,0,0,4"
                    automation:AutomationProperties.Name="{t:Translate Go back}"
                    Click="BackButton_Click">
                <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/backward.svg"
                                  Width="16" Height="16"/>
            </Button>

            <Button Grid.Column="1"
                    x:Name="ForwardButton"
                    Classes="nav"
                    Width="35" Height="35" Padding="6"
                    CornerRadius="0"
                    automation:AutomationProperties.Name="{t:Translate Go forward}"
                    Click="ForwardButton_Click">
                <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/forward.svg"
                                  Width="16" Height="16"/>
            </Button>

            <Button Grid.Column="2"
                    Classes="nav"
                    Width="35" Height="35" Padding="6"
                    CornerRadius="0"
                    automation:AutomationProperties.Name="{t:Translate Go to home page}"
                    Click="HomeButton_Click">
                <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/home.svg"
                                  Width="16" Height="16"/>
            </Button>

            <Button Grid.Column="3"
                    Classes="nav"
                    Width="35" Height="35" Padding="6"
                    CornerRadius="0,4,4,0"
                    automation:AutomationProperties.Name="{t:Translate Reload page}"
                    Click="ReloadButton_Click">
                <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/reload.svg"
                                  Width="16" Height="16"/>
            </Button>

            <Button Grid.Column="5"
                    Classes="flat"
                    Height="35"
                    Command="{Binding OpenInBrowserCommand}"
                    automation:AutomationProperties.Name="{t:Translate View page on browser}">
                <TextBlock Text="{t:Translate View page on browser}"
                           automation:AutomationProperties.AccessibilityView="Raw"/>
            </Button>

        </Grid>

        <!-- Progress bar shown while navigating -->
        <ProgressBar Grid.Row="1"
                     x:Name="NavProgressBar"
                     IsIndeterminate="{Binding IsVisible, RelativeSource={RelativeSource Self}}"
                     IsVisible="False"
                     Height="2"
                     CornerRadius="0"
                     automation:AutomationProperties.AccessibilityView="Raw"/>

        <!-- WebView -->
        <Border x:Name="WebViewBorder" Grid.Row="2" CornerRadius="6" ClipToBounds="True">
            <controls:UniGetUiWebView x:Name="WebViewControl"/>
        </Border>

        <!-- Linux fallback -->
        <StackPanel x:Name="LinuxFallbackPanel" Grid.Row="2"
                    HorizontalAlignment="Center" VerticalAlignment="Center"
                    Spacing="12" IsVisible="False">
            <TextBlock Text="{t:Translate The built-in browser is not supported on Linux yet.}"
                       TextAlignment="Center" TextWrapping="Wrap" MaxWidth="400"/>
            <Button Classes="flat" HorizontalAlignment="Center" Command="{Binding OpenInBrowserCommand}">
                <TextBlock Text="{t:Translate Open in browser}"
                           automation:AutomationProperties.AccessibilityView="Raw"/>
            </Button>
        </StackPanel>

    </Grid>
</UserControl>
