mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(ios): embed systemAppearance handling (#10219)
This commit is contained in:
@@ -206,6 +206,19 @@ export class iOSApplication implements iOSApplicationDefinition {
|
||||
return this._rootView;
|
||||
}
|
||||
|
||||
public setSystemAppearance(value: 'light' | 'dark' | null) {
|
||||
if (this.systemAppearance !== value) {
|
||||
this._systemAppearance = value;
|
||||
systemAppearanceChanged(this.rootView, value);
|
||||
notify(<SystemAppearanceChangedEventData>{
|
||||
eventName: systemAppearanceChangedEvent,
|
||||
ios: this,
|
||||
newValue: iosApp.systemAppearance,
|
||||
object: this,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
||||
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
|
||||
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, 'onReceive', notificationName, null);
|
||||
@@ -376,17 +389,7 @@ export class iOSApplication implements iOSApplicationDefinition {
|
||||
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
||||
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
||||
|
||||
if (this._systemAppearance !== newSystemAppearance) {
|
||||
this._systemAppearance = newSystemAppearance;
|
||||
systemAppearanceChanged(rootView, newSystemAppearance);
|
||||
|
||||
notify(<SystemAppearanceChangedEventData>{
|
||||
eventName: systemAppearanceChangedEvent,
|
||||
ios: this,
|
||||
newValue: this._systemAppearance,
|
||||
object: this,
|
||||
});
|
||||
}
|
||||
this.setSystemAppearance(newSystemAppearance);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -475,16 +478,7 @@ export function run(entry?: string | NavigationEntry) {
|
||||
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
||||
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
||||
|
||||
if (this._systemAppearance !== newSystemAppearance) {
|
||||
this._systemAppearance = newSystemAppearance;
|
||||
|
||||
notify(<SystemAppearanceChangedEventData>{
|
||||
eventName: systemAppearanceChangedEvent,
|
||||
ios: this,
|
||||
newValue: this._systemAppearance,
|
||||
object: this,
|
||||
});
|
||||
}
|
||||
iosApp.setSystemAppearance(newSystemAppearance);
|
||||
});
|
||||
iosApp.notifyAppStarted();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user