Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/imagepicker.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (<any>android.provider).DocumentsContract;
Expand Down Expand Up @@ -133,9 +136,9 @@ class UriHelper {
}

export class ImagePicker {
private _options;
private _options: Options;

constructor(options) {
constructor(options: Options) {
this._options = options;
}

Expand Down Expand Up @@ -226,6 +229,6 @@ export class ImagePicker {
}
}

export function create(options?): ImagePicker {
export function create(options?: Options): ImagePicker {
return new ImagePicker(options);
}
57 changes: 57 additions & 0 deletions src/imagepicker.common.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}
3 changes: 2 additions & 1 deletion src/imagepicker.ios.ts
Original file line number Diff line number Diff line change
@@ -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<any> = NSArray.arrayWithArray(<any>[
PHAssetCollectionSubtype.SmartAlbumRecentlyAdded,
Expand Down