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;
|
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 {
|
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
||||||
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
|
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
|
||||||
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, 'onReceive', notificationName, null);
|
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, 'onReceive', notificationName, null);
|
||||||
@@ -376,17 +389,7 @@ export class iOSApplication implements iOSApplicationDefinition {
|
|||||||
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
||||||
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
||||||
|
|
||||||
if (this._systemAppearance !== newSystemAppearance) {
|
this.setSystemAppearance(newSystemAppearance);
|
||||||
this._systemAppearance = newSystemAppearance;
|
|
||||||
systemAppearanceChanged(rootView, newSystemAppearance);
|
|
||||||
|
|
||||||
notify(<SystemAppearanceChangedEventData>{
|
|
||||||
eventName: systemAppearanceChangedEvent,
|
|
||||||
ios: this,
|
|
||||||
newValue: this._systemAppearance,
|
|
||||||
object: this,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,16 +478,7 @@ export function run(entry?: string | NavigationEntry) {
|
|||||||
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
|
||||||
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
|
||||||
|
|
||||||
if (this._systemAppearance !== newSystemAppearance) {
|
iosApp.setSystemAppearance(newSystemAppearance);
|
||||||
this._systemAppearance = newSystemAppearance;
|
|
||||||
|
|
||||||
notify(<SystemAppearanceChangedEventData>{
|
|
||||||
eventName: systemAppearanceChangedEvent,
|
|
||||||
ios: this,
|
|
||||||
newValue: this._systemAppearance,
|
|
||||||
object: this,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
iosApp.notifyAppStarted();
|
iosApp.notifyAppStarted();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user