diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index 2ae80701..74393ce1 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -4722,9 +4722,9 @@ Microsoft Privacy Statement Displayed on a link to the Microsoft Privacy Statement on the Settings page. - + You'll see your changes the next time you start the app. - Notice when the user change the theme. + Notice prompting the user to restart the app for changes to theme to take effect. Back diff --git a/src/Calculator/SettingsPage.xaml b/src/Calculator/SettingsPage.xaml index 58ce9e0f..122c2b5b 100644 --- a/src/Calculator/SettingsPage.xaml +++ b/src/Calculator/SettingsPage.xaml @@ -82,6 +82,7 @@ diff --git a/src/Calculator/SettingsPage.xaml.cpp b/src/Calculator/SettingsPage.xaml.cpp index 72708113..5feac3ed 100644 --- a/src/Calculator/SettingsPage.xaml.cpp +++ b/src/Calculator/SettingsPage.xaml.cpp @@ -27,7 +27,6 @@ using namespace winrt::Windows::Storage; SettingsPage::SettingsPage() { - auto resourceLoader = AppResourceProvider::GetInstance(); auto themevalue = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"themeSetting"); auto restartValue = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"restartApp"); auto currentThemeValue = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"CurrentTheme"); @@ -44,7 +43,7 @@ SettingsPage::SettingsPage() if (themevalue != nullptr) { - if (colorSetting == L"Light") + if (colorSetting == ApplicationTheme::Light.ToString()) { SettingsLightTheme->IsChecked = true; if (currentTheme == nullptr) @@ -52,7 +51,7 @@ SettingsPage::SettingsPage() Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"CurrentTheme", L"Light"); } } - else if (colorSetting == L"Dark") + else if (colorSetting == ApplicationTheme::Dark.ToString()) { SettingsDarkTheme->IsChecked = true; if (currentTheme == nullptr) @@ -131,15 +130,6 @@ void SettingsPage::InitializeContributeTextBlock() void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) { auto rootFrame = dynamic_cast<::Frame ^>(Window::Current->Content); - - if (SettingsRestartApp->Visibility == ::Visibility::Visible) - { - Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"True"); - } - else - { - Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"False"); - } rootFrame->Navigate((MainPage::typeid), this); } @@ -186,18 +176,19 @@ void SettingsPage::ThemeChecked(Platform::Object ^ sender, Windows::UI::Xaml::Ro if (currentTheme == tag) { SettingsRestartApp->Visibility = ::Visibility::Collapsed; + Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"False"); } else { SettingsRestartApp->Visibility = ::Visibility::Visible; - SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice"); + Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"True"); } - if (tag == "Light") + if (tag == ApplicationTheme::Light.ToString()) { Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Light.ToString()); } - else if (tag == "Dark") + else if (tag == ApplicationTheme::Dark.ToString()) { Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Dark.ToString()); } diff --git a/src/Calculator/SettingsPage.xaml.h b/src/Calculator/SettingsPage.xaml.h index 9ae0e0f4..b1019d3a 100644 --- a/src/Calculator/SettingsPage.xaml.h +++ b/src/Calculator/SettingsPage.xaml.h @@ -16,6 +16,12 @@ namespace CalculatorApp property MainPage ^ MainPageProperty; private: + enum Theme + { + Light, + Dark, + System + }; void SetDefaultFocus(); void InitializeContributeTextBlock(); void BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);