diff --git a/lib/ui/window.dart b/lib/ui/window.dart index a810551e38254..edff156af1ef4 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -1194,6 +1194,7 @@ class AccessibilityFeatures { static const int _kDisableAnimationsIndex = 1 << 2; static const int _kBoldTextIndex = 1 << 3; static const int _kReduceMotionIndex = 1 << 4; + static const int _kOnOffSwitchLabelsIndex = 1 << 5; // A bitfield which represents each enabled feature. final int _index; @@ -1221,6 +1222,11 @@ class AccessibilityFeatures { /// Only supported on iOS. bool get reduceMotion => _kReduceMotionIndex & _index != 0; + /// The platform is requesting that on/off labels be added to switches. + /// + /// Only supported on iOS. + bool get onOffSwitchLabels => _kOnOffSwitchLabelsIndex & _index != 0; + @override String toString() { final List features = []; @@ -1234,6 +1240,8 @@ class AccessibilityFeatures { features.add('boldText'); if (reduceMotion) features.add('reduceMotion'); + if (onOffSwitchLabels) + features.add('onOffSwitchLabels'); return 'AccessibilityFeatures$features'; } diff --git a/lib/ui/window/window.h b/lib/ui/window/window.h index 99a8585a6910a..6039b9e178dc0 100644 --- a/lib/ui/window/window.h +++ b/lib/ui/window/window.h @@ -44,6 +44,7 @@ enum class AccessibilityFeatureFlag : int32_t { kDisableAnimations = 1 << 2, kBoldText = 1 << 3, kReduceMotion = 1 << 4, + kOnOffSwitchLabels = 1 << 5, }; class WindowClient { diff --git a/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart index 80f15c712d165..56c09a4133dd7 100644 --- a/lib/web_ui/lib/src/ui/window.dart +++ b/lib/web_ui/lib/src/ui/window.dart @@ -1012,6 +1012,7 @@ class AccessibilityFeatures { static const int _kDisableAnimationsIndex = 1 << 2; static const int _kBoldTextIndex = 1 << 3; static const int _kReduceMotionIndex = 1 << 4; + static const int _kOnOffSwitchLabelsIndex = 1 << 5; // A bitfield which represents each enabled feature. final int _index; @@ -1039,6 +1040,11 @@ class AccessibilityFeatures { /// Only supported on iOS. bool get reduceMotion => _kReduceMotionIndex & _index != 0; + /// The platform is requesting that on/off labels be added to switches. + /// + /// Only supported on iOS. + bool get onOffSwitchLabels => _kOnOffSwitchLabelsIndex & _index != 0; + @override String toString() { final List features = []; @@ -1057,6 +1063,9 @@ class AccessibilityFeatures { if (reduceMotion) { features.add('reduceMotion'); } + if (onOffSwitchLabels) { + features.add('onOffSwitchLabels'); + } return 'AccessibilityFeatures$features'; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 87e605e97fd48..09a32e67f05a5 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -234,6 +234,16 @@ - (void)setupNotificationCenterObservers { name:UIAccessibilityBoldTextStatusDidChangeNotification object:nil]; + [center addObserver:self + selector:@selector(onAccessibilityStatusChanged:) + name:UIAccessibilityOnOffSwitchLabelsDidChangeNotification + object:nil]; + + [center addObserver:self + selector:@selector(onAccessibilityStatusChanged:) + name:UIAccessibilityOnOffSwitchLabelsDidChangeNotification + object:nil]; + [center addObserver:self selector:@selector(onUserSettingsChanged:) name:UIContentSizeCategoryDidChangeNotification @@ -857,6 +867,8 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification { flags |= static_cast(flutter::AccessibilityFeatureFlag::kReduceMotion); if (UIAccessibilityIsBoldTextEnabled()) flags |= static_cast(flutter::AccessibilityFeatureFlag::kBoldText); + if (UIAccessibilityIsOnOffSwitchLabelsEnabled()) + flags |= static_cast(flutter::AccessibilityFeatureFlag::kOnOffSwitchLabels); #if TARGET_OS_SIMULATOR // There doesn't appear to be any way to determine whether the accessibility // inspector is enabled on the simulator. We conservatively always turn on the