How to use @nativescript/core - 10 common examples

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
//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++;
    //});

    stackLayout.addChild(btn1);

    var btn2 = new buttonModule.Button();
    btn2.text = "navigate";
    btn2.on("tap", () => {
        var nextPage = "app/tests/pages/page16";
        Frame.topmost().navigate(nextPage);
    });

    stackLayout.addChild(btn2);

    page.content = stackLayout;

    return page;
}
github NativeScript / NativeScript / tests / app / pages / page16.ts View on Github external
//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++;
    //});

    stackLayout.addChild(btn1);
github EddyVerbruggen / nativescript-bluetooth / demo / app / test-page-model.ts View on Github external
constructor(navContext) {
        super();
        this._bluetooth.debug = false;
        this.peripheral = navContext.peripheral;
        this.advertismentData = navContext.peripheral.advertismentData as AdvertismentData;
        console.log('peripheral', JSON.stringify(this.peripheral));
        console.log('advertismentData', JSON.stringify(this.advertismentData));
        console.log('serviceData', JSON.stringify(this.advertismentData.serviceData));
        console.log('uuids', this.advertismentData.serviceUUIDs);
        console.log('txPowerLevel', this.advertismentData.txPowerLevel);

        applicationOn(suspendEvent, this.onAppPause, this);
        applicationOn(resumeEvent, this.onAppResume, this);
        // console.log('localName', this.advertismentData.localName);
        // console.log('serviceUUIDs', this.advertismentData.serviceUUIDs);
        // console.log('txPowerLevel', this.advertismentData.txPowerLevel);
        // console.log('flags', this.advertismentData.flags);
        // console.log('manufacturerId', this.advertismentData.manufacturerId);
        // console.log('manufacturerData', this.advertismentData.manufacturerData);
        // console.log('serviceData', this.advertismentData.serviceData);
    }
    onAppResume(args: ApplicationEventData) {
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 / ui / frame / frame-tests-common.ts View on Github external
export function ignore_test_DummyTestForSnippetOnly4() {
    // >> frame-back
    const frame = Frame.topmost();
    frame.goBack();
    // << frame-back
}
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_inspector_ui_setAttributeAsText_set_existing_property() {
    // Arrange
    const label = new Label();

    label.text = "original label";
    const expectedValue = "updated label";

    label.ensureDomNode();

    // Act
    // simulate call from the inspector UI
    currentInspector.setAttributeAsText(label.domNode.nodeId, "text='" + expectedValue + "'", "text");

    // Assert
    assertEqual(label.text, expectedValue);
}
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_inspector_ui_setAttributeAsText_set_new_property() {
    // Arrange
    const label = new Label();
    const expectedValue = "custom";

    label.ensureDomNode();

    // Act
    // simulate call from the inspector UI
    currentInspector.setAttributeAsText(label.domNode.nodeId, "data-attr='" + expectedValue + "'" /* data-attr="custom" */, " " /* empty attr name initially */);

    // Assert
    assertEqual(label["data-attr"], expectedValue);
}
github NativeScript / NativeScript / tests / app / debugger / dom-node-tests.ts View on Github external
export function test_inspector_ui_setAttributeAsText_remove_existing_property() {
    // Arrange
    const label = new Label();
    label.text = "original label";

    label.ensureDomNode();

    // Act
    // simulate call from the inspector UI
    currentInspector.setAttributeAsText(label.domNode.nodeId, "" /* empty value - removes the attribute */, "text");

    // Assert
    assertEqual(label.text, "");
}
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 / test-runner.ts View on Github external
export function isRunningOnEmulator(): boolean {
    // These checks are not good enough to be added to modules but they keep unit tests green.

    if (platform.device.os === platform.platformNames.android) {
        return android.os.Build.FINGERPRINT.indexOf("generic") > -1 ||
            android.os.Build.HARDWARE.toLowerCase() === "goldfish" ||
            android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator
            android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 ||
            android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator
    }
    else if (platform.device.os === platform.platformNames.ios) {
        return (__dirname.search("Simulator") > -1);
    }
}