Skip to content

Commit 56bad48

Browse files
author
Jonah Williams
authored
expose bold text flag in accessibility features for iOS (flutter#6072)
1 parent ad4e87d commit 56bad48

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/ui/window.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ class AccessibilityFeatures {
762762
static const int _kAccessibleNavigation = 1 << 0;
763763
static const int _kInvertColorsIndex = 1 << 1;
764764
static const int _kDisableAnimationsIndex = 1 << 2;
765+
static const int _kBoldTextIndex = 1 << 3;
765766

766767
// A bitfield which represents each enabled feature.
767768
final int _index;
@@ -778,6 +779,11 @@ class AccessibilityFeatures {
778779
/// The platform is requesting that animations be disabled or simplified.
779780
bool get disableAnimations => _kDisableAnimationsIndex & _index != 0;
780781

782+
/// The platform is requesting that text be rendered at a bold font weight.
783+
///
784+
/// Only supported on iOS.
785+
bool get boldText => _kBoldTextIndex & _index != 0;
786+
781787
@override
782788
String toString() {
783789
final List<String> features = <String>[];
@@ -787,6 +793,8 @@ class AccessibilityFeatures {
787793
features.add('invertColors');
788794
if (disableAnimations)
789795
features.add('disableAnimations');
796+
if (boldText)
797+
features.add('boldText');
790798
return 'AccessibilityFeatures$features';
791799
}
792800

lib/ui/window/window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum class AccessibilityFeatureFlag : int32_t {
3030
kAccessibleNavigation = 1 << 0,
3131
kInvertColors = 1 << 1,
3232
kDisableAnimations = 1 << 2,
33+
kBoldText = 1 << 3,
3334
};
3435

3536
class WindowClient {

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ - (void)setupNotificationCenterObservers {
295295
name:UIAccessibilityReduceMotionStatusDidChangeNotification
296296
object:nil];
297297

298+
[center addObserver:self
299+
selector:@selector(onAccessibilityStatusChanged:)
300+
name:UIAccessibilityBoldTextStatusDidChangeNotification
301+
object:nil];
302+
298303
[center addObserver:self
299304
selector:@selector(onMemoryWarning:)
300305
name:UIApplicationDidReceiveMemoryWarningNotification
@@ -811,6 +816,8 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
811816
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kInvertColors);
812817
if (UIAccessibilityIsReduceMotionEnabled())
813818
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kDisableAnimations);
819+
if (UIAccessibilityIsBoldTextEnabled())
820+
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kBoldText);
814821
#if TARGET_OS_SIMULATOR
815822
// There doesn't appear to be any way to determine whether the accessibility
816823
// inspector is enabled on the simulator. We conservatively always turn on the

0 commit comments

Comments
 (0)