Files
NativeScript/apps/ui/app/events/layout-changed-event-page.ts
Nathan Walker 1e6fccf272 chore: cleanup
2020-07-23 14:03:37 -07:00

25 lines
825 B
TypeScript

import { StackLayout } from '@nativescript/core/ui/layouts/stack-layout';
import { Button } from '@nativescript/core/ui/button';
import { TextView } from '@nativescript/core/ui/text-view';
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 = '';
}