-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(HighContrast): Expose the XAML HighContrastChanged event to JS #1443
Conversation
The event is exposed as highContrastDidChange in AccessibilityInfo. For now it only tells if high contrast is enabled or disabled in system settings. Later it can tell what are the chosen high contrast colors: Windows 10 allows to create custom high contrast themes with user chosen colors.
|
||
public override void Initialize() | ||
{ | ||
_accessibility.HighContrastChanged += OnHighContrastChanged; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_accessibility.HighContrastChanged += OnHighContrastChanged; [](start = 12, length = 60)
Should we do this in Initialize
or in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eric suggested to use Initialize
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. What's the reasoning behind preferring Initialize
over the constructor? When does Initialize
get called relative to Constants
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor is called before the JS bundle is loaded, so you could potentially notify event to JS before anything there to listen. If you call after Initialize, bundle load operation has already been queued.
In reply to: 144430206 [](ancestors = 144430206)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firing an event before anything is listening sounds pretty harmless.
So it sounds like it doesn't matter too much whether you register for the event in Initialize
or in the constructor. Do you agree?
In reply to: 145428282 [](ancestors = 145428282,144430206)
return "rgba(" + color.R + "," + color.G + "," + color.B + "," + color.A + ")"; | ||
} | ||
|
||
private IDictionary<string, string> GetHighContrastColors() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private IDictionary<string, string> GetHighContrastColors() [](start = 8, length = 59)
Maybe put a TODO about how we want to expose these colors to JavaScript in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
return new Promise((resolve, reject) => { | ||
reject('AccessibilityInfo is not supported on this platform.'); | ||
resolve(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve(false); [](start = 6, length = 15)
Can you put a comment about how UWP doesn't provide any way to query whether or not a screen reader is being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report
@@ Coverage Diff @@
## master #1443 +/- ##
==========================================
- Coverage 31.82% 31.82% -0.01%
==========================================
Files 263 263
Lines 19078 19078
Branches 1589 1589
==========================================
- Hits 6072 6071 -1
Misses 12855 12855
- Partials 151 152 +1
Continue to review full report at Codecov.
|
return "rgba(" + color.R + "," + color.G + "," + color.B + "," + color.A + ")"; | ||
} | ||
|
||
// TODO: These are the 8 high contrast colors in Windows. Eventually they will be exposed to JS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you file an issue for this TODO item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #1459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event is exposed as highContrastDidChange in AccessibilityInfo. For now
it only tells if high contrast is enabled or disabled in system settings. Later it
can tell what are the chosen high contrast colors: Windows 10 allows to create
custom high contrast themes with user chosen colors.