8000 feat: add traitCollectionDidChange to controllers · NativeScript/NativeScript@7da835d · GitHub
[go: up one dir, main page]

Skip to content

Commit 7da835d

Browse files
committed
feat: add traitCollectionDidChange to controllers
1 parent 327adb7 commit 7da835d

File tree

6 files changed

+72
-4
lines changed

6 files changed

+72
-4
lines changed

tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ class UITabBarControllerImpl extends UITabBarController {
7979
}
8080
});
8181
}
82+
83+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
84+
super.traitCollectionDidChange(previousTraitCollection);
85+
86+
const owner = this._owner.get();
87+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
88+
console.log("---> UITabBarControllerImpl.traitCollectionDidChange()");
89+
90+
if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
91+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
92+
}
93+
}
8294
}
8395

8496
class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControllerDelegate {

tns-core-modules/ui/core/view/view.ios.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,18 @@ export namespace ios {
10031003
owner.callUnloaded();
10041004
}
10051005
}
1006+
1007+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
1008+
super.traitCollectionDidChange(previousTraitCollection);
1009+
1010+
const owner = this.owner.get();
1011+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
1012+
console.log("---> UILayoutViewController.traitCollectionDidChange()");
1013+
1014+
if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
1015+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
1016+
}
1017+
}
10061018
}
10071019

10081020
export class UIPopoverPresentationControllerDelegateImp extends NSObject implements UIPopoverPresentationControllerDelegate {

tns-core-modules/ui/frame/frame.ios.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ class UINavigationControllerImpl extends UINavigationController {
393393
return controller;
394394
}
395395

396-
get owner(): Frame {
397-
return this._owner.get();
398-
}
399-
400396
@profile
401397
public viewWillAppear(animated: boolean): void {
402398
super.viewWillAppear(animated);
@@ -532,6 +528,18 @@ class UINavigationControllerImpl extends UINavigationController {
532528

533529
return null;
534530
}
531+
532+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
533+
super.traitCollectionDidChange(previousTraitCollection);
534+
535+
const owner = this._owner.get();
536+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
537+
console.log("---> UINavigationControllerImpl.traitCollectionDidChange()");
538+
539+
if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
540+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
541+
}
542+
}
535543
}
536544

537545
function _getTransitionId(nativeTransition: UIViewAnimationTransition, transitionType: string): string {

tns-core-modules/ui/page/page.ios.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ class UIViewControllerImpl extends UIViewController {
280280
iosView.layoutView(this, owner);
281281
}
282282
}
283+
284+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
285+
super.traitCollectionDidChange(previousTraitCollection);
286+
287+
const owner = this._owner.get();
288+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
289+
console.log("---> UIViewControllerImpl.traitCollectionDidChange()");
290+
291+
if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
292+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
293+
}
294+
}
283295
}
284296

285297
const whiteColor = new Color("white").ios;

tns-core-modules/ui/tab-view/tab-view.ios.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ class UITabBarControllerImpl extends UITabBarController {
7171
}
7272
});
7373
}
74+
75+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
76+
super.traitCollectionDidChange(previousTraitCollection);
77+
78+
const owner = this._owner.get();
79+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
80+
console.log("---> UITabBarControllerImpl.traitCollectionDidChange()");
81+
82+
if (this.traitCollection.hasDifferentColorA 18B0 ppearanceComparedToTraitCollection(previousTraitCollection)) {
83+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
84+
}
85+
}
7486
}
7587

7688
class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControllerDelegate {

tns-core-modules/ui/tabs/tabs.ios.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ class UIPageViewControllerImpl extends UIPageViewController {
190190
scrollView.frame = CGRectMake(0, scrollViewTop, this.view.bounds.size.width, scrollViewHeight); //this.view.bounds;
191191
}
192192
}
193+
194+
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
195+
super.traitCollectionDidChange(previousTraitCollection);
196+
197+
const owner = this._owner.get();
198+
owner.notify({ eventName: "traitCollectionChanged", object: owner });
199+
console.log("---> UIPageViewControllerImpl.traitCollectionDidChange()");
200+
201+
if (this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
202+
owner.notify({ eventName: "traitCollectionColorAppearanceChanged", object: owner });
203+
}
204+
}
193205
}
194206

195207
class UIPageViewControllerDataSourceImpl extends NSObject implements UIPageViewControllerDataSource {

0 commit comments

Comments
 (0)
0