Skip to content

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

@gabrieldonadel

Description

@gabrieldonadel

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 gabrieldonadel/react-native#2

Discussion points

  • Should we add a prefersCrossFadeTransitions function to AccessibilityInfo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions