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

4
StabilityMatrix/InstallPage.xaml.cs

@ -18,9 +18,9 @@ namespace StabilityMatrix
DataContext = new InstallerViewModel(); 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:NavigationViewItem>
</ui:NavigationView.MenuItems> </ui:NavigationView.MenuItems>
<ui:NavigationView.FooterMenuItems> <ui:NavigationView.FooterMenuItems>
<ui:NavigationViewItem Content="Settings"> <ui:NavigationViewItem Content="Settings" TargetPageType="{x:Type local:SettingsPage}">
<ui:NavigationViewItem.Icon> <ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="Settings24" /> <ui:SymbolIcon Symbol="Settings24" />
</ui:NavigationViewItem.Icon> </ui:NavigationViewItem.Icon>

56
StabilityMatrix/SettingsPage.xaml

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

4
StabilityMatrix/ViewModels/InstallerViewModel.cs

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

21
StabilityMatrix/ViewModels/SettingsViewModel.cs

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

Loading…
Cancel
Save