From eddc2c90f693739273583b74fc70148182b9f143 Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Fri, 18 Nov 2016 17:24:42 -0800 Subject: [PATCH] iOS: Add getContentSizeMultiplier & event Summary: Corresponding Android PR: https://github.com/facebook/react-native/pull/11008 This gives apps the ability to find out the current scaling factor for fonts on the device. An event was also added so that apps can find out when this value changes. **Test plan (required)** Verified that the getter and the event work properly in a test app. Also, this change is used in my team's app. Adam Comella Microsoft Corp. Closes https://github.com/facebook/react-native/pull/11010 Differential Revision: D4207620 Pulled By: ericvicenti fbshipit-source-id: b3f6f4a412557ba97e1f5fb63446c7ff9a2ff753 --- React/Modules/RCTUIManager.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 2db1bc9419..8bc31ee03e 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -240,6 +240,10 @@ RCT_EXPORT_MODULE() - (void)didReceiveNewContentSizeMultiplier { + // Report the event across the bridge. + [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateContentSizeMultiplier" + body:@([_bridge.accessibilityManager multiplier])]; + dispatch_async(RCTGetUIManagerQueue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification object:self]; @@ -1565,6 +1569,11 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config }]; } +RCT_EXPORT_METHOD(getContentSizeMultiplier:(nonnull RCTResponseSenderBlock)callback) +{ + callback(@[@(_bridge.accessibilityManager.multiplier)]); +} + - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView *view))completion { RCTAssertMainQueue();