Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xlmnxp/nativescript-menu

A plugin that adds a pop-up menu to NativeScript
https://github.com/xlmnxp/nativescript-menu

android ios menu nativescript nativescript-plugin popup

Last synced: 3 months ago
JSON representation

A plugin that adds a pop-up menu to NativeScript

Awesome Lists containing this project

README

        

# nativescript-menu [![Build Status](https://travis-ci.org/xlmnxp/nativescript-menu.svg?branch=master)](https://travis-ci.org/xlmnxp/nativescript-menu)

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 [email protected]`

## Demo

| Android | iOS |
| ------------ | ------------ |
| screenshot 1 | screenshot 2 |

## Usage

###

```XML



```

```typescript
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

```typescript
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

```typescript
export interface MenuOptions {
title?: string; // IOS Only
message?: string; // IOS Only
view: View;
actions: object[] | string[];
cancelButtonText?: string; // IOS Only
}
```

| Method | Description |
| ------------------------------------------------------------------------------------------------ | -------------------------------- |
| **popup(options: MenuOptions)**: Promise<{id: number, title: string} \| actionObject \| boolean> | Create a pop-up menu and show it |