Skip to content

Commit

Permalink
Clean up microsoft#5
Browse files Browse the repository at this point in the history
  • Loading branch information
Chips1234 committed May 2, 2021
1 parent 9df4d4d commit 04f67e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Calculator/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4722,9 +4722,9 @@
<value>Microsoft Privacy Statement</value>
<comment>Displayed on a link to the Microsoft Privacy Statement on the Settings page.</comment>
</data>
<data name="SettingsRestartNotice" xml:space="preserve">
<data name="SettingsRestartApp.Text" xml:space="preserve">
<value>You'll see your changes the next time you start the app.</value>
<comment>Notice when the user change the theme.</comment>
<comment>Notice prompting the user to restart the app for changes to theme to take effect.</comment>
</data>
<data name="BackButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Back</value>
Expand Down
1 change: 1 addition & 0 deletions src/Calculator/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@


<TextBlock x:Name="SettingsRestartApp"
x:Uid="SettingsRestartApp"
Style="{StaticResource CaptionTextBlockStyle}"
Foreground="{StaticResource SystemBaseMediumColor}"/>

Expand Down
21 changes: 6 additions & 15 deletions src/Calculator/SettingsPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -44,15 +43,15 @@ SettingsPage::SettingsPage()

if (themevalue != nullptr)
{
if (colorSetting == L"Light")
if (colorSetting == ApplicationTheme::Light.ToString())
{
SettingsLightTheme->IsChecked = true;
if (currentTheme == nullptr)
{
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)
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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());
}
Expand Down
6 changes: 6 additions & 0 deletions src/Calculator/SettingsPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 04f67e4

Please sign in to comment.