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

@ -39,8 +39,8 @@ const Responder = (<any>UIResponder).extend({
// NOOP // NOOP
} }
}, { }, {
protocols: [UIApplicationDelegate] protocols: [UIApplicationDelegate]
} }
); );
class NotificationObserver extends NSObject { class NotificationObserver extends NSObject {
@ -86,6 +86,7 @@ class IOSApplication implements IOSApplicationDefinition {
private _observers: Array<NotificationObserver>; private _observers: Array<NotificationObserver>;
private _orientation: "portrait" | "landscape" | "unknown"; private _orientation: "portrait" | "landscape" | "unknown";
private _rootView: View; private _rootView: View;
private _userInterfaceStyle: UIUserInterfaceStyle;
constructor() { constructor() {
this._observers = new Array<NotificationObserver>(); this._observers = new Array<NotificationObserver>();
@ -97,6 +98,10 @@ class IOSApplication implements IOSApplicationDefinition {
this.addNotificationObserver(UIApplicationDidChangeStatusBarOrientationNotification, this.didChangeStatusBarOrientation.bind(this)); this.addNotificationObserver(UIApplicationDidChangeStatusBarOrientationNotification, this.didChangeStatusBarOrientation.bind(this));
} }
private asdf(notification: NSNotification) {
console.log("---> Yeah!");
}
get orientation(): "portrait" | "landscape" | "unknown" { get orientation(): "portrait" | "landscape" | "unknown" {
if (!this._orientation) { if (!this._orientation) {
const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation; const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
@ -132,6 +137,14 @@ class IOSApplication implements IOSApplicationDefinition {
return this._rootView; 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 { 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);
@ -389,6 +402,9 @@ export function getNativeApplication(): UIApplication {
} }
function getViewController(view: View): UIViewController { function getViewController(view: View): UIViewController {
//
let viewController: UIViewController = view.viewController || view.ios; let viewController: UIViewController = view.viewController || view.ios;
if (viewController instanceof UIViewController) { if (viewController instanceof UIViewController) {
return viewController; return viewController;

View File

@ -86,6 +86,14 @@ class UIViewControllerImpl extends UIViewController {
this.extendedLayoutIncludesOpaqueBars = true; this.extendedLayoutIncludesOpaqueBars = true;
} }
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
super.traitCollectionDidChange(previousTraitCollection);
console.log("---> traitCollectionDidChange");
}
public viewWillAppear(animated: boolean): void { public viewWillAppear(animated: boolean): void {
super.viewWillAppear(animated); super.viewWillAppear(animated);
const owner = this._owner.get(); const owner = this._owner.get();
@ -148,7 +156,7 @@ class UIViewControllerImpl extends UIViewController {
const isReplace = navigationContext.navigationType === NavigationType.replace; const isReplace = navigationContext.navigationType === NavigationType.replace;
frame.setCurrent(newEntry, navigationContext.navigationType); frame.setCurrent(newEntry, navigationContext.navigationType);
if (isReplace) { if (isReplace) {
let controller = newEntry.resolvedPage.ios; let controller = newEntry.resolvedPage.ios;
if (controller) { if (controller) {