Skip to content

Commit

Permalink
feat: AccessibilitySettings class
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jun 27, 2021
1 parent 826da94 commit 99726d5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.ViewManagement
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class AccessibilitySettings
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool HighContrast
{
Expand All @@ -17,7 +17,7 @@ public bool HighContrast
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string HighContrastScheme
{
Expand All @@ -27,7 +27,7 @@ public string HighContrastScheme
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public AccessibilitySettings()
{
Expand Down
37 changes: 37 additions & 0 deletions src/Uno.UWP/UI/ViewManagement/AccessibilitySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Uno;

namespace Windows.UI.ViewManagement
{
/// <summary>
/// Provides access to the high contrast accessibility settings.
/// </summary>
public partial class AccessibilitySettings
{
/// <summary>
/// Initializes a new AccessibilitySettings object.
/// </summary>
public AccessibilitySettings()
{
}

/// <summary>
/// Gets a value that indicates whether the system high contrast feature is on or off.
/// </summary>
/// <remarks>
/// In Uno Platform this returns the value of <see cref="WinRTFeatureConfiguration.Accessibility.HighContrast"/>.
/// The default is false.
/// </remarks>
[NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool HighContrast => WinRTFeatureConfiguration.Accessibility.HighContrast;

/// <summary>
/// Gets the name of the default high contrast color scheme.
/// </summary>
/// <remarks>
/// In Uno Platform this returns the value of <see cref="WinRTFeatureConfiguration.Accessibility.HighContrastScheme"/>.
/// The default is "High Contrast Black".
/// </remarks>
[NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string HighContrastScheme => WinRTFeatureConfiguration.Accessibility.HighContrastScheme;
}
}
12 changes: 6 additions & 6 deletions src/Uno.UWP/UI/ViewManagement/UISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace Windows.UI.ViewManagement
/// </summary>
/// <remarks>Events on this class are fired as long as the instance is alive.
/// To ensure the class does not get garbage collected, keep a strong reference to it.</remarks>
public partial class UISettings
{
public partial class UISettings
{
private static readonly ConcurrentDictionary<WeakReference<UISettings>, object> _instances = new ConcurrentDictionary<WeakReference<UISettings>, object>();
private readonly WeakReference<UISettings> _weakReference;

public UISettings()
{
{
_weakReference = new WeakReference<UISettings>(this);
_instances.TryAdd(_weakReference, null);
}
Expand All @@ -30,7 +30,7 @@ public UISettings()
}

internal static void OnColorValuesChanged()
{
{
foreach (var instance in _instances)
{
var weakReference = instance.Key;
Expand Down Expand Up @@ -207,11 +207,11 @@ public bool AdvancedEffectsEnabled
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.ViewManagement.UISettings", "UIElementColor");
return Colors.Black;
}
}

#pragma warning disable 67
[global::Uno.NotImplemented]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.ViewManagement.UISettings, object> TextScaleFactorChanged;
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.ViewManagement.UISettings, object> TextScaleFactorChanged;

[global::Uno.NotImplemented]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.ViewManagement.UISettings, object> AdvancedEffectsEnabledChanged;
Expand Down
18 changes: 18 additions & 0 deletions src/Uno.UWP/WinRTFeatureConfiguration.Accessibility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Uno
{
partial class WinRTFeatureConfiguration
{
public static class Accessibility
{
/// <summary>
/// Allows overriding the value returned by <see cref="Windows.UI.ViewManagement.AccessibilitySettings.HighContrast"/>.
/// </summary>
public static bool HighContrast { get; set; } = false;

/// <summary>
/// Allows overriding the value returned by <see cref="Windows.UI.ViewManagement.AccessibilitySettings.HighContrastScheme"/>.
/// </summary>
public static string HighContrastScheme { get; set; } = "High Contrast Black";
}
}
}

0 comments on commit 99726d5

Please sign in to comment.