Skip to content

Commit

Permalink
iOS: Add getContentSizeMultiplier & event
Browse files Browse the repository at this point in the history
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
Adam Comella authored and Facebook Github Bot committed Nov 19, 2016
1 parent a78ee43 commit eddc2c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit eddc2c9

Please sign in to comment.