Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/core/application/application.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,13 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication

protected getSystemAppearance(): 'light' | 'dark' {
// userInterfaceStyle is available on UITraitCollection since iOS 12.
if ((!__VISIONOS__ && SDK_VERSION <= 11) || !this.rootController) {
if (!__VISIONOS__ && SDK_VERSION <= 11) {
return null;
}

const userInterfaceStyle = this.rootController.traitCollection.userInterfaceStyle;
return this.getSystemAppearanceValue(userInterfaceStyle);
// the launch event fires before the window has a root view controller: the screen traits are enough then
const traits = this.rootController?.traitCollection ?? this.window?.traitCollection ?? UIScreen.mainScreen.traitCollection;
return this.getSystemAppearanceValue(traits.userInterfaceStyle);
}

private getSystemAppearanceValue(userInterfaceStyle: number): 'dark' | 'light' {
Expand Down
8 changes: 3 additions & 5 deletions packages/core/native-window/native-window.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ export class IOSNativeWindow extends NativeWindow {
if (!__VISIONOS__ && SDK_VERSION <= 11) {
return null;
}
const rootVC = this._window?.rootViewController;
if (!rootVC) {
return null;
}
return this._getSystemAppearanceValue(rootVC.traitCollection.userInterfaceStyle);
// the launch event fires before the window has a root view controller: the screen traits are enough then
const traits = this._window?.rootViewController?.traitCollection ?? this._window?.traitCollection ?? UIScreen.mainScreen.traitCollection;
return this._getSystemAppearanceValue(traits.userInterfaceStyle);
}

protected _getLayoutDirection(): CoreTypes.LayoutDirectionType | null {
Expand Down
Loading