2015-11-30 06:30:15 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
2016-02-07 05:56:38 +08:00
|
|
|
/**
|
|
|
|
* The ActionSheet plugin shows a native list of options the user can choose from.
|
|
|
|
*/
|
2015-11-30 06:30:15 +08:00
|
|
|
@Plugin({
|
|
|
|
name: 'ActionSheet',
|
|
|
|
plugin: 'cordova-plugin-actionsheet',
|
|
|
|
pluginRef: 'plugins.actionsheet',
|
|
|
|
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet'
|
|
|
|
})
|
|
|
|
export class ActionSheet {
|
2016-02-06 09:22:23 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the ActionSheet.
|
|
|
|
* @param {options}
|
|
|
|
* Available options:
|
|
|
|
* buttonLabels: string[]
|
|
|
|
* title: string
|
|
|
|
* androidTheme (Android only): number 1-5
|
|
|
|
* androidEnableCancelButton (Android only): boolean, default false
|
|
|
|
* winphoneEnableCancelButton (WP only): boolean, default false
|
|
|
|
* addCancelButtonWithLabel: string
|
|
|
|
* addDestructiveButtonWithLabel: string
|
|
|
|
* position: [x, y] (iPad pass in [x, y] coords of popover)
|
2016-02-07 05:56:38 +08:00
|
|
|
* @returns {Promise} returns a promise that resolves with the index of the
|
|
|
|
* button pressed (1 based, so 1, 2, 3, etc.)
|
2016-02-06 09:22:23 +08:00
|
|
|
*/
|
2015-11-30 09:54:45 +08:00
|
|
|
@Cordova()
|
2016-02-06 09:22:23 +08:00
|
|
|
static show(options?: {
|
|
|
|
buttonLabels: string[],
|
|
|
|
title?: string,
|
|
|
|
androidTheme?: number,
|
|
|
|
androidEnableCancelButton?: boolean,
|
|
|
|
winphoneEnableCancelButton?: boolean,
|
|
|
|
addCancelButtonWithLabel?: string,
|
|
|
|
addDestructiveButtonWithLabel?: string,
|
|
|
|
position?: number[]
|
2016-02-07 05:56:38 +08:00
|
|
|
}) {
|
|
|
|
// This Promise is replaced by one from the @Cordova decorator that wraps
|
|
|
|
// the plugin's callbacks. We provide a dummy one here so TypeScript
|
|
|
|
// knows that the correct return type is Promise, because there's no way
|
|
|
|
// for it to know the return type from a decorator.
|
|
|
|
// See https://github.com/Microsoft/TypeScript/issues/4881
|
|
|
|
return new Promise<any>((res, rej) => {});
|
2016-02-06 09:22:23 +08:00
|
|
|
};
|
|
|
|
|
2015-11-30 06:30:15 +08:00
|
|
|
|
2016-02-06 09:22:23 +08:00
|
|
|
/**
|
|
|
|
* Hide the ActionSheet.
|
|
|
|
*/
|
2015-11-30 09:54:45 +08:00
|
|
|
@Cordova()
|
2016-02-07 05:56:38 +08:00
|
|
|
static hide() {
|
|
|
|
// This Promise is replaced by one from the @Cordova decorator that wraps
|
|
|
|
// the plugin's callbacks. We provide a dummy one here so TypeScript
|
|
|
|
// knows that the correct return type is Promise, because there's no way
|
|
|
|
// for it to know the return type from a decorator.
|
|
|
|
// See https://github.com/Microsoft/TypeScript/issues/4881
|
|
|
|
return new Promise<any>((res, rej) => {});
|
2016-02-06 09:22:23 +08:00
|
|
|
};
|
2015-11-30 06:30:15 +08:00
|
|
|
}
|