-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[General] [added] - Add support for "reduce motion" into AccessibilityInfo #23839
[General] [added] - Add support for "reduce motion" into AccessibilityInfo #23839
Conversation
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
|
da5a517
to
a2ec146
Compare
a2ec146
to
3c44bf0
Compare
I really hope that this change gets accepted. Currently it's not possible to implement as good accessibility support on React Native than it is on native iOS, and disabling animations when "reduced motion" is enabled is a great thing.
These area also good additions allow even better experience. Btw. are there any similar flags on Android for these ones? |
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.
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@kristerkari I think just "inverted color" is also supported by Android |
Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js
Outdated
Show resolved
Hide resolved
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.
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
Nice work, thanks for adding this functionality! I'll try to land it as it seems like it got stuck earlier.
This pull request was successfully merged by @elucaswork in 0090ab3. When will my fix make it into a release? | Upcoming Releases |
Summary: As a follow-up to this other PR #23839, it adds support for other, iOS only, flags into `AccessibilityInfo`. It adds these other 4 methods: * `isBoldTextEnabled()` * `isGrayscaleEnabled()` * `isInvertColorsEnabled()` * `isReduceTransparencyEnabled()` P.S: Android implementation for those methods just return `false` (with `Promise.resolve(false)`) And the corresponding event listeners: * `boldTextChanged` * `grayscaleChanged`, * `invertColorsChanged`, * `reduceTransparencyChanged` Pull Request resolved: #23913 Differential Revision: D14482214 Pulled By: cpojer fbshipit-source-id: b97725fd12706957d4dad880a97e6b0993738272
Summary: I've realized after #23839 got merged, that `AccessibilityInfo` doesn't have a jest mock the same way as the other frameworks do. This PR adds the testing mock for `AccessibilityInfo`. Pull Request resolved: #23982 Differential Revision: D14502780 Pulled By: cpojer fbshipit-source-id: ec11bd547b6f90858e7f51ed8230c8d02dc4904c
Summary
This PR adds
isReduceMotionEnabled()
toAccessibilityInfo
in other to add support for "reduce motion", exposing the Operational System's settings option. Additionally, it adds a new event,reduceMotionChanged
, in order to listen for this flag's update.With this feature, developers will be able to disable or reduce animations, something that will be required as soon as WCAG 2.1 draft got approved. See WCAG 2.1 — 2.3.3 Animations from Interaction criteria
Changelog
It's exposed by
UIAccessibility
' isReduceMotionEnabled on iOS and Settings.Global.TRANSITION_ANIMATION_SCALE on Android.Up until now,
AccessibilityInfo
only exposes screen reader flag. By adding this second accessibility option, it's a good opportunity to renamefetch
method to an appropriate name,isScreenReaderEnabled
, as well as renamechange
event toscreenReaderChanged
, which will make it clearer and more specific.(In case it's approved, a follow-up PR could exposes more iOS acessibility flags, such as
isShakeToUndoEnabled
,isReduceTransparencyEnabled
,isGrayscaleEnabled
,isInvertColorsEnabled
)(iOS code inspired by phonegap-mobile-accessibility. And Android by Flutter)
Test Plan
For iOS:
"General" > "Accessibility" > "Reduce Motion" in Settings, then make sure the toggle next to "Reduce Motion" is enabled.
For Android:
Reduce motion is only an option from Android 9 via "Accessibility" > "Reduce Motion" in Settings. For other versions, it can be enabled via "Transition Animation Scale" in "Developer options" selecting "Animation off"
The api applied:
TODO:
AccessibilityInfo
documentation.