-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ThemeListener Refactor & Disposal #4361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| using Microsoft.Toolkit.Uwp.UI.Helpers; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
| using Windows.UI.Xaml.Navigation; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
| { | ||
|
|
@@ -16,9 +17,7 @@ public sealed partial class ThemeListenerPage : Page | |
| public ThemeListenerPage() | ||
| { | ||
| this.InitializeComponent(); | ||
| Listener = new ThemeListener(); | ||
| this.Loaded += ThemeListenerPage_Loaded; | ||
| Listener.ThemeChanged += Listener_ThemeChanged; | ||
| SampleController.Current.ThemeChanged += Current_ThemeChanged; | ||
| } | ||
|
|
||
|
|
@@ -32,17 +31,16 @@ private void ThemeListenerPage_Loaded(object sender, RoutedEventArgs e) | |
| UpdateThemeState(); | ||
| } | ||
|
|
||
| private void Listener_ThemeChanged(ThemeListener sender) | ||
| { | ||
| UpdateThemeState(); | ||
| } | ||
|
|
||
| private void UpdateThemeState() | ||
| { | ||
| SystemTheme.Text = Listener.CurrentThemeName; | ||
| SystemTheme.Text = SampleController.Current.ThemeListener.CurrentThemeName; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a SystemTheme method as well: WindowsCommunityToolkit/Microsoft.Toolkit.Uwp.SampleApp/Pages/SampleController.xaml.cs Line 74 in bdd1d84
public ApplicationTheme SystemTheme()
(Not sure why this isn't prefixed with 'Get' like CurrentTheme is, probably something else we should clean-up.)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed |
||
| CurrentTheme.Text = SampleController.Current.GetCurrentTheme().ToString(); | ||
| } | ||
|
|
||
| public ThemeListener Listener { get; } | ||
| protected async override void OnNavigatedFrom(NavigationEventArgs e) | ||
| { | ||
| Loaded -= ThemeListenerPage_Loaded; | ||
| SampleController.Current.ThemeChanged -= Current_ThemeChanged; | ||
| } | ||
| } | ||
| } | ||