76 lines
2.8 KiB
TypeScript
Raw Normal View History

2016-07-08 00:31:06 +02:00
import { Cordova, Plugin } from './plugin';
2015-11-29 16:30:15 -06:00
2016-02-06 15:56:38 -06:00
/**
2016-03-13 15:45:07 -04:00
* @name Action Sheet
* @description
2016-02-06 15:56:38 -06:00
* The ActionSheet plugin shows a native list of options the user can choose from.
2016-02-18 12:01:27 -06:00
*
2016-03-07 09:04:33 +01:00
* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet).
2016-02-18 12:01:27 -06:00
*
* @usage
* ```ts
2016-02-18 12:01:27 -06:00
* import {ActionSheet} from 'ionic-native';
*
* let buttonLabels = ['Share via Facebook', 'Share via Twitter'];
* ActionSheet.show({
* 'title': 'What do you want with this image?',
* 'buttonLabels': buttonLabels,
* 'addCancelButtonWithLabel': 'Cancel',
* 'addDestructiveButtonWithLabel' : 'Delete'
* }).then(buttonIndex => {
* console.log('Button pressed: ' + buttonLabels[buttonIndex - 1]);
* });
* ```
*
2016-07-01 11:38:12 -04:00
* @advanced
* ActionSheet options
*
* | Option | Type | Description |
* |-------------------------------|-----------|----------------------------------------------|
* | title |`string` | The title for the actionsheet |
* | buttonLabels |`string[]` | the labels for the buttons. Uses the index x |
* | androidTheme |`number` | Theme to be used on Android |
* | androidEnableCancelButton |`boolean` | Enable a cancel on Android |
* | winphoneEnableCancelButton |`boolean` | Enable a cancel on Windows Phone |
* | addCancelButtonWithLabel |`string` | Add a cancel button with text |
* | addDestructiveButtonWithLabel |`string` | Add a destructive button with text |
* | position |`number[]` | On an iPad, set the X,Y position |
*
*
2016-02-06 15:56:38 -06:00
*/
2015-11-29 16:30:15 -06:00
@Plugin({
plugin: 'cordova-plugin-actionsheet',
pluginRef: 'plugins.actionsheet',
2016-03-14 13:38:35 -04:00
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet',
platforms: ['Android', 'iOS', 'Windows Phone 8']
2015-11-29 16:30:15 -06:00
})
export class ActionSheet {
2016-02-05 19:22:23 -06:00
/**
2016-07-01 11:38:12 -04:00
* Show a native ActionSheet component. See below for options.
* @param {options} Options See table below
2016-02-18 12:01:27 -06:00
* @returns {Promise} Returns a Promise that resolves with the index of the
2016-02-06 15:56:38 -06:00
* button pressed (1 based, so 1, 2, 3, etc.)
2016-02-05 19:22:23 -06:00
*/
2015-11-29 19:54:45 -06:00
@Cordova()
2016-02-05 19:22:23 -06:00
static show(options?: {
buttonLabels: string[],
title?: string,
androidTheme?: number,
androidEnableCancelButton?: boolean,
winphoneEnableCancelButton?: boolean,
addCancelButtonWithLabel?: string,
addDestructiveButtonWithLabel?: string,
position?: number[]
}): Promise<any> { return; }
2016-02-05 19:22:23 -06:00
2015-11-29 16:30:15 -06:00
2016-02-05 19:22:23 -06:00
/**
2016-07-01 11:38:12 -04:00
* Progamtically hide the native ActionSheet
* @returns {Promise} Returns a Promise that resolves when the actionsheet is closed
2016-02-05 19:22:23 -06:00
*/
2015-11-29 19:54:45 -06:00
@Cordova()
static hide(options?: any): Promise<any> { return; }
2015-11-29 16:30:15 -06:00
}