FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(layout): IOS Layout not invalidated with custom root (#5724) · NativeScript/NativeScript@f1c0b85 · GitHub

Commit f1c0b85

Browse files
authored andcommitted
fix(layout): IOS Layout not invalidated with custom root (#5724)
* fix(layout): Buuple up layout trough viewControllers * test: Layout invalidates correctly with different root view * chore: tslint
1 parent ade142f commit f1c0b85

5 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎tests/app/ui/root-view/mymodule/MyControl.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class MyControl extends stackLayoutModule.StackLayout {
1010
var counter: number = 0;
1111

1212
var lbl = new label.Label();
13+
lbl.id = "my-test-label";
1314
var btn = new button.Button();
1415
btn.text = "Tap me!";
1516
btn.on(button.Button.tapEvent, (args: observable.EventData) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<GridLayout class="MyStackLayoutRoot">
2+
<Label text="I'm here!!!" id="my-test-label"/>
23
</GridLayout>

‎tests/app/ui/root-view/root-modules/tabview-root.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<TabViewItem title="Tab">
55
<TabViewItem.view>
6-
<Label text="Tab" />
6+
<Label text="Tab" id="my-test-label"/>
77
</TabViewItem.view>
88
</TabViewItem>
99

‎tests/app/ui/root-view/root-view-tests.ts‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as TKUnit from "../../TKUnit";
2-
import { Page } from "tns-core-modules/ui/page";
2+
import { Page, View } from "tns-core-modules/ui/page";
33
import { Frame, NavigationEntry, stack } from "tns-core-modules/ui/frame";
44
import { _resetRootView, getRootView } from "tns-core-modules/application";
55
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
@@ -65,10 +65,42 @@ export function test_gridlayout_rootview_css_applied() {
6565
helper.assertViewBackgroundColor(rootView, "#0000FF");
6666
};
6767

68+
export function test_gridlayout_rootview_layout_updates() {
69+
layout_invalidate_test("ui/root-view/root-modules/gridlayout-root");
70+
}
71+
72+
export function test_custom_component_rootview_layout_updates() {
73+
layout_invalidate_test("ui/root-view/root-modules/custom-component-root");
74+
}
75+
76+
export function test_tabview_rootview_layout_updates() {
77+
layout_invalidate_test("ui/root-view/root-modules/gridlayout-root");
78+
}
79+
80+
function layout_invalidate_test(moduleName: string) {
81+
var entry = { moduleName };
82+
83+
_resetRootView(entry);
84+
85+
var rootView = getRootView();
86+
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
87+
88+
const lbl = <View>rootView.getViewById("my-test-label");
89+
90+
lbl.visibility = "collapse";
91+
TKUnit.assertFalse(rootView.isLayoutValid);
92+
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
93+
94+
lbl.visibility = "visible";
95+
TKUnit.assertFalse(rootView.isLayoutValid);
96+
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
97+
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
98+
}
99+
68100
export function tearDownModule() {
69101
// reset the root to frame for other tests
70102
const resetFrameRoot = createTestFrameRootEntry();
71103

72104
_resetRootView(resetFrameRoot.entry);
73105
TKUnit.waitUntilReady(() => resetFrameRoot.page.isLoaded);
74-
}
106+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export class View extends ViewCommon {
5959
if (nativeView) {
6060
nativeView.setNeedsLayout();
6161
}
62+
63+
if (this.viewController && this.viewController.view !== nativeView) {
64+
this.viewController.view.setNeedsLayout();
65+
}
6266
}
6367

6468
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL