From 904a51de7339bdd5d750613345a24685f4f5a954 Mon Sep 17 00:00:00 2001 From: m1ga Date: Fri, 19 Jul 2024 10:06:46 +0200 Subject: [PATCH] multi image picker --- app/controllers/phone/cameraGallery.js | 14 +++++++++++--- app/views/phone/cameraGallery.xml | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/phone/cameraGallery.js b/app/controllers/phone/cameraGallery.js index 1ee61e46..efc56b21 100644 --- a/app/controllers/phone/cameraGallery.js +++ b/app/controllers/phone/cameraGallery.js @@ -24,7 +24,10 @@ function openComponent(e) { saveToGallery(); break; case 'openFromGallery': - openFromGallery(); + openFromGallery(false); + break; + case 'openFromGalleryMulti': + openFromGallery(true); break; default: logger.log('Ti.Media', 'Unknown action selected: ' + action); @@ -106,7 +109,7 @@ function saveToGallery() { }); } -function openFromGallery() { +function openFromGallery(allowMultiple) { require('/permissions').checkCameraPermission(success => { if (!success) { alert('No permissions!'); @@ -114,9 +117,14 @@ function openFromGallery() { } Ti.Media.openPhotoGallery({ + allowMultiple: allowMultiple, success: (e) => { logger.log('Ti.Media', 'Image open successfully!'); - processImage(e.media); + if (e.images) { + processImage(e.images[0].media); + } else { + processImage(e.media); + } }, error: ({ error }) => { logger.log('Ti.Media', 'Error opening image: ' + error); diff --git a/app/views/phone/cameraGallery.xml b/app/views/phone/cameraGallery.xml index b78e45bf..c5972bb3 100644 --- a/app/views/phone/cameraGallery.xml +++ b/app/views/phone/cameraGallery.xml @@ -8,8 +8,9 @@ - + +