2017-03-20 16:38:14 -04:00
import { Injectable } from '@angular/core' ;
import { Cordova , Plugin , CordovaProperty } from '@ionic-native/core' ;
2016-07-08 00:31:06 +02:00
2016-12-06 08:06:47 -05:00
export interface ActionSheetOptions {
/**
* The labels for the buttons. Uses the index x
*/
buttonLabels : string [ ] ;
/**
* The title for the actionsheet
*/
title? : string ;
2017-04-17 14:27:13 -03:00
/**
* The subtitle for the actionsheet (IOS only)
*/
2017-04-18 17:47:24 -04:00
subtitle? : string ;
2017-04-17 14:27:13 -03:00
2016-12-06 08:06:47 -05:00
/**
* Theme to be used on Android
*/
androidTheme? : number ;
/**
* Enable a cancel on Android
*/
androidEnableCancelButton? : boolean ;
/**
* Enable a cancel on Windows Phone
*/
winphoneEnableCancelButton? : boolean ;
/**
* Add a cancel button with text
*/
addCancelButtonWithLabel? : string ;
/**
* Add a destructive button with text
*/
addDestructiveButtonWithLabel? : string ;
/**
* On an iPad, set the X,Y position
*/
position? : number [ ] ;
2017-04-17 14:27:13 -03:00
/**
* Choose if destructive button will be the last
*/
2017-04-18 17:47:24 -04:00
destructiveButtonLast : boolean ;
2016-12-06 08:06:47 -05:00
}
2016-02-06 15:56:38 -06:00
/**
2016-03-13 15:45:07 -04:00
* @name Action Sheet
2016-02-22 16:20:00 -05:00
* @description
2016-12-16 14:59:11 -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
*
2016-03-12 18:30:16 -05:00
* @usage
2016-07-20 17:17:09 +02:00
* ```typescript
2017-03-20 16:38:14 -04:00
* import { ActionSheet, ActionSheetOptions } from '@ionic-native/action-sheet';
*
* constructor(private actionSheet: ActionSheet) { }
*
* ...
*
2016-07-20 17:17:09 +02:00
*
2016-02-18 12:01:27 -06:00
* let buttonLabels = ['Share via Facebook', 'Share via Twitter'];
2017-03-20 16:38:14 -04:00
*
* const options: ActionSheetOptions = {
* title: 'What do you want with this image?',
2017-04-26 23:36:01 -05:00
* subtitle: 'Choose an action',
2017-03-20 16:38:14 -04:00
* buttonLabels: buttonLabels,
* addCancelButtonWithLabel: 'Cancel',
* addDestructiveButtonWithLabel: 'Delete',
2017-04-17 14:27:13 -03:00
* androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK,
* destructiveButtonLast: true
2017-03-20 16:38:14 -04:00
* };
*
* this.actionSheet.show(options).then((buttonIndex: number) => {
2016-08-01 14:01:54 -04:00
* console.log('Button pressed: ' + buttonIndex);
2016-02-18 12:01:27 -06:00
* });
* ```
2016-12-04 13:12:42 -05:00
* @interfaces
* ActionSheetOptions
2016-02-06 15:56:38 -06:00
*/
2015-11-29 16:30:15 -06:00
@Plugin ( {
2016-10-27 12:48:50 -05:00
pluginName : 'ActionSheet' ,
2015-11-29 16:30:15 -06:00
plugin : 'cordova-plugin-actionsheet' ,
pluginRef : 'plugins.actionsheet' ,
2016-03-14 13:38:35 -04:00
repo : 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet' ,
2017-04-17 14:27:13 -03:00
platforms : [ 'Android' , 'iOS' , 'Windows Phone 8' , 'Browser' ]
2015-11-29 16:30:15 -06:00
} )
2017-03-20 16:38:14 -04:00
@Injectable ( )
2015-11-29 16:30:15 -06:00
export class ActionSheet {
2016-02-05 19:22:23 -06:00
2017-03-20 16:38:14 -04:00
@CordovaProperty
ANDROID_THEMES : {
THEME_TRADITIONAL : number ;
THEME_HOLO_DARK : number ;
THEME_HOLO_LIGHT : number ;
THEME_DEVICE_DEFAULT_DARK : number ;
THEME_DEVICE_DEFAULT_LIGHT : number ;
} ;
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.
2016-12-04 13:12:42 -05:00
* @param options {ActionSheetOptions} Options See table below
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>} 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 ( )
2017-03-20 16:38:14 -04:00
show ( options? : ActionSheetOptions ) : 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
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>} 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 ( )
2017-03-20 16:38:14 -04:00
hide ( options? : any ) : Promise < any > { return ; }
2015-11-29 16:30:15 -06:00
}