Add UIContentSizeCategoryDidChangeNotification to re-render text

Summary:
Changelog:
[Internal] - Add UIContentSizeCategoryDidChangeNotification to re-render text

We don't need to restart the app to re-render text now, but we still need to swipe the screen or click on buttons to force to refresh. We may address this in the future.

Reviewed By: PeteTheHeat

Differential Revision: D22867293

fbshipit-source-id: 4747a45adc2bdc638cf7ef9c07a9484e48600583
This commit is contained in:
Jiayan Zhuang 2020-08-04 15:09:44 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 7bf6196408
Коммит df66b7a4d2
1 изменённых файлов: 22 добавлений и 0 удалений

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

@ -120,6 +120,11 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
_observers = [NSMutableArray array];
_scheduler = [self _createScheduler];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_handleContentSizeCategoryDidChangeNotification:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}
return self;
@ -425,6 +430,23 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
}];
}
- (void)_handleContentSizeCategoryDidChangeNotification:(NSNotification *)notification
{
RCTScheduler *scheduler = [self _scheduler];
[_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RCTFabricSurface *> *enumerator) {
for (RCTFabricSurface *surface in enumerator) {
LayoutContext layoutContext = RCTGetLayoutContext();
LayoutConstraints layoutConstraints = RCTGetLayoutConstraintsForSize(surface.minimumSize, surface.maximumSize);
[scheduler constraintSurfaceLayoutWithLayoutConstraints:layoutConstraints
layoutContext:layoutContext
surfaceId:surface.rootTag];
}
}];
}
#pragma mark - RCTSchedulerDelegate
- (void)schedulerDidFinishTransaction:(MountingCoordinator::Shared const &)mountingCoordinator