precheck details view and viewmodel WIP

This commit is contained in:
IsWaffle 2023-07-25 22:07:48 -04:00
parent 886770253a
commit eb4f8b006c
10 changed files with 177 additions and 22 deletions

View File

@ -1,4 +1,4 @@
<Application xmlns="https://github.com/avaloniaui"
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SPTInstaller"
x:Class="SPTInstaller.App">

View File

@ -184,4 +184,20 @@
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<!-- PreCheck Path Styles -->
<Style Selector="Path.passed">
<Setter Property="Data" Value="{StaticResource CircledCheck}"/>
<Setter Property="Fill" Value="Green"/>
</Style>
<Style Selector="Path.failed">
<Setter Property="Data" Value="{StaticResource CircledX}"/>
<Setter Property="Fill" Value="Red"/>
</Style>
<Style Selector="Path.warning">
<Setter Property="Data" Value="{StaticResource CircledWarn}"/>
<Setter Property="Fill" Value="Goldenrod"/>
</Style>
</Styles>

View File

@ -0,0 +1,75 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPTInstaller.CustomControls.DetailedPreCheckItem"
Background="Transparent" MinHeight="100">
<UserControl.Styles>
<Style Selector="Arc.running">
<Setter Property="Stroke" Value="DodgerBlue"/>
</Style>
<Style Selector="Arc">
<Setter Property="Stroke" Value="Gray"/>
<Setter Property="IsVisible" Value="{Binding IsPending, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<Style.Animations>
<Animation Duration="0:0:1" RepeatCount="infinite">
<KeyFrame Cue="0%">
<Setter Property="RotateTransform.Angle" Value="0"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="RotateTransform.Angle" Value="360"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</UserControl.Styles>
<Grid RowDefinitions="3,AUTO,3,*,3" ColumnDefinitions="3,*,3" Margin="10">
<Border Grid.RowSpan="5" Grid.ColumnSpan="3"
Background="{StaticResource AKI_Background_Light}" CornerRadius="8"
BoxShadow="3 3 10 .1 black"
/>
<Border Grid.RowSpan="3" Grid.ColumnSpan="3"
Background="{StaticResource AKI_Brush_DarkGrayBlue}" CornerRadius="8 8 0 0"
/>
<Grid Grid.Row="1" Grid.Column="1" ColumnDefinitions="22, AUTO" Margin="3">
<Canvas Margin="0 3 0 0"
IsVisible="{Binding !IsPending, RelativeSource={RelativeSource AncestorType=UserControl}}">
<Ellipse Fill="White" Height="15" Width="15" Canvas.Top="3" Canvas.Left="3"
/>
<Path Name="iconPath" StrokeThickness="2"
Classes.passed="{Binding Passed, RelativeSource={RelativeSource AncestorType=UserControl}}"
>
<Classes.failed>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="IsRequired"/>
<Binding Path="!Passed"/>
</MultiBinding>
</Classes.failed>
<Classes.warning>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="!IsRequired"/>
<Binding Path="!Passed"/>
</MultiBinding>
</Classes.warning>
</Path>
</Canvas>
<Arc StartAngle="280" SweepAngle="80" Margin="0 3 0 0" StrokeThickness="3"
Width="20" Height="20" VerticalAlignment="Top"
Classes.running="{Binding IsRunning, RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
<Label Grid.Column="1"
Content="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}}"
Classes.bold="{Binding IsRunning, RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
</Grid>
<Label Grid.Row="3" Grid.Column="1"
Content="{Binding PreCheckDetails, RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
</Grid>
</UserControl>

View File

@ -0,0 +1,19 @@
using Avalonia;
namespace SPTInstaller.CustomControls;
public partial class DetailedPreCheckItem : PreCheckItem
{
public DetailedPreCheckItem()
{
InitializeComponent();
}
public string PreCheckDetails
{
get => GetValue(PreCheckDetailsProperty);
set => SetValue(PreCheckDetailsProperty, value);
}
public static readonly StyledProperty<string> PreCheckDetailsProperty =
AvaloniaProperty.Register<DetailedPreCheckItem, string>(nameof(PreCheckDetails));
}

View File

@ -1,4 +1,4 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -6,7 +6,6 @@
x:Class="SPTInstaller.CustomControls.PreCheckItem">
<UserControl.Styles>
<Style Selector="Arc.running">
<Setter Property="Stroke" Value="DodgerBlue"/>
</Style>
@ -29,23 +28,6 @@
<Style Selector="Label.bold">
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style Selector="Path.passed">
<Setter Property="Data" Value="{StaticResource CircledCheck}"/>
<Setter Property="Fill" Value="Green"/>
</Style>
<Style Selector="Path.failed">
<Setter Property="Data" Value="{StaticResource CircledX}"/>
<Setter Property="Fill" Value="Red"/>
<Setter Property="ToolTip.Tip" Value="A required dependency could not be found"/>
</Style>
<Style Selector="Path.warning">
<Setter Property="Data" Value="{StaticResource CircledWarn}"/>
<Setter Property="Fill" Value="Goldenrod"/>
<Setter Property="ToolTip.Tip" Value="This dependency could not be found"/>
</Style>
</UserControl.Styles>

View File

@ -0,0 +1,9 @@
using ReactiveUI;
namespace SPTInstaller.ViewModels;
public class DetailedPreChecksViewModel : PreChecksViewModel
{
public DetailedPreChecksViewModel(IScreen host) : base(host)
{
}
}

View File

@ -15,6 +15,8 @@ public class PreChecksViewModel : ViewModelBase
public ObservableCollection<PreCheckBase> PreChecks { get; set; } = new(ServiceHelper.GetAll<PreCheckBase>());
public ICommand StartInstallCommand { get; set; }
public ICommand ShowDetailedViewCommand { get; set; }
public string InstallPath
{
get => _installPath;
@ -43,6 +45,7 @@ public class PreChecksViewModel : ViewModelBase
InstallPath = data.TargetInstallPath;
StartInstallCommand = ReactiveCommand.Create(() => NavigateTo(new InstallViewModel(HostScreen)));
ShowDetailedViewCommand = ReactiveCommand.Create(() => NavigateTo(new DetailedPreChecksViewModel(HostScreen)));
Task.Run(async () =>
{

View File

@ -0,0 +1,36 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cc="using:SPTInstaller.CustomControls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPTInstaller.Views.DetailedPreChecksView">
<Grid RowDefinitions="10,AUTO,AUTO,AUTO,10">
<Label Grid.Row="1" HorizontalAlignment="Center"
Content="Placeholder for install location info because I'm lazy"
/>
<Separator Grid.Row="2" Margin="10 5" Height="2"/>
<ScrollViewer Grid.Row="3">
<ItemsControl Items="{Binding PreChecks}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Stretch" Spacing="10" Margin="10"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<cc:DetailedPreCheckItem PreCheckName="{Binding Name}"
IsRunning="{Binding IsRunning}"
IsPending="{Binding IsPending}"
IsRequired="{Binding IsRequired}"
Passed="{Binding Passed}"
PreCheckDetails="Placeholder for details"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

View File

@ -0,0 +1,11 @@
using Avalonia.ReactiveUI;
using SPTInstaller.ViewModels;
namespace SPTInstaller.Views;
public partial class DetailedPreChecksView : ReactiveUserControl<DetailedPreChecksViewModel>
{
public DetailedPreChecksView()
{
InitializeComponent();
}
}

View File

@ -1,4 +1,4 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -6,7 +6,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPTInstaller.Views.PreChecksView">
<Grid ColumnDefinitions="10,*,AUTO,*,10"
RowDefinitions="10,*,AUTO,AUTO,AUTO,*,10">
RowDefinitions="10,*,AUTO,AUTO,AUTO,AUTO,*,10">
<StackPanel Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="2" HorizontalAlignment="Center">
<Label Content="SPT will be installed into this folder:"
HorizontalAlignment="Center"
@ -44,5 +44,9 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" HorizontalAlignment="Center"
Content="Detailed View"
Command="{Binding ShowDetailedViewCommand}"
/>
</Grid>
</UserControl>