[Settings] Fix for theming aware titles (#5245)

* Fix for theming aware titles

* Converter fix
This commit is contained in:
Niels Laute
2020-07-29 20:38:03 +02:00
committed by GitHub
parent d98d1193fc
commit d913285523
2 changed files with 34 additions and 7 deletions

View File

@@ -17,6 +17,13 @@
<ResourceDictionary Source="/Styles/Button.xaml"/>
</ResourceDictionary.MergedDictionaries>
<converters:ModuleEnabledToForegroundConverter x:Key="ModuleEnabledToForegroundConverter"/>
<SolidColorBrush x:Key="DarkForegroundDisabledBrush">#66FFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="DarkForegroundBrush">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="LightForegroundDisabledBrush">#66000000</SolidColorBrush>
<SolidColorBrush x:Key="LightForegroundBrush">#FF000000</SolidColorBrush>
</ResourceDictionary>
</Application.Resources>
</xaml:XamlApplication>

View File

@@ -1,7 +1,4 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Settings.UI.Lib;
using System;
using Windows.UI;
using Windows.UI.Xaml;
@@ -15,13 +12,36 @@ namespace Microsoft.PowerToys.Settings.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
bool isEnabled = (bool)value;
if (isEnabled)
GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
var defaultTheme = new Windows.UI.ViewManagement.UISettings();
var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString();
string selectedTheme = generalSettings.Theme.ToLower();
if (selectedTheme == "dark" || (selectedTheme == "system" && uiTheme == "#FF000000"))
{
return new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"]);
// DARK
if (isEnabled)
{
return (SolidColorBrush)Application.Current.Resources["DarkForegroundBrush"];
}
else
{
return (SolidColorBrush)Application.Current.Resources["DarkForegroundDisabledBrush"];
}
}
else
{
return (SolidColorBrush)Application.Current.Resources["SystemControlDisabledBaseMediumLowBrush"];
// LIGHT
if (isEnabled)
{
return (SolidColorBrush)Application.Current.Resources["LightForegroundBrush"];
}
else
{
return (SolidColorBrush)Application.Current.Resources["LightForegroundDisabledBrush"];
}
}
}