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
This commit is contained in:
Alexander Vakrilov
2018-04-23 15:47:27 +03:00
committed by Stanimira Vlaeva
parent ade142fee7
commit f1c0b85d95
5 changed files with 41 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ export class MyControl extends stackLayoutModule.StackLayout {
var counter: number = 0;
var lbl = new label.Label();
lbl.id = "my-test-label";
var btn = new button.Button();
btn.text = "Tap me!";
btn.on(button.Button.tapEvent, (args: observable.EventData) => {

View File

@@ -1,2 +1,3 @@
<GridLayout class="MyStackLayoutRoot">
<Label text="I'm here!!!" id="my-test-label"/>
</GridLayout>

View File

@@ -3,7 +3,7 @@
<TabViewItem title="Tab">
<TabViewItem.view>
<Label text="Tab" />
<Label text="Tab" id="my-test-label"/>
</TabViewItem.view>
</TabViewItem>

View File

@@ -1,5 +1,5 @@
import * as TKUnit from "../../TKUnit";
import { Page } from "tns-core-modules/ui/page";
import { Page, View } from "tns-core-modules/ui/page";
import { Frame, NavigationEntry, stack } from "tns-core-modules/ui/frame";
import { _resetRootView, getRootView } from "tns-core-modules/application";
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
@@ -65,6 +65,38 @@ export function test_gridlayout_rootview_css_applied() {
helper.assertViewBackgroundColor(rootView, "#0000FF");
};
export function test_gridlayout_rootview_layout_updates() {
layout_invalidate_test("ui/root-view/root-modules/gridlayout-root");
}
export function test_custom_component_rootview_layout_updates() {
layout_invalidate_test("ui/root-view/root-modules/custom-component-root");
}
export function test_tabview_rootview_layout_updates() {
layout_invalidate_test("ui/root-view/root-modules/gridlayout-root");
}
function layout_invalidate_test(moduleName: string) {
var entry = { moduleName };
_resetRootView(entry);
var rootView = getRootView();
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
const lbl = <View>rootView.getViewById("my-test-label");
lbl.visibility = "collapse";
TKUnit.assertFalse(rootView.isLayoutValid);
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
lbl.visibility = "visible";
TKUnit.assertFalse(rootView.isLayoutValid);
TKUnit.waitUntilReady(() => rootView.isLayoutValid);
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
}
export function tearDownModule() {
// reset the root to frame for other tests
const resetFrameRoot = createTestFrameRootEntry();

View File

@@ -59,6 +59,10 @@ export class View extends ViewCommon {
if (nativeView) {
nativeView.setNeedsLayout();
}
if (this.viewController && this.viewController.view !== nativeView) {
this.viewController.view.setNeedsLayout();
}
}
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {