Made LightSwitchPage Navigable

This commit is contained in:
Jaylyn Barbee
2025-11-10 13:09:05 -05:00
parent b01c81910e
commit c0bc4410a4
2 changed files with 32 additions and 31 deletions

View File

@@ -1,25 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page
<local:NavigablePage
x:Class="Microsoft.PowerToys.Settings.UI.Views.LightSwitchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ViewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Settings.UI.Library.Helpers"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
xmlns:ui="using:CommunityToolkit.WinUI"
d:DataContext="{d:DesignInstance Type=ViewModel:LightSwitchViewModel}"
xmlns:viewModels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
d:DataContext="{d:DesignInstance Type=viewModels:LightSwitchViewModel}"
AutomationProperties.LandmarkType="Main"
mc:Ignorable="d">
<Page.Resources>
<local:NavigablePage.Resources>
<converters:TimeSpanToFriendlyTimeConverter x:Key="TimeSpanToFriendlyTimeConverter" />
<converters:StringToDoubleConverter x:Key="StringToDoubleConverter" />
</Page.Resources>
</local:NavigablePage.Resources>
<Grid>
<controls:SettingsPageControl
x:Uid="LightSwitch"
@@ -364,4 +362,4 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>
</local:NavigablePage>

View File

@@ -18,20 +18,18 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using PowerToys.GPOWrapper;
using Settings.UI.Library;
using Settings.UI.Library.Helpers;
using Windows.Devices.Geolocation;
using Windows.Services.Maps;
namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class LightSwitchPage : Page
public sealed partial class LightSwitchPage : NavigablePage, IRefreshablePage
{
private readonly string _appName = "LightSwitch";
private readonly SettingsUtils _settingsUtils;
private readonly Func<string, int> _sendConfigMsg = ShellPage.SendDefaultIPCMessage;
private readonly ISettingsRepository<GeneralSettings> _generalSettingsRepository;
private readonly ISettingsRepository<LightSwitchSettings> _moduleSettingsRepository;
private readonly SettingsRepository<GeneralSettings> _generalSettingsRepository;
private readonly SettingsRepository<LightSwitchSettings> _moduleSettingsRepository;
private readonly IFileSystem _fileSystem;
private readonly IFileSystemWatcher _fileSystemWatcher;
@@ -55,7 +53,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
var darkSettings = _moduleSettingsRepository.SettingsConfig;
// Pass them into the ViewModel
ViewModel = new LightSwitchViewModel(darkSettings, ShellPage.SendDefaultIPCMessage);
ViewModel = new LightSwitchViewModel(darkSettings, _sendConfigMsg);
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
LoadSettings(_generalSettingsRepository, _moduleSettingsRepository);
@@ -74,9 +72,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
_fileSystemWatcher.Changed += Settings_Changed;
_fileSystemWatcher.EnableRaisingEvents = true;
this.InitializeComponent();
this.Loaded += LightSwitchPage_Loaded;
this.Loaded += (s, e) => ViewModel.OnPageLoaded();
InitializeComponent();
Loaded += LightSwitchPage_Loaded;
Loaded += (s, e) => ViewModel.OnPageLoaded();
}
public void RefreshEnabledState()
{
ViewModel.RefreshEnabledState();
}
private void LightSwitchPage_Loaded(object sender, RoutedEventArgs e)
@@ -369,7 +372,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
}
private void CityAutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
/* private void CityAutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
if (args.SelectedItem is SearchLocation location)
{
@@ -379,7 +382,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
LocationDialog.IsPrimaryButtonEnabled = true;
LocationResultPanel.Visibility = Visibility.Visible;
}
}
} */
private void ModeSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{