Skip to content
Open
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
11 changes: 5 additions & 6 deletions packages/imagepicker/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ImageAsset, ImageSource } from '@nativescript/core';
import { MultiResult, Result } from '@nativescript-community/perms';
import { MultiResult, Status } from '@nativescript-community/perms';

export enum ImagePickerMediaType {
Any = 0,
Expand Down Expand Up @@ -148,18 +148,17 @@ export interface ImagePickerApi {

export interface AuthorizationResult {
authorized: boolean;
details: MultiResult | Result;
details: MultiResult | Status;
}
const requestingPermissions = ['android.permission.READ_MEDIA_IMAGES', 'android.permission.READ_MEDIA_VIDEO'];

export abstract class ImagePickerBase implements ImagePickerApi {
abstract authorize(): Promise<AuthorizationResult>;
abstract present(): Promise<ImagePickerSelection[]>;
protected mapResult(result: MultiResult | Result): AuthorizationResult {
protected mapResult(result: MultiResult | Status): AuthorizationResult {
let authorized = true;
if (Array.isArray(result) && result.length == 2) {
// is of type Result
authorized = result[0] === 'authorized' || result[0] === 'limited';
if (typeof result === 'string') {
authorized = result === 'authorized' || result === 'limited';
} else {
const t = result as MultiResult;
requestingPermissions.forEach((permission) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/imagepicker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"readmeFilename": "README.md",
"bootstrapper": "@nativescript/plugin-seed",
"dependencies": {
"@nativescript-community/perms": "^2.3.1"
"@nativescript-community/perms": "^3.0.4"
}
}