feat(base64-to-gallery): add options interface

feat(base64-to-gallery): add options interface
This commit is contained in:
Daniel Sogl 2018-03-16 16:57:55 +01:00 committed by GitHub
commit 50ae6f0888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,15 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface Base64ToGalleryOptions {
/** Saved file name prefix */
prefix: string;
/**
* On Android runs Media Scanner after file creation.
* On iOS if true the file will be added to camera roll, otherwise will be saved to a library folder.
*/
mediaScanner: boolean;
}
/** /**
* @name Base64 To Gallery * @name Base64 To Gallery
@ -19,6 +29,8 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
* err => console.log('Error saving image to gallery ', err) * err => console.log('Error saving image to gallery ', err)
* ); * );
* ``` * ```
* @interfaces
* Base64ToGalleryOptions
*/ */
@Plugin({ @Plugin({
pluginName: 'Base64ToGallery', pluginName: 'Base64ToGallery',
@ -29,19 +41,20 @@ import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
}) })
@Injectable() @Injectable()
export class Base64ToGallery extends IonicNativePlugin { export class Base64ToGallery extends IonicNativePlugin {
/** /**
* Converts a base64 string to an image file in the device gallery * Converts a base64 string to an image file in the device gallery
* @param {string} data The actual base64 string that you want to save * @param {string} data The actual base64 string that you want to save
* @param {any} [options] An object with properties: prefix: string, mediaScanner: boolean. Prefix will be prepended to the filename. If true, mediaScanner runs Media Scanner on Android and saves to Camera Roll on iOS; if false, saves to Library folder on iOS. * @param {any} [options] An object with properties
* @returns {Promise<any>} returns a promise that resolves when the image is saved. * @returns {Promise<any>} returns a promise that resolves when the image is saved.
*/ */
@Cordova({ @Cordova({
successIndex: 2, successIndex: 2,
errorIndex: 3 errorIndex: 3
}) })
base64ToGallery(data: string, options?: { prefix?: string; mediaScanner?: boolean }): Promise<any> { base64ToGallery(
data: string,
options?: Base64ToGalleryOptions
): Promise<any> {
return; return;
} }
} }