tests(ui-test-app): add LayoutChanged event test

This commit is contained in:
ADjenkov
2018-05-22 17:06:23 +03:00
committed by Dimitar Topuzov
parent c3a7c815e5
commit d8721c7bd8
3 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
import { Button } from "tns-core-modules/ui/button";
import { TextView } from "tns-core-modules/ui/text-view";
import { View } from "tns-core-modules/ui/core/view";
import { EventData } from "tns-core-modules/data/observable";
let buttonsCount = 1;
export function onLayoutChanged(args) {
let msg = "StackLayout layout changed - width:" + args.object.getActualSize().width;
(<TextView>args.object.page.getViewById("output")).text += msg + "\n";
}
export function addChild(args) {
let button = new Button();
button.text = "Button" + buttonsCount;
button.margin = 10;
button.backgroundColor = "lightgreen";
(<StackLayout>args.object.page.getViewById("target")).addChild(button);
buttonsCount++;
}
export function clear(args) {
(<StackLayout>args.object.page.getViewById("target")).removeChildren();
args.object.page.getViewById("output").text = "";
}

View File

@@ -0,0 +1,11 @@
<Page>
<GridLayout rows="*, *, *" >
<StackLayout horizontalAlignment="left" orientation="horizontal" backgroundColor="yellow" id="target" margin="20" layoutChanged="onLayoutChanged"/>
<StackLayout row="1">
<Button text="clear" tap="clear"/>
<Button text="add child" tap="addChild"/>
</StackLayout>
<TextView row="2" id="output" automationText="output" style="font-size: 10, font-family: monospace;"/>
</GridLayout>
</Page>

View File

@@ -19,6 +19,7 @@ export function loadExamples() {
examples.set("i61", "events/i61");
examples.set("i73", "events/i73");
examples.set("i86", "events/i86");
examples.set("layout changed", "events/layout-changed-event");
return examples;
}