2016-07-18 01:56:02 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
|
|
|
|
2016-03-11 04:29:50 +08:00
|
|
|
|
|
|
|
export interface ImagePickerOptions {
|
2016-10-14 18:44:57 +08:00
|
|
|
/**
|
|
|
|
* max images to be selected, defaults to 15. If this is set to 1, upon selection of a single image, the plugin will return it.
|
|
|
|
*/
|
2016-07-18 01:56:02 +08:00
|
|
|
maximumImagesCount?: number;
|
2016-03-11 04:29:50 +08:00
|
|
|
|
2016-10-14 18:44:57 +08:00
|
|
|
/**
|
|
|
|
* Max width to allow images to be
|
|
|
|
*/
|
2016-07-18 01:56:02 +08:00
|
|
|
width?: number;
|
2016-10-14 18:44:57 +08:00
|
|
|
/**
|
|
|
|
* Max height to allow images to be
|
|
|
|
*/
|
2016-07-18 01:56:02 +08:00
|
|
|
height?: number;
|
2016-03-11 04:29:50 +08:00
|
|
|
|
2016-10-14 18:44:57 +08:00
|
|
|
/**
|
|
|
|
* Quality of images, defaults to 100
|
|
|
|
*/
|
2016-07-18 01:56:02 +08:00
|
|
|
quality?: number;
|
2016-03-11 04:29:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-14 03:45:07 +08:00
|
|
|
* @name Image Picker
|
2016-03-11 04:29:50 +08:00
|
|
|
* @description
|
|
|
|
* Cordova Plugin For Multiple Image Selection
|
|
|
|
*
|
|
|
|
* Requires Cordova plugin: `cordova-plugin-image-picker`.
|
|
|
|
* For more info, please see the https://github.com/wymsee/cordova-imagePicker
|
|
|
|
*
|
|
|
|
* @usage
|
2016-07-20 23:17:09 +08:00
|
|
|
* ```typescript
|
|
|
|
* import { ImagePicker } from 'ionic-native';
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2016-03-11 07:59:14 +08:00
|
|
|
* ImagePicker.getPictures(options).then((results) => {
|
2016-03-11 04:29:50 +08:00
|
|
|
* for (var i = 0; i < results.length; i++) {
|
|
|
|
* console.log('Image URI: ' + results[i]);
|
|
|
|
* }
|
2016-07-20 23:17:09 +08:00
|
|
|
* }, (err) => { });
|
2016-03-11 04:29:50 +08:00
|
|
|
* ```
|
2016-10-14 18:44:57 +08:00
|
|
|
* @interfaces
|
|
|
|
* ImagePickerOptions
|
2016-03-11 04:29:50 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-18 09:33:17 +08:00
|
|
|
name: 'ImagePicker',
|
2016-03-11 04:29:50 +08:00
|
|
|
plugin: 'cordova-plugin-image-picker',
|
2016-03-11 04:39:14 +08:00
|
|
|
pluginRef: 'window.imagePicker',
|
2016-03-11 04:29:50 +08:00
|
|
|
repo: 'https://github.com/wymsee/cordova-imagePicker'
|
|
|
|
})
|
|
|
|
export class ImagePicker {
|
|
|
|
/**
|
|
|
|
* Pick pictures from the library.
|
|
|
|
* @param {ImagePickerOptions} options
|
|
|
|
* @return Returns a Promise that resolves the image file URI
|
|
|
|
* otherwise rejects with an error.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
callbackOrder: 'reverse'
|
|
|
|
})
|
2016-04-30 11:56:49 +08:00
|
|
|
static getPictures(options: ImagePickerOptions): Promise<any> { return; }
|
2016-07-18 01:56:02 +08:00
|
|
|
|
2016-10-14 18:48:57 +08:00
|
|
|
/**
|
|
|
|
* Check if we have permission to read images
|
|
|
|
* @returns {Promise<boolean>} Returns a promise that resolves with a boolean that indicates whether we have permission
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
platforms: ['Android']
|
|
|
|
})
|
|
|
|
static hasReadPermission(): Promise<boolean> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request permission to read images
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
platforms: ['Android']
|
|
|
|
})
|
|
|
|
static requestReadPermission(): Promise<any> { return; }
|
|
|
|
|
2016-03-11 04:29:50 +08:00
|
|
|
}
|