Permalink
Browse files

iOS: Add getContentSizeMultiplier & event

Summary:
Corresponding Android PR: #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 #11010

Differential Revision: D4207620

Pulled By: ericvicenti

fbshipit-source-id: b3f6f4a412557ba97e1f5fb63446c7ff9a2ff753
  • Loading branch information...
1 parent a78ee43 commit eddc2c90f693739273583b74fc70148182b9f143 @rigdern rigdern committed with Facebook Github Bot Nov 19, 2016
Showing with 9 additions and 0 deletions.
  1. +9 −0 React/Modules/RCTUIManager.m
@@ -240,6 +240,10 @@ @implementation RCTUIManager
- (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 @@ static void RCTMeasureLayout(RCTShadowView *view,
}];
}
+RCT_EXPORT_METHOD(getContentSizeMultiplier:(nonnull RCTResponseSenderBlock)callback)
+{
+ callback(@[@(_bridge.accessibilityManager.multiplier)]);
+}
+
- (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView *view))completion
{
RCTAssertMainQueue();

0 comments on commit eddc2c9

Please sign in to comment.