Skip to content

Commit

Permalink
Don't map iOS reduce motion to disabled animations (flutter#6194)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored Sep 7, 2018
1 parent 687cf08 commit 2af72eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ class AccessibilityFeatures {
static const int _kInvertColorsIndex = 1 << 1;
static const int _kDisableAnimationsIndex = 1 << 2;
static const int _kBoldTextIndex = 1 << 3;
static const int _kReduceMotionIndex = 1 << 4;

// A bitfield which represents each enabled feature.
final int _index;
Expand All @@ -784,6 +785,12 @@ class AccessibilityFeatures {
/// Only supported on iOS.
bool get boldText => _kBoldTextIndex & _index != 0;

/// The platform is requesting that certain animations be simplified and
/// parallax effects removed.
///
/// Only supported on iOS.
bool get reduceMotion => _kReduceMotionIndex & _index != 0;

@override
String toString() {
final List<String> features = <String>[];
Expand All @@ -795,6 +802,8 @@ class AccessibilityFeatures {
features.add('disableAnimations');
if (boldText)
features.add('boldText');
if (reduceMotion)
features.add('reduceMotion');
return 'AccessibilityFeatures$features';
}

Expand Down
1 change: 1 addition & 0 deletions lib/ui/window/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class AccessibilityFeatureFlag : int32_t {
kInvertColors = 1 << 1,
kDisableAnimations = 1 << 2,
kBoldText = 1 << 3,
kReduceMotion = 1 << 4,
};

class WindowClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
if (UIAccessibilityIsInvertColorsEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kInvertColors);
if (UIAccessibilityIsReduceMotionEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kDisableAnimations);
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kReduceMotion);
if (UIAccessibilityIsBoldTextEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kBoldText);
#if TARGET_OS_SIMULATOR
Expand Down

0 comments on commit 2af72eb

Please sign in to comment.