Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/xlmnxp/nativescript-menu
- Owner: xlmnxp
- License: mit
- Created: 2018-09-13T22:53:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-29T09:27:36.000Z (over 1 year ago)
- Last Synced: 2024-09-26T09:21:53.199Z (3 months ago)
- Topics: android, ios, menu, nativescript, nativescript-plugin, popup
- Language: TypeScript
- Homepage:
- Size: 5.52 MB
- Stars: 20
- Watchers: 5
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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 |
| ------------ | ------------ |
| | |## 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 |