From 8b990ffe3aab8dd5eed208cf8188c41f989eabc9 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Tue, 24 Sep 2019 21:06:10 +0300 Subject: [PATCH] asdf --- .../application/application.ios.ts | 20 +++++++++++++++++-- tns-core-modules/ui/page/page.ios.ts | 10 +++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 37a834096..f374fdae1 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -39,8 +39,8 @@ const Responder = (UIResponder).extend({ // NOOP } }, { - protocols: [UIApplicationDelegate] - } + protocols: [UIApplicationDelegate] +} ); class NotificationObserver extends NSObject { @@ -86,6 +86,7 @@ class IOSApplication implements IOSApplicationDefinition { private _observers: Array; private _orientation: "portrait" | "landscape" | "unknown"; private _rootView: View; + private _userInterfaceStyle: UIUserInterfaceStyle; constructor() { this._observers = new Array(); @@ -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; diff --git a/tns-core-modules/ui/page/page.ios.ts b/tns-core-modules/ui/page/page.ios.ts index 093cf0970..2ba0e6fc3 100644 --- a/tns-core-modules/ui/page/page.ios.ts +++ b/tns-core-modules/ui/page/page.ios.ts @@ -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(); @@ -148,7 +156,7 @@ class UIViewControllerImpl extends UIViewController { const isReplace = navigationContext.navigationType === NavigationType.replace; frame.setCurrent(newEntry, navigationContext.navigationType); - + if (isReplace) { let controller = newEntry.resolvedPage.ios; if (controller) {