Use Dynamic Text Size Multipliers from Wilde in ReactNative Module

This commit is contained in:
Vladislav Alexeev 2015-08-07 02:32:00 -07:00
parent ffa7dbcbf1
commit 9edad17a15
2 changed files with 19 additions and 3 deletions

View File

@ -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)

View File

@ -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,10 +80,15 @@ RCT_EXPORT_MODULE()
{
if (_contentSizeCategory != contentSizeCategory) {
_contentSizeCategory = [contentSizeCategory copy];
[self invalidateMultiplier];
}
}
- (void)invalidateMultiplier
{
self.multiplier = [self multiplierForContentSizeCategory:_contentSizeCategory];
[[NSNotificationCenter defaultCenter] postNotificationName:RCTAccessibilityManagerDidUpdateMultiplierNotification object:self];
}
}
- (CGFloat)multiplierForContentSizeCategory:(NSString *)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) {