This commit is contained in:
Vasil Chimev
2019-09-24 21:06:10 +03:00
parent 48616aa961
commit 8b990ffe3a
2 changed files with 27 additions and 3 deletions

View File

@ -86,6 +86,7 @@ class IOSApplication implements IOSApplicationDefinition {
private _observers: Array<NotificationObserver>;
private _orientation: "portrait" | "landscape" | "unknown";
private _rootView: View;
private _userInterfaceStyle: UIUserInterfaceStyle;
constructor() {
this._observers = new Array<NotificationObserver>();
@ -97,6 +98,10 @@ class IOSApplication implements IOSApplicationDefinition {
this.addNotificationObserver(UIApplicationDidChangeStatusBarOrientationNotification, this.didChangeStatusBarOrientation.bind(this));
}
private asdf(notification: NSNotification) {
console.log("---> Yeah!");
}
get orientation(): "portrait" | "landscape" | "unknown" {
if (!this._orientation) {
const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
@ -132,6 +137,14 @@ class IOSApplication implements IOSApplicationDefinition {
return this._rootView;
}
get userInterfaceStyle(): UIUserInterfaceStyle {
if (!this._userInterfaceStyle) {
this._userInterfaceStyle = this._rootView.viewController.traitCollection.userInterfaceStyle;
}
return this._userInterfaceStyle;
}
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
@ -389,6 +402,9 @@ export function getNativeApplication(): UIApplication {
}
function getViewController(view: View): UIViewController {
//
let viewController: UIViewController = view.viewController || view.ios;
if (viewController instanceof UIViewController) {
return viewController;

View File

@ -86,6 +86,14 @@ class UIViewControllerImpl extends UIViewController {
this.extendedLayoutIncludesOpaqueBars = true;
}
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
super.traitCollectionDidChange(previousTraitCollection);
console.log("---> traitCollectionDidChange");
}
public viewWillAppear(animated: boolean): void {
super.viewWillAppear(animated);
const owner = this._owner.get();