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

fix(layout): IOS Layout not invalidated with custom root by vakrilov · Pull Request #5724 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (3) .xml  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions tests/app/ui/root-view/mymodule/MyControl.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<GridLayout class="MyStackLayoutRoot">
<Label text="I'm here!!!" id="my-test-label"/>
</GridLayout>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<TabViewItem title="Tab">
<TabViewItem.view>
<Label text="Tab" />
<Label text="Tab" id="my-test-label"/>
</TabViewItem.view>
</TabViewItem>

Expand Down
36 changes: 34 additions & 2 deletions tests/app/ui/root-view/root-view-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -65,10 +65,42 @@ 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();

_resetRootView(resetFrameRoot.entry);
TKUnit.waitUntilReady(() => resetFrameRoot.page.isLoaded);
}
}
4 changes: 4 additions & 0 deletions tns-core-modules/ui/core/view/view.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

Back | FazBrowse Home | New Git URL