mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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:
committed by
Stanimira Vlaeva
parent
ade142fee7
commit
f1c0b85d95
@@ -10,6 +10,7 @@ export class MyControl extends stackLayoutModule.StackLayout {
|
|||||||
var counter: number = 0;
|
var counter: number = 0;
|
||||||
|
|
||||||
var lbl = new label.Label();
|
var lbl = new label.Label();
|
||||||
|
lbl.id = "my-test-label";
|
||||||
var btn = new button.Button();
|
var btn = new button.Button();
|
||||||
btn.text = "Tap me!";
|
btn.text = "Tap me!";
|
||||||
btn.on(button.Button.tapEvent, (args: observable.EventData) => {
|
btn.on(button.Button.tapEvent, (args: observable.EventData) => {
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
<GridLayout class="MyStackLayoutRoot">
|
<GridLayout class="MyStackLayoutRoot">
|
||||||
|
<Label text="I'm here!!!" id="my-test-label"/>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<TabViewItem title="Tab">
|
<TabViewItem title="Tab">
|
||||||
<TabViewItem.view>
|
<TabViewItem.view>
|
||||||
<Label text="Tab" />
|
<Label text="Tab" id="my-test-label"/>
|
||||||
</TabViewItem.view>
|
</TabViewItem.view>
|
||||||
</TabViewItem>
|
</TabViewItem>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as TKUnit from "../../TKUnit";
|
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 { Frame, NavigationEntry, stack } from "tns-core-modules/ui/frame";
|
||||||
import { _resetRootView, getRootView } from "tns-core-modules/application";
|
import { _resetRootView, getRootView } from "tns-core-modules/application";
|
||||||
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
|
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
|
||||||
@@ -65,10 +65,42 @@ export function test_gridlayout_rootview_css_applied() {
|
|||||||
helper.assertViewBackgroundColor(rootView, "#0000FF");
|
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() {
|
export function tearDownModule() {
|
||||||
// reset the root to frame for other tests
|
// reset the root to frame for other tests
|
||||||
const resetFrameRoot = createTestFrameRootEntry();
|
const resetFrameRoot = createTestFrameRootEntry();
|
||||||
|
|
||||||
_resetRootView(resetFrameRoot.entry);
|
_resetRootView(resetFrameRoot.entry);
|
||||||
TKUnit.waitUntilReady(() => resetFrameRoot.page.isLoaded);
|
TKUnit.waitUntilReady(() => resetFrameRoot.page.isLoaded);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ export class View extends ViewCommon {
|
|||||||
if (nativeView) {
|
if (nativeView) {
|
||||||
nativeView.setNeedsLayout();
|
nativeView.setNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.viewController && this.viewController.view !== nativeView) {
|
||||||
|
this.viewController.view.setNeedsLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user