<ui:ContentDialog
    CloseButtonText="Close"
    Loaded="OneClickInstallDialog_OnLoaded"
    Title="Stable Diffusion WebUI Installer"
    d:DataContext="{d:DesignInstance Type=viewModels:OneClickInstallViewModel,
                                     IsDesignTimeCreatable=True}"
    d:DesignHeight="512"
    d:DesignWidth="640"
    mc:Ignorable="d"
    ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
    ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
    x:Class="StabilityMatrix.OneClickInstallDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:StabilityMatrix"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
    xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:StabilityMatrix.Controls">

    <ui:ContentDialog.Resources>
        <!--  ReSharper disable once Xaml.StaticResourceNotResolved  -->
        <Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:OneClickInstallDialog}" />
        <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
    </ui:ContentDialog.Resources>

    <Grid MaxHeight="900" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="1*" />
            <RowDefinition Height="0.25*" />
        </Grid.RowDefinitions>
        <TextBlock Text="{Binding HeaderText, FallbackValue=Installing Stable Diffusion WebUI...}"
                   TextWrapping="Wrap"
                   VerticalAlignment="Top" HorizontalAlignment="Center"
                   FontSize="36" FontWeight="Light" Margin="8" />
        <TextBlock Grid.Row="1"
                   Text="{Binding SubHeaderText, FallbackValue=Installing git...}"
                   TextWrapping="Wrap" TextAlignment="Center"
                   VerticalAlignment="Top" HorizontalAlignment="Center"
                   FontSize="16" FontWeight="Light" Margin="8"/>
        
        <TextBlock Grid.Row="2"
                   Text="{Binding SubSubHeaderText, FallbackValue=Installing git...}"
                   TextWrapping="Wrap" TextAlignment="Center"
                   VerticalAlignment="Top" HorizontalAlignment="Center"
                   FontSize="10" Margin="8"/>

        <StackPanel Grid.Row="3" VerticalAlignment="Center">
            <ProgressBar Maximum="100" 
                         controls:ProgressBarSmoother.SmoothValue="{Binding OneClickInstallProgress}"
                         Visibility="{Binding ProgressBarVisibility}"
                         IsIndeterminate="{Binding IsIndeterminate}"
                         Margin="16" />
            <ui:Button
                Visibility="{Binding ShowInstallButton, Converter={StaticResource BoolToVisConverter}}"
                Content="Install"
                Command="{Binding InstallCommand}"
                FontSize="32"
                HorizontalAlignment="Center"
                Appearance="Success"
                Margin="16"
                Padding="16, 8, 16, 8" />
        </StackPanel>

        <ui:Button Grid.Row="4"
                Appearance="Transparent"
                Visibility="{Binding ShowInstallButton, Converter={StaticResource BoolToVisConverter}}"
                Command="{Binding ToggleAdvancedModeCommand}"
                Content="Skip first-time setup"
                FontSize="14"
                HorizontalAlignment="Center"
                Margin="16"
                VerticalAlignment="Bottom" />
    </Grid>

</ui:ContentDialog>
