/titanium-imagepicker

Primary LanguageSwiftApache License 2.0Apache-2.0

Titanium - Multi-Image picker module

This module uses the Matisse SDK on Android and YPImagePicker on iOS.

Important Note

This started as a parity effort via @prashantsaini1/titanium-imagepicker but as we decided to use different libraries than before (lately by using Matisse instead of an own library).

Requirements & Installation

<module platform="android">ti.imagepicker</module>
<module platform="iphone">ti.imagepicker</module>

Android:

  • Titanium 9.0.0+
  • The following in your [app]/platform/android/build.gradle (create if not exists):
    repositories {
        maven { url 'https://jitpack.io' }
    }
    
  • If you don't use a different module that includes Glide (e.g. av.imageview) you have to add it:
repositories {
	mavenCentral()
	maven { url 'https://jitpack.io' }
}
dependencies {
	implementation 'com.github.bumptech.glide:glide:4.13.2'
}

otherwise it will show "Failed resolution of: Lcom/bumptech/glide/Glide" when opening the imagepicker.

iOS:

  • Titanium 9.2.0+

Methods

openGallery()

  • Opens the inbuilt gallery with a 3x3 default grid-view.
  • Takes following arguments in a single dictionary object. (All arguments are optional though)
Argument Description Default Value Platform
String doneButtonTitle Title of the OK button which calls the callback method Done Android, iOS
String nextButtonTitle Title of the "Next" button Next iOS
String cancelButtonTitle Title of the "Cancel" button Cancel iOS
String cameraTitle Title of the "Photo" button Photo iOS
String libraryTitle Title of the "Library" button Library iOS
String albumsTitle Title of the "Albums" button Albums iOS
Bool square Use square images only false iOS
int columnCount Number of grid-view columns to show in gallery 3 (2 to 5 on Android, no limit on iOS) , iOS
int maxImageSelection Maximum number of images to select. Can be used for single image selection by passing as 1 No limit Android
function callback Callback method to get results into. See below example for its usage none Android, iOS
skipSelectionsGallery skip the selections gallery false iOS
showsPhotoFilters shows photo filters false iOS
shouldSaveNewPicturesToAlbum save new pictures to album false iOS
defaultMultipleSelection default multiple selection false iOS
enablePhoto enable or disable photo false iOS
minNumberOfItems min number of photos 1 iOS
mode image selection mode (IMAGE_PICKER_MODE_ALL _PHOTO _LIBRARY
preSelectItemOnMultipleSelection Pre-selects the current item on setting multiple selection true iOS
import ImagePicker from 'ti.imagepicker';

ImagePicker.openGallery({
  callback: function(e) {
    if (e.success) {
      var allImages = e.images;
    } else if (e.cancel) {
      // gallery result cancelled
    } else {
      alert(e.message);
    }
  }
});

Compile the iOS module

go INTO ios folder and install YPImagePicker

carthage update

build the module

ti build -p ios --build-only

LICENSE

MIT