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
This commit is contained in:
Adam Comella 2016-11-18 17:24:42 -08:00 коммит произвёл Facebook Github Bot
Родитель a78ee4323b
Коммит eddc2c90f6
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

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