Browse Source

Fix settings page & some async testing

pull/5/head
JT 2 years ago
parent
commit
d5f1caa3cb
  1. 5
      StabilityMatrix/InstallPage.xaml
  2. 4
      StabilityMatrix/InstallPage.xaml.cs
  3. 2
      StabilityMatrix/MainWindow.xaml
  4. 60
      StabilityMatrix/SettingsPage.xaml
  5. 4
      StabilityMatrix/ViewModels/InstallerViewModel.cs
  6. 21
      StabilityMatrix/ViewModels/SettingsViewModel.cs

5
StabilityMatrix/InstallPage.xaml

@ -10,7 +10,9 @@
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
d:DesignHeight="700"
d:DesignWidth="1100"
ui:Design.Background="#202020"
Loaded="InstallPage_OnLoaded"
Background="{DynamicResource ApplicationBackgroundBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
<Page.DataContext>
@ -21,7 +23,6 @@
<StackPanel Orientation="Horizontal" Margin="16" HorizontalAlignment="Left" Height="400">
<ListView
ItemsSource="{Binding Packages}"
SelectedIndex="0"
SelectedItem="{Binding SelectedPackage, Mode=TwoWay}">
<ListView.ItemTemplate>

4
StabilityMatrix/InstallPage.xaml.cs

@ -18,9 +18,9 @@ namespace StabilityMatrix
DataContext = new InstallerViewModel();
}
private void InstallPage_OnLoaded(object sender, RoutedEventArgs e)
private async void InstallPage_OnLoaded(object sender, RoutedEventArgs e)
{
((InstallerViewModel) DataContext).OnLoaded();
await ((InstallerViewModel) DataContext).OnLoaded();
}
}
}

2
StabilityMatrix/MainWindow.xaml

@ -46,7 +46,7 @@
</ui:NavigationViewItem>
</ui:NavigationView.MenuItems>
<ui:NavigationView.FooterMenuItems>
<ui:NavigationViewItem Content="Settings">
<ui:NavigationViewItem Content="Settings" TargetPageType="{x:Type local:SettingsPage}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="Settings24" />
</ui:NavigationViewItem.Icon>

60
StabilityMatrix/SettingsPage.xaml

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="StabilityMatrix.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@ -7,24 +8,51 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:models="using:StabilityMatrix.Models"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
d:DesignHeight="700"
d:DesignWidth="1100"
Background="{DynamicResource ApplicationBackgroundBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
<Page.DataContext>
<viewModels:SettingsViewModel/>
<viewModels:SettingsViewModel />
</Page.DataContext>
<Grid>
<StackPanel Orientation="Vertical">
<ui:Card Margin="8,16,8,8">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
<TextBlock Text="Theme" FontWeight="Bold" FontSize="16" Margin="0,8" />
<ComboBox
Margin="8"
ItemsSource="{Binding AvailableThemes}"
SelectedItem="{Binding SelectedTheme, Mode=TwoWay}"
Width="500" />
</StackPanel>
</ui:Card>
<ui:Card Margin="8">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
<TextBlock Text="Some Other Setting" FontWeight="Bold" FontSize="16" Margin="0,8" />
<ComboBox
Margin="8"
ItemsSource="{Binding AvailableThemes}"
SelectedItem="{Binding SelectedTheme, Mode=TwoWay}"
Width="500" />
</StackPanel>
</ui:Card>
<ScrollViewer Margin="20">
<!-- TODO: Fix this with new UI Framework -->
<!-- <StackPanel Spacing="3"> -->
<!-- <labs:SettingsCard x:Name="SettingsCard" -->
<!-- Header="Choose UI Theme"> -->
<!-- <ComboBox -->
<!-- ItemsSource="{Binding AvailableThemes}" -->
<!-- SelectedItem="{Binding SelectedTheme, Mode=TwoWay}" -->
<!-- Header="Theme" Width="200"/> -->
<!-- </labs:SettingsCard> -->
<!-- </StackPanel> -->
</ScrollViewer>
<ui:Card Margin="8">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
<TextBlock Text="Some Other Other Setting" FontWeight="Bold" FontSize="16" Margin="0,8" />
<ComboBox
Margin="8"
ItemsSource="{Binding AvailableThemes}"
SelectedItem="{Binding SelectedTheme, Mode=TwoWay}"
Width="500" />
</StackPanel>
</ui:Card>
</StackPanel>
</Grid>
</Page>

4
StabilityMatrix/ViewModels/InstallerViewModel.cs

@ -25,9 +25,10 @@ internal class InstallerViewModel : INotifyPropertyChanged
ProgressValue = 0;
}
public void OnLoaded()
public Task OnLoaded()
{
SelectedPackage = Packages.First();
return Task.CompletedTask;
}
public static ObservableCollection<BasePackage> Packages => new()
@ -75,7 +76,6 @@ internal class InstallerViewModel : INotifyPropertyChanged
get => selectedPackage;
set
{
if (Equals(value, selectedPackage)) return;
selectedPackage = value;
OnPropertyChanged();
}

21
StabilityMatrix/ViewModels/SettingsViewModel.cs

@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Wpf.Ui.Appearance;
namespace StabilityMatrix.ViewModels;
@ -23,17 +24,15 @@ internal class SettingsViewModel : INotifyPropertyChanged
selectedTheme = value;
OnPropertyChanged();
// TODO: redo for new UI Framework
// Update theme
// switch (selectedTheme)
// {
// case "Light":
// Application.Current.RequestedTheme = ApplicationTheme.Light;
// break;
// case "Dark":
// Application.Current.RequestedTheme = ApplicationTheme.Dark;
// break;
// }
switch (selectedTheme)
{
case "Light":
Theme.Apply(ThemeType.Light);
break;
case "Dark":
Theme.Apply(ThemeType.Dark);
break;
}
}
}

Loading…
Cancel
Save