diff --git a/React/Modules/RCTAccessibilityManager.h b/React/Modules/RCTAccessibilityManager.h index 03d22f945..a901aa874 100644 --- a/React/Modules/RCTAccessibilityManager.h +++ b/React/Modules/RCTAccessibilityManager.h @@ -18,6 +18,9 @@ extern NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification; / @property (nonatomic, readonly) CGFloat multiplier; +/// map from UIKit categories to multipliers +@property (nonatomic, copy) NSDictionary *multipliers; + @end @interface RCTBridge (RCTAccessibilityManager) diff --git a/React/Modules/RCTAccessibilityManager.m b/React/Modules/RCTAccessibilityManager.m index 9271b1e3d..7fc58786a 100644 --- a/React/Modules/RCTAccessibilityManager.m +++ b/React/Modules/RCTAccessibilityManager.m @@ -15,7 +15,6 @@ NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAc @interface RCTAccessibilityManager () -@property (nonatomic, copy) NSDictionary *multipliers; @property (nonatomic, copy) NSString *contentSizeCategory; @property (nonatomic, assign) CGFloat multiplier; @@ -24,6 +23,7 @@ NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAc @implementation RCTAccessibilityManager @synthesize bridge = _bridge; +@synthesize multipliers = _multipliers; RCT_EXPORT_MODULE() @@ -80,11 +80,16 @@ RCT_EXPORT_MODULE() { if (_contentSizeCategory != contentSizeCategory) { _contentSizeCategory = [contentSizeCategory copy]; - self.multiplier = [self multiplierForContentSizeCategory:_contentSizeCategory]; - [[NSNotificationCenter defaultCenter] postNotificationName:RCTAccessibilityManagerDidUpdateMultiplierNotification object:self]; + [self invalidateMultiplier]; } } +- (void)invalidateMultiplier +{ + self.multiplier = [self multiplierForContentSizeCategory:_contentSizeCategory]; + [[NSNotificationCenter defaultCenter] postNotificationName:RCTAccessibilityManagerDidUpdateMultiplierNotification object:self]; +} + - (CGFloat)multiplierForContentSizeCategory:(NSString *)category { NSNumber *m = self.multipliers[category]; @@ -95,6 +100,14 @@ RCT_EXPORT_MODULE() return m.doubleValue; } +- (void)setMultipliers:(NSDictionary *)multipliers +{ + if (_multipliers != multipliers) { + _multipliers = [multipliers copy]; + [self invalidateMultiplier]; + } +} + - (NSDictionary *)multipliers { if (_multipliers == nil) {