Skip to content

Commit 9cf41b8

Browse files
committed
feature: add mediaType to options in iOS
1 parent 82edc3f commit 9cf41b8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/imagepicker.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as data_observable from "tns-core-modules/data/observable";
22
import * as frame from "tns-core-modules/ui/frame";
33
import * as imageAssetModule from "tns-core-modules/image-asset";
4-
import { Options } from ".";
4+
import { Options, ImagePickerMediaType } from ".";
55

66
const defaultAssetCollectionSubtypes: NSArray<any> = NSArray.arrayWithArray(<any>[
77
PHAssetCollectionSubtype.SmartAlbumRecentlyAdded,
@@ -27,7 +27,7 @@ export class ImagePicker extends data_observable.Observable {
2727

2828
let imagePickerController = QBImagePickerController.alloc().init();
2929
imagePickerController.assetCollectionSubtypes = defaultAssetCollectionSubtypes;
30-
imagePickerController.mediaType = QBImagePickerMediaType.Image;
30+
imagePickerController.mediaType = options.mediaType ? <QBImagePickerMediaType>options.mediaType.valueOf() : QBImagePickerMediaType.Any;
3131
imagePickerController.delegate = this._imagePickerControllerDelegate;
3232
imagePickerController.allowsMultipleSelection = options.mode === 'multiple';
3333
imagePickerController.minimumNumberOfSelection = options.minimumNumberOfSelection || 0;

src/index.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export class ImagePicker {
1616
present(): Promise<ImageAsset[]>;
1717
}
1818

19+
export declare const enum ImagePickerMediaType {
20+
Any = 0,
21+
Image = 1,
22+
Video = 2
23+
}
24+
1925
/**
2026
* Provide options for the image picker.
2127
*/
@@ -49,12 +55,17 @@ interface Options {
4955
* Set the number of columns in Portrait in iOS
5056
*/
5157
numberOfColumnsInPortrait?: number;
52-
58+
5359
/**
5460
* Set the number of columns in Landscape in iOS
5561
*/
5662
numberOfColumnsInLandscape?: number;
5763

64+
/**
65+
* Set the media type (image/video/both) to pick in iOS
66+
*/
67+
mediaType?: ImagePickerMediaType;
68+
5869
android?: {
5970
/**
6071
* Provide a reason for permission request to access external storage on api levels above 23.

0 commit comments

Comments
 (0)