diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 3cab64e..3715b15 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -2,6 +2,9 @@ import * as application from "tns-core-modules/application"; import * as imageAssetModule from "tns-core-modules/image-asset"; import * as permissions from "nativescript-permissions"; +import { ImagePickerMediaType, Options } from "./imagepicker.common"; +export * from "./imagepicker.common"; + class UriHelper { public static _calculateFileUri(uri: android.net.Uri) { let DocumentsContract = (android.provider).DocumentsContract; @@ -133,9 +136,9 @@ class UriHelper { } export class ImagePicker { - private _options; + private _options: Options; - constructor(options) { + constructor(options: Options) { this._options = options; } @@ -226,6 +229,6 @@ export class ImagePicker { } } -export function create(options?): ImagePicker { +export function create(options?: Options): ImagePicker { return new ImagePicker(options); } diff --git a/src/imagepicker.common.ts b/src/imagepicker.common.ts new file mode 100644 index 0000000..364787e --- /dev/null +++ b/src/imagepicker.common.ts @@ -0,0 +1,57 @@ +export enum ImagePickerMediaType { + Any = 0, + Image = 1, + Video = 2 +} + +/** + * Provide options for the image picker. + */ +export interface Options { + /** + * Set the picker mode. Supported modes: "single" or "multiple" (default). + */ + mode?: string; + + /** + * Set the minumum number of selected assets in iOS + */ + minimumNumberOfSelection?: number; + + /** + * Set the maximum number of selected assets in iOS + */ + maximumNumberOfSelection?: number; + + /** + * Display the number of selected assets in iOS + */ + showsNumberOfSelectedAssets?: boolean; + + /** + * Display prompt text when selecting assets in iOS + */ + prompt?: string; + + /** + * Set the number of columns in Portrait in iOS + */ + numberOfColumnsInPortrait?: number; + + /** + * Set the number of columns in Landscape in iOS + */ + numberOfColumnsInLandscape?: number; + + /** + * Set the media type (image/video/any) to pick + */ + mediaType?: ImagePickerMediaType; + + android?: { + /** + * Provide a reason for permission request to access external storage on api levels above 23. + */ + read_external_storage?: string; + }; +} \ No newline at end of file diff --git a/src/imagepicker.ios.ts b/src/imagepicker.ios.ts index 320b503..6127e63 100644 --- a/src/imagepicker.ios.ts +++ b/src/imagepicker.ios.ts @@ -1,8 +1,9 @@ import * as data_observable from "tns-core-modules/data/observable"; import * as imageAssetModule from "tns-core-modules/image-asset"; -import { Options, ImagePickerMediaType } from "."; +import { Options, ImagePickerMediaType } from "./imagepicker.common"; import { View } from "tns-core-modules/ui/core/view/view"; import * as utils from "tns-core-modules/utils/utils"; +export * from "./imagepicker.common"; const defaultAssetCollectionSubtypes: NSArray = NSArray.arrayWithArray([ PHAssetCollectionSubtype.SmartAlbumRecentlyAdded,