Skip to content

Commit ee92512

Browse files
authored
fix(ios): embed systemAppearance handling (#10219)
1 parent fd35d6c commit ee92512

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

packages/core/application/index.ios.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@ export class iOSApplication implements iOSApplicationDefinition {
206206
return this._rootView;
207207
}
208208

209+
public setSystemAppearance(value: 'light' | 'dark' | null) {
210+
if (this.systemAppearance !== value) {
211+
this._systemAppearance = value;
212+
systemAppearanceChanged(this.rootView, value);
213+
notify(<SystemAppearanceChangedEventData>{
214+
eventName: systemAppearanceChangedEvent,
215+
ios: this,
216+
newValue: iosApp.systemAppearance,
217+
object: this,
218+
});
219+
}
220+
}
221+
209222
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
210223
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
211224
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, 'onReceive', notificationName, null);
@@ -376,17 +389,7 @@ export class iOSApplication implements iOSApplicationDefinition {
376389
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
377390
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
378391

379-
if (this._systemAppearance !== newSystemAppearance) {
380-
this._systemAppearance = newSystemAppearance;
381-
systemAppearanceChanged(rootView, newSystemAppearance);
382-
383-
notify(<SystemAppearanceChangedEventData>{
384-
eventName: systemAppearanceChangedEvent,
385-
ios: this,
386-
newValue: this._systemAppearance,
387-
object: this,
388-
});
389-
}
392+
this.setSystemAppearance(newSystemAppearance);
390393
});
391394
}
392395
}
@@ -475,16 +478,7 @@ export function run(entry?: string | NavigationEntry) {
475478
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
476479
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
477480

478-
if (this._systemAppearance !== newSystemAppearance) {
479-
this._systemAppearance = newSystemAppearance;
480-
481-
notify(<SystemAppearanceChangedEventData>{
482-
eventName: systemAppearanceChangedEvent,
483-
ios: this,
484-
newValue: this._systemAppearance,
485-
object: this,
486-
});
487-
}
481+
iosApp.setSystemAppearance(newSystemAppearance);
488482
});
489483
iosApp.notifyAppStarted();
490484
}

0 commit comments

Comments
 (0)