diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 77e262d3a..7835bdd7b 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -286,6 +286,35 @@ class IOSApplication implements IOSApplicationDefinition { if (!haveController) { this._window.makeKeyAndVisible(); } + + this._rootView.on("traitCollectionColorAppearanceChanged", + (args) => { + if (this._rootView === args.object) { + console.log("---> Oh!"); + this._rootView.notify({ eventName: "colorAppearanceChanged", object: this._rootView }); + + const userInterfaceStyle = this._rootView.viewController.traitCollection.userInterfaceStyle; + const userInterfaceStyleValue = getUserInterfaceStyleValue(userInterfaceStyle); + console.log("---> userInterfaceStyleValue", userInterfaceStyleValue); + this._rootView.cssClasses.delete("ns-dark"); + this._rootView.cssClasses.delete("ns-light"); + this._rootView.cssClasses.add("ns-" + userInterfaceStyleValue); + + this._rootView.cssClasses.forEach(console.log); + } + } + ); + + this._rootView.on("colorAppearanceChanged", + (args) => { + console.log("---> Yeah!"); + // const userInterfaceStyle = (args.object).traitCollection.userInterfaceStyle; + // console.log("---> userInterfaceStyle", userInterfaceStyle); + // const userInterfaceStyleValue = getUserInterfaceStyleValue(userInterfaceStyle); + + + } + ); } } @@ -419,7 +448,10 @@ function getViewController(rootView: View): UIViewController { pushToRootViewCssClasses(`${CLASS_PREFIX}${userInterfaceStyleValue}`); const rootViewCssClasses = getRootViewCssClasses(); + rootView.cssClasses.forEach(console.log); rootViewCssClasses.forEach(c => rootView.cssClasses.add(c)); + console.log("---> kur"); + rootView.cssClasses.forEach(console.log); return viewController; } @@ -437,6 +469,7 @@ function setViewControllerView(view: View): void { } } + on(orientationChangedEvent, (args: OrientationChangedEventData) => { const rootView = getRootView(); if (rootView) { diff --git a/tns-core-modules/ui/frame/frame.ios.ts b/tns-core-modules/ui/frame/frame.ios.ts index afa1feaac..0cf9a4b18 100644 --- a/tns-core-modules/ui/frame/frame.ios.ts +++ b/tns-core-modules/ui/frame/frame.ios.ts @@ -541,6 +541,7 @@ class UINavigationControllerImpl extends UINavigationController { console.log("---> UINavigationControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + console.log("---> UINavigationControllerImpl.traitCollectionColorAppearanceChanged()", owner); owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); } }