diff --git a/apps/demo-angular/project.json b/apps/demo-angular/project.json index 57eebe49..70452a08 100644 --- a/apps/demo-angular/project.json +++ b/apps/demo-angular/project.json @@ -21,10 +21,9 @@ } ] }, - "ios": { - "executor": "@nativescript/nx:build", + "debug": { + "executor": "@nativescript/nx:debug", "options": { - "platform": "ios", "noHmr": true }, "dependsOn": [ @@ -34,10 +33,9 @@ } ] }, - "android": { - "executor": "@nativescript/nx:build", + "prepare": { + "executor": "@nativescript/nx:prepare", "options": { - "platform": "android", "noHmr": true }, "dependsOn": [ @@ -48,10 +46,8 @@ ] }, "clean": { - "executor": "@nativescript/nx:build", - "options": { - "clean": true - } + "executor": "@nativescript/nx:clean", + "options": {} }, "lint": { "executor": "@nx/linter:eslint", diff --git a/apps/demo-angular/src/plugin-demos/imagepicker.component.html b/apps/demo-angular/src/plugin-demos/imagepicker.component.html index 31dbee8c..b28808e4 100644 --- a/apps/demo-angular/src/plugin-demos/imagepicker.component.html +++ b/apps/demo-angular/src/plugin-demos/imagepicker.component.html @@ -5,7 +5,7 @@ - + diff --git a/apps/demo-angular/src/plugin-demos/imagepicker.component.ts b/apps/demo-angular/src/plugin-demos/imagepicker.component.ts index 72480a7b..493b611d 100644 --- a/apps/demo-angular/src/plugin-demos/imagepicker.component.ts +++ b/apps/demo-angular/src/plugin-demos/imagepicker.component.ts @@ -1,14 +1,14 @@ import { Component, NgZone } from '@angular/core'; -import { ImageAsset } from '@nativescript/core'; -import * as imagepicker from '@nativescript/imagepicker'; +import { ImageAsset, ImageSource } from '@nativescript/core'; +import { ImagePicker, create, ImagePickerSelection } from '@nativescript/imagepicker'; @Component({ selector: 'demo-imagepicker', templateUrl: 'imagepicker.component.html', }) export class ImagepickerComponent { - imageAssets = []; - imageSrc: any; + imageAssets: ImagePickerSelection[] = []; + imageSrc: ImageAsset | ImageSource; isSingleMode: boolean = true; thumbSize: number = 80; previewSize: number = 300; @@ -18,7 +18,7 @@ export class ImagepickerComponent { public onSelectMultipleTap() { this.isSingleMode = false; - let context = imagepicker.create({ + let context = create({ mode: 'multiple', }); this.startSelection(context); @@ -27,36 +27,40 @@ export class ImagepickerComponent { public onSelectSingleTap() { this.isSingleMode = true; - let context = imagepicker.create({ + let context = create({ mode: 'single', }); this.startSelection(context); } - private startSelection(context) { + private startSelection(context: ImagePicker) { context .authorize() - .then(() => { + .then((authResult) => { this._ngZone.run(() => { this.imageAssets = []; this.imageSrc = null; }); - return context.present(); - }) - .then((selection) => { - this._ngZone.run(() => { - console.log('Selection done: ' + JSON.stringify(selection)); - this.imageSrc = this.isSingleMode && selection.length > 0 ? selection[0] : null; + if (authResult.authorized) { + return context.present().then((selection) => { + this._ngZone.run(() => { + console.log('Selection done: ' + JSON.stringify(selection)); + this.imageSrc = this.isSingleMode && selection.length > 0 ? selection[0].asset : null; - // set the images to be loaded from the assets with optimal sizes (optimize memory usage) - selection.forEach((el: ImageAsset) => { - el.options.width = this.isSingleMode ? this.previewSize : this.thumbSize; - el.options.height = this.isSingleMode ? this.previewSize : this.thumbSize; - }); + // set the images to be loaded from the assets with optimal sizes (optimize memory usage) + selection.forEach((el) => { + el.asset.options.width = this.isSingleMode ? this.previewSize : this.thumbSize; + el.asset.options.height = this.isSingleMode ? this.previewSize : this.thumbSize; + }); - this.imageAssets = selection; - }); + this.imageAssets = selection; + }); + }); + } else { + console.log('Unauthorised'); + } }) + .catch(function (e) { console.log(e); }); diff --git a/apps/demo/project.json b/apps/demo/project.json index 55887d78..75cce95b 100644 --- a/apps/demo/project.json +++ b/apps/demo/project.json @@ -21,10 +21,9 @@ } ] }, - "ios": { - "executor": "@nativescript/nx:build", + "debug": { + "executor": "@nativescript/nx:debug", "options": { - "platform": "ios", "noHmr": true }, "dependsOn": [ @@ -34,10 +33,9 @@ } ] }, - "android": { - "executor": "@nativescript/nx:build", + "prepare": { + "executor": "@nativescript/nx:prepare", "options": { - "platform": "android", "noHmr": true }, "dependsOn": [ @@ -48,10 +46,8 @@ ] }, "clean": { - "executor": "@nativescript/nx:build", - "options": { - "clean": true - } + "executor": "@nativescript/nx:clean", + "options": {} }, "lint": { "executor": "@nx/linter:eslint", diff --git a/apps/demo/src/main-page.xml b/apps/demo/src/main-page.xml index 3f2c4c7d..4e542f5f 100644 --- a/apps/demo/src/main-page.xml +++ b/apps/demo/src/main-page.xml @@ -27,21 +27,18 @@