discussions-and-proposals icon indicating copy to clipboard operation
discussions-and-proposals copied to clipboard

Proposal to add support for "Prefer Cross-Fade Transitions" into AccessibilityInfo

Open gabrieldonadel opened this issue 3 years ago • 2 comments

Introduction

I would like to propose adding support for "Prefer Cross-Fade Transitions" into AccessibilityInfo by exposing the iOS UIAccessibilityPrefersCrossFadeTransitions() function.

Details

UIAccessibilityPrefersCrossFadeTransitions was added to UIKit on iOS 14.0 indicating whether the Reduce Motion and the Prefer Cross-Fade Transitions settings are in an enabled state. It would be great to have a method for that embedded into AccessibilityInfo. As this is an iOS-only feature I suggest we just always return false on Android.

There's a caveat though, we would not be able to add support for a prefersCrossFadeTransitionsChanged event into AccessibilityInfo.addEventListener because from my testing (iOS 14.4 and 15.2) UIAccessibilityPrefersCrossFadeTransitionsStatusDidChangeNotification does not get triggered when changing the "Prefer Cross-Fade Transitions" option in the accessibility settings, due to this factor we would need to call UIAccessibilityPrefersCrossFadeTransitions() every time to get the most updated value instead of storing it into a private variable inside RCTAccessibilityManager

My idea is to add a prefersCrossFadeTransitions function to AccessibilityInfo which would probably look something like this:

  prefersCrossFadeTransitions(): Promise<boolean> {
    return new Promise((resolve, reject) => {
      if (Platform.OS === 'android') {
        return Promise.resolve(false);
      } else {
        if (NativeAccessibilityManagerIOS != null) {
          NativeAccessibilityManagerIOS.getCurrentPrefersCrossFadeTransitionsState(
            resolve,
            reject,
          );
        } else {
          reject(null);
        }
      }
    });
  }

Note: I already have a draft for this implementation if anyone is interested in taking a look https://github.com/gabrieldonadel/react-native/pull/2

Discussion points

  • Should we add a prefersCrossFadeTransitions function to AccessibilityInfo?

gabrieldonadel avatar Jan 27 '22 03:01 gabrieldonadel

I believe this would be especially helpful for solving https://github.com/facebook/react-native/issues/31484

gabrieldonadel avatar Jan 31 '22 00:01 gabrieldonadel

This would help improve react-navigation for users who have motion sensitivity and prefer cross-fade transitions

martsie avatar Feb 14 '22 04:02 martsie

I'm closing this as the support for "Prefer Cross-Fade Transitions" into AccessibilityInfo was added through https://github.com/facebook/react-native/commit/be7c50fefd7f13201fb538ded93d91b374341173

gabrieldonadel avatar Aug 25 '22 17:08 gabrieldonadel