Support accessibility labels on iOS switches. (flutter/engine#12404)
This commit is contained in:
committed by
Jonah Williams
parent
92dda0b588
commit
4a14828c0b
@@ -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<String> features = <String>[];
|
||||
@@ -1234,6 +1240,8 @@ class AccessibilityFeatures {
|
||||
features.add('boldText');
|
||||
if (reduceMotion)
|
||||
features.add('reduceMotion');
|
||||
if (onOffSwitchLabels)
|
||||
features.add('onOffSwitchLabels');
|
||||
return 'AccessibilityFeatures$features';
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ enum class AccessibilityFeatureFlag : int32_t {
|
||||
kDisableAnimations = 1 << 2,
|
||||
kBoldText = 1 << 3,
|
||||
kReduceMotion = 1 << 4,
|
||||
kOnOffSwitchLabels = 1 << 5,
|
||||
};
|
||||
|
||||
class WindowClient {
|
||||
|
||||
@@ -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<String> features = <String>[];
|
||||
@@ -1057,6 +1063,9 @@ class AccessibilityFeatures {
|
||||
if (reduceMotion) {
|
||||
features.add('reduceMotion');
|
||||
}
|
||||
if (onOffSwitchLabels) {
|
||||
features.add('onOffSwitchLabels');
|
||||
}
|
||||
return 'AccessibilityFeatures$features';
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,16 @@ typedef enum UIAccessibilityContrast : NSInteger {
|
||||
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 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
|
||||
flags |= static_cast<int32_t>(flutter::AccessibilityFeatureFlag::kReduceMotion);
|
||||
if (UIAccessibilityIsBoldTextEnabled())
|
||||
flags |= static_cast<int32_t>(flutter::AccessibilityFeatureFlag::kBoldText);
|
||||
if (UIAccessibilityIsOnOffSwitchLabelsEnabled())
|
||||
flags |= static_cast<int32_t>(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
|
||||
|
||||
Reference in New Issue
Block a user