From 6e1eae005d21f5616e1b0ad7f91595cf4b27bae3 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Mon, 30 Sep 2019 13:55:53 +0300 Subject: [PATCH] feat(ios): expose traitCollectionColorAppearanceChangedEvent --- .../ui/bottom-navigation/bottom-navigation.ios.ts | 5 +++-- tns-core-modules/ui/core/view/view.d.ts | 5 +++++ tns-core-modules/ui/core/view/view.ios.ts | 7 +++++-- tns-core-modules/ui/frame/frame.ios.ts | 6 ++++-- tns-core-modules/ui/page/page.ios.ts | 5 +++-- tns-core-modules/ui/tab-view/tab-view.ios.ts | 5 +++-- tns-core-modules/ui/tabs/tabs.ios.ts | 5 +++-- 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts b/tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts index c0ea8d49f..5a8445376 100644 --- a/tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts +++ b/tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts @@ -84,11 +84,12 @@ class UITabBarControllerImpl extends UITabBarController { super.traitCollectionDidChange(previousTraitCollection); const owner = this._owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UITabBarControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } } diff --git a/tns-core-modules/ui/core/view/view.d.ts b/tns-core-modules/ui/core/view/view.d.ts index 2eafa9694..be60affc3 100644 --- a/tns-core-modules/ui/core/view/view.d.ts +++ b/tns-core-modules/ui/core/view/view.d.ts @@ -839,6 +839,11 @@ export const iosOverflowSafeAreaProperty: Property; export const iosOverflowSafeAreaEnabledProperty: InheritedProperty; export namespace ios { + /** + * String value used when hooking to traitCollectionColorAppearanceChangedEvent event. + */ + export const traitCollectionColorAppearanceChangedEvent: string; + /** * Returns a view with viewController or undefined if no such found along the view's parent chain. * @param view The view form which to start the search. diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index c04add1f2..6b7029456 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -702,6 +702,8 @@ export class CustomLayoutView extends ContainerView { } export namespace ios { + export const traitCollectionColorAppearanceChangedEvent = "traitCollectionColorAppearanceChanged"; + export function getParentWithViewController(view: View): View { while (view && !view.viewController) { view = view.parent as View; @@ -1008,11 +1010,12 @@ export namespace ios { super.traitCollectionDidChange(previousTraitCollection); const owner = this.owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UILayoutViewController.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: traitCollectionColorAppearanceChangedEvent, object: owner }); } } } diff --git a/tns-core-modules/ui/frame/frame.ios.ts b/tns-core-modules/ui/frame/frame.ios.ts index afa1feaac..2563472bb 100644 --- a/tns-core-modules/ui/frame/frame.ios.ts +++ b/tns-core-modules/ui/frame/frame.ios.ts @@ -2,6 +2,7 @@ import { iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition } from "."; +import { ios as iosView } from "../core/view"; import { Page } from "../page"; import { profile } from "../../profiling"; @@ -537,11 +538,12 @@ class UINavigationControllerImpl extends UINavigationController { super.traitCollectionDidChange(previousTraitCollection); const owner = this._owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UINavigationControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } } diff --git a/tns-core-modules/ui/page/page.ios.ts b/tns-core-modules/ui/page/page.ios.ts index d75c3f8f6..8e75a15c6 100644 --- a/tns-core-modules/ui/page/page.ios.ts +++ b/tns-core-modules/ui/page/page.ios.ts @@ -285,11 +285,12 @@ class UIViewControllerImpl extends UIViewController { super.traitCollectionDidChange(previousTraitCollection); const owner = this._owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UIViewControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } } diff --git a/tns-core-modules/ui/tab-view/tab-view.ios.ts b/tns-core-modules/ui/tab-view/tab-view.ios.ts index a5a7983c9..c8e04d372 100644 --- a/tns-core-modules/ui/tab-view/tab-view.ios.ts +++ b/tns-core-modules/ui/tab-view/tab-view.ios.ts @@ -76,11 +76,12 @@ class UITabBarControllerImpl extends UITabBarController { super.traitCollectionDidChange(previousTraitCollection); const owner = this._owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UITabBarControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } } diff --git a/tns-core-modules/ui/tabs/tabs.ios.ts b/tns-core-modules/ui/tabs/tabs.ios.ts index eae05b6ef..ee1c0501a 100644 --- a/tns-core-modules/ui/tabs/tabs.ios.ts +++ b/tns-core-modules/ui/tabs/tabs.ios.ts @@ -195,11 +195,12 @@ class UIPageViewControllerImpl extends UIPageViewController { super.traitCollectionDidChange(previousTraitCollection); const owner = this._owner.get(); - owner.notify({ eventName: "traitCollectionChanged", object: owner }); + // TODO: + // owner.notify({ eventName: "traitCollectionChanged", object: owner }); console.log("---> UIPageViewControllerImpl.traitCollectionDidChange()"); if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner }); + owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } }