Closed rdlauer closed 6 months ago
Hi @rdlauer! Indeed 2.0 and above brought a small breaking change in the return result to provide more rich information noted here:
https://github.com/NativeScript/plugins/tree/main/packages/imagepicker#installation - can see the Note
in that section.
Looking at the SB sample looks like this:
imagePicker
.authorize()
.then(() => {
return imagePicker.present();
})
.then((selection) => {
console.log('Selection done: ' + JSON.stringify(selection));
just needs to be updated to this:
imagePicker
.authorize()
.then(() => {
return imagePicker.present();
})
.then((selection) => {
console.log('Selection done: ' + JSON.stringify(selection));
this.set(
'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((item: imagePickerPlugin.ImagePickerSelection) => {
item.asset.options.width = this.isSingleMode
? this.previewSize
: this.thumbSize;
item.asset.options.height = this.isSingleMode
? this.previewSize
: this.thumbSize;
});
this.set(
'imageAssets',
selection.map((item, i) => ({ imageAsset: item.asset, index: i }))
);
})
This forked SB has the change: https://stackblitz.com/edit/nativescript-stackblitz-templates-1byxnc?file=package.json,app%2Fmain-view-model.ts
Stackblitz has a Wasm issue on file uploads at moment so if link doesn't run in Preview, you can run it locally. Let us know if that clears ya!
Dang, that was it! Thank you @NathanWalker and I have to say after coming back to {N} after all these years, the dev experience is really slick. 🙏
Thank you for confirming, let us know any other snags - your feedback is always much appreciated!
Welcome back @rdlauer 😄
It's been a while since I've done any NativeScript development! But...I'm helping on a project and using the latest version of imagepicker (3.0.1) and the exact code that's used in the TypeScript example on Stackblitz. Unfortunately in the iOS Simulator I'm hitting this error and it doesn't display the image selected:
Reverting to 1.0.9 and it works just fine.