Use Dynamic Text Size Multipliers from Wilde in ReactNative Module
This commit is contained in:
parent
ffa7dbcbf1
commit
9edad17a15
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue