How to use the @nativescript/core/ui/layouts/stack-layout.StackLayout function in @nativescript/core

To help you get started, we’ve selected a few @nativescript/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / NativeScript / tests / app / pages / page16.ts View on Github external
//iconItem.text = "TEST";

    //iconItem.icon = "~/app" + "/tests" + "/test-icon.png"; // use + to stop regex replace during build
    //iconItem.on("tap", () => {
    //    console.log("Icon item tapped");
    //});
    //page.optionsMenu.addItem(iconItem);

    //var textItem = new pageModule.MenuItem();
    //textItem.text = "SAVE";
    //textItem.on("tap", () => {
    //    console.log("Save item tapped");
    //});
    //page.optionsMenu.addItem(textItem);

    var stackLayout = new stackModule.StackLayout();
    //var count = 0;
    var btn1 = new buttonModule.Button();
    btn1.text = "add item";
    //btn1.on("tap", () => {
    //    console.log("adding menu item");

    //    var newItem = new pageModule.MenuItem();
    //    var text =  "item " + count;
    //    newItem.text = text
    //    newItem.on("tap", () => {
    //        console.log("ITEM [" + text + "] tapped");
    //    });
    //    page.optionsMenu.addItem(newItem);
    //    count++;
    //});
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_childNodeInserted_at_index_in_dom_node() {
    const stack = new StackLayout();
    stack.ensureDomNode();

    // child index 0
    const btn1 = new Button();
    btn1.text = "button1";
    stack.addChild(btn1);

    // child index 1
    const btn2 = new Button();
    btn2.text = "button2";
    stack.addChild(btn2);

    // child index 2
    const btn3 = new Button();
    btn3.text = "button3";
    stack.addChild(btn3);
github NativeScript / NativeScript / tests / app / ui-helper.ts View on Github external
export function do_PageTest_WithStackLayout_AndButton(test: (views: [Page, StackLayout, Button, ActionBar]) => void) {
    clearPage();
    let newPage = getCurrentPage();
    let stackLayout = new StackLayout();
    let btn = new Button();
    stackLayout.addChild(btn);
    newPage.content = stackLayout;
    test([newPage, stackLayout, btn, newPage.actionBar]);
    newPage.content = null;
}
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_childNodeRemoved_in_dom_node() {
    let childNodeRemovedCalled = false;
    let actualRemovedNodeId = 0;
    let expectedRemovedNodeId = 0;

    currentInspector.childNodeRemoved = (parentId, nodeId) => {
        childNodeRemovedCalled = true;
        actualRemovedNodeId = nodeId;
    };

    const stack = new StackLayout();
    stack.ensureDomNode();

    const btn1 = new Button();
    btn1.text = "button1";
    expectedRemovedNodeId = btn1._domId;
    stack.addChild(btn1);

    const btn2 = new Button();
    btn2.text = "button2";
    stack.addChild(btn2);

    stack.removeChild(btn1);
    console.log("btn2: " + btn2);

    assert(childNodeRemovedCalled, "global inspector childNodeRemoved not called.");
    assertEqual(actualRemovedNodeId, expectedRemovedNodeId);
github NativeScript / NativeScript / tests / app / pages / page15.ts View on Github external
export function createPage() {
    var page = new pageModule.Page();
    var stackLayout = new stackModule.StackLayout();
    var btn1 = new buttonModule.Button();
    btn1.horizontalAlignment = "left";
    btn1.verticalAlignment = "top";
    btn1.marginTop = 10;
    btn1.marginRight = 0;
    btn1.marginBottom = 10;
    btn1.marginLeft = 20;
    btn1.text = "top, left";

    var btn2 = new buttonModule.Button();
    btn2.horizontalAlignment = "center";
    btn2.verticalAlignment = "middle";
    btn2.text = "center, center";

    var btn3 = new buttonModule.Button();
    btn3.horizontalAlignment = "right";
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_inspector_ui_removeNode() {
    let childNodeRemovedCalled = false;
    let stack = new StackLayout();
    let label = new Label();
    stack.addChild(label);

    stack.ensureDomNode();
    label.ensureDomNode();

    let expectedParentId = stack.domNode.nodeId;
    let expectedNodeId = label.domNode.nodeId;

    currentInspector.childNodeRemoved = (parentId, nodeId) => {
        childNodeRemovedCalled = true;
        assertEqual(parentId, expectedParentId);
        assertEqual(nodeId, expectedNodeId);
    };

    currentInspector.removeNode(label.domNode.nodeId);
github NativeScript / NativeScript / tests / app / test-runner.ts View on Github external
function showReportPage(finalMessage: string) {
    const stack = new StackLayout();
    const btn = new Button();
    btn.text = "Rerun tests";
    btn.on("tap", () => runAll(testsSelector));
    stack.addChild(btn);

    const messageContainer = new TextView();
    messageContainer.editable = messageContainer.autocorrect = false;
    messageContainer.text = finalMessage;
    stack.addChild(messageContainer);

    Frame.topmost().navigate({
        create: () => {
            const page = new Page();
            page.content = stack;
            messageContainer.focus();
            page.style.fontSize = 11;
github NativeScript / NativeScript / tests / app / ui / styling / value-source-tests.ts View on Github external
export var test_value_Inherited_stronger_than_Default = function () {
    let page = helper.getCurrentPage();
    let btn = new button.Button();
    let testStack = new stack.StackLayout();
    page.content = testStack;
    testStack.addChild(btn);
    page.css = "stackLayout { color: red; }";
    helper.assertViewColor(btn, "#FF0000");
    page.css = "";
};
github NativeScript / NativeScript / tests / app / pages / page11.ts View on Github external
export function createPage() {
    var StackLayout = new sp.StackLayout();
    var grid = new gridModule.GridLayout();
    grid.horizontalAlignment = "left";

    StackLayout.addChild(grid);

    var btn1 = new button.Button();
    btn1.text = "btn1";
    var btn2 = new button.Button();
    btn2.text = "btn2";
    var btn3 = new button.Button();
    btn3.text = "btn3";
    var btn4 = new button.Button();
    btn4.text = "btn4";

    grid.addChild(btn2);
    grid.addChild(btn3);