Skip to content

Commit 7deeb34

Browse files
marcelwgnkarkarl
authored andcommitted
Fix settings icon not properly animating, minor refactor (#1313)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> Fixes #870 ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Screenshots (if appropriate): ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
1 parent 818ff6d commit 7deeb34

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

WinUIGallery/SettingsPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
</toolkit:SettingsExpander.Items>
101101
</toolkit:SettingsExpander>
102102

103-
<toolkit:SettingsExpander x:Name="ScreenshotCard" Header="Screenshot mode">
103+
<toolkit:SettingsExpander x:Name="ScreenshotCard" Header="Screenshot mode" Visibility="Collapsed">
104104
<toolkit:SettingsExpander.HeaderIcon>
105105
<FontIcon Glyph="&#xEC4F;" />
106106
</toolkit:SettingsExpander.HeaderIcon>

WinUIGallery/SettingsPage.xaml.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@ public string Version
3535
}
3636

3737
public string WinAppSdkRuntimeDetails => App.WinAppSdkRuntimeDetails;
38+
private int lastNavigationSelectionMode = 0;
3839

3940
public SettingsPage()
4041
{
4142
this.InitializeComponent();
4243
Loaded += OnSettingsPageLoaded;
43-
44-
if (ElementSoundPlayer.State == ElementSoundPlayerState.On)
45-
soundToggle.IsOn = true;
46-
if (ElementSoundPlayer.SpatialAudioMode == ElementSpatialAudioMode.On)
47-
spatialSoundBox.IsOn = true;
48-
49-
ScreenshotCard.Visibility = Visibility.Collapsed;
5044
}
5145

5246
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -81,7 +75,16 @@ private void OnSettingsPageLoaded(object sender, RoutedEventArgs e)
8175
{
8276
navigationLocation.SelectedIndex = 1;
8377
}
84-
}
78+
lastNavigationSelectionMode = navigationLocation.SelectedIndex;
79+
}
80+
81+
if (ElementSoundPlayer.State == ElementSoundPlayerState.On)
82+
soundToggle.IsOn = true;
83+
if (ElementSoundPlayer.SpatialAudioMode == ElementSpatialAudioMode.On)
84+
spatialSoundBox.IsOn = true;
85+
#if DEBUG
86+
ScreenshotCard.Visibility = Visibility.Visible;
87+
#endif
8588
}
8689

8790
private void themeMode_SelectionChanged(object sender, RoutedEventArgs e)
@@ -137,7 +140,13 @@ private void screenshotModeToggle_Toggled(object sender, RoutedEventArgs e)
137140

138141
private void navigationLocation_SelectionChanged(object sender, SelectionChangedEventArgs e)
139142
{
140-
NavigationOrientationHelper.IsLeftModeForElement(navigationLocation.SelectedIndex == 0, this);
143+
// Since setting the left mode does not look at the old setting we
144+
// need to check if this is an actual update
145+
if (navigationLocation.SelectedIndex != lastNavigationSelectionMode)
146+
{
147+
NavigationOrientationHelper.IsLeftModeForElement(navigationLocation.SelectedIndex == 0, this);
148+
lastNavigationSelectionMode = navigationLocation.SelectedIndex;
149+
}
141150
}
142151

143152
private async void FolderButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)