1.1.7 • Published 3 years ago

nativescript-menu v1.1.7

Weekly downloads
102
License
MIT
Repository
-
Last release
3 years ago

nativescript-menu Build Status

A plugin that adds a pop-up menu to NativeScript

Installation

From your command prompt/terminal go to your app's root folder and execute: tns plugin add nativescript-menu

Version lower then NativeScript 7

tns plugin add nativescript-menu@1.1.6

Demo

AndroidiOS

Usage

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page"
  xmlns:ui="nativescript-menu">
  <StackLayout class="p-20">
    <Button id="menuBtn" text="getMenu" tap="{{ buttonTap }}"/>
  </StackLayout>
</Page>
import { Menu } from "nativescript-menu";

export class HelloWorldModel extends Observable {
  public message: string;
  private menu: Menu;

  constructor(public page: Page) {
    super();
  }

  buttonTap() {
    Menu.popup({
      view: this.page.getViewById("menuBtn"),
      actions: ["Example", "NativeScript", "Menu"]
    })
      .then(action => {
        alert(action.id + " - " + action.title);
      })
      .catch(console.log);
  }
}

with custom options

import { Menu } from "nativescript-menu";

export class HelloWorldModel extends Observable {
  public message: string;
  private menu: Menu;

  constructor(public page: Page) {
    super();
  }

  buttonTap() {
    Menu.popup({
      view: this.page.getViewById("menuBtn"),
      actions: [
        { id: "one", title: "Example" },
        { id: "two", title: "NativeScript", customOption: "Hello" },
        { id: "three", title: "Menu" }
      ]
    })
      .then(action => {
        alert(JSON.stringify(action));
      })
      .catch(console.log);
  }
}

API

  • MenuOptions
export interface MenuOptions {
  title?: string; // IOS Only
  message?: string; // IOS Only
  view: View;
  actions: object[] | string[];
  cancelButtonText?: string; // IOS Only
}
MethodDescription
popup(options: MenuOptions): Promise<{id: number, title: string} | actionObject | boolean>Create a pop-up menu and show it
1.1.7

3 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago