Skip to content

Commit

Permalink
Merge pull request #261 from jpudysz/feature/init
Browse files Browse the repository at this point in the history
feat: await initial values while initializing ios core
  • Loading branch information
jpudysz authored Jul 31, 2024
2 parents 441d799 + c8e3466 commit a2dfbdd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ios/platform/Platform_iOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ - (void)makeShared:(void*)runtime {
return [self setRootViewBackgroundColor:color alpha:alpha];
});

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_main_queue(), ^{
Screen screen = [self getScreenDimensions];

Expand All @@ -92,7 +93,11 @@ - (void)makeShared:(void*)runtime {
unistylesRuntime->pixelRatio = screen.pixelRatio;
unistylesRuntime->fontScale = screen.fontScale;
unistylesRuntime->rtl = [self isRtl];

dispatch_semaphore_signal(semaphore);
});

dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}

- (void)onAppearanceChange:(NSNotification *)notification {
Expand Down Expand Up @@ -155,7 +160,7 @@ - (bool)isRtl {
BOOL hasForcedRtl = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"];
// user preferences
BOOL isRtl = [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;

return hasForcedRtl || isRtl;
}

Expand Down

0 comments on commit a2dfbdd

Please sign in to comment.