feat(ios): expose traitCollectionColorAppearanceChangedEvent

This commit is contained in:
Vasil Chimev
2019-09-30 13:55:53 +03:00
parent 5e215d9b98
commit 6e1eae005d
7 changed files with 26 additions and 12 deletions

View File

@@ -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 });
}
}
}

View File

@@ -839,6 +839,11 @@ export const iosOverflowSafeAreaProperty: Property<View, boolean>;
export const iosOverflowSafeAreaEnabledProperty: InheritedProperty<View, boolean>;
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.

View File

@@ -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 });
}
}
}

View File

@@ -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 });
}
}
}

View File

@@ -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 });
}
}
}

View File

@@ -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 });
}
}
}

View File

@@ -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 });
}
}
}