Compare commits

..

39 Commits

Author SHA1 Message Date
marcosrdz
3e343152a6 Merge remote-tracking branch 'upstream/master' 2020-08-10 19:28:32 -04:00
Janic Duplessis
b7a89e3d3b 2.3.3 2020-07-13 13:44:38 -04:00
Jafar Jabr
be1a4980e3
remove deprecated gradle option (#1390)
remove The option 'android.enableUnitTestBinaryResources' is deprecated
which removed from gradle 4, The current default is 'false'
to allow the build using gradle 4
2020-07-13 13:42:09 -04:00
Marcos Rodriguez Vélez
da9bd7db9d
Update ImagePickerManager.m 2020-07-11 23:28:19 -04:00
Marcos Rodriguez Vélez
5bcf00fd6a
Use Catalyst if Target 2020-07-11 00:21:04 -04:00
Marcos Rodriguez Vélez
be4bca9225
Remove Code that blocks from compiling with Catalyst. 2020-07-10 20:35:41 -04:00
Janic Duplessis
e99b8bb5be 2.3.2 2020-07-06 13:46:13 -04:00
Andrei Tofan
18ee85b339
Make sure the calls are execute on the main thread (#1265)
* Make sure the calls are execute on the main thread

* Fix formatting

* Wrap method calls

Co-authored-by: Andrei Tofan <andrei@optinify.io>
2020-07-06 13:43:30 -04:00
Akhmad Syaikhul Hadi
38db13aeb6 Fix failure delivering result info #579 2020-05-07 08:13:08 +02:00
Evan Bacon
3b9cf0347b Update README.md 2020-05-06 14:59:26 +02:00
Ulf Andersson
d3a7ed2ca0 test: Make tests work with >=Java9 by upgrading libraries
- Upgrade RoboElectric from 3.3.2 => 4.3.1
- Upgrade PowerMock from 1.6.2 => 1.6.6
- Removed unused fest-assert-core
- Remove explicit mockito, junit and assertj dependencies, correct
versions are pulled in as transitive depedencies by RoboElectric
2020-05-04 07:33:54 +02:00
Johan du Toit
a2626b3760
Add help wanted notification 2020-04-30 13:03:32 +02:00
Janic Duplessis
a40e85bfc9 2.3.1 2020-02-26 10:28:12 -06:00
Marcus Bergholm
54d62aca89
Add write permission check when accessing camera android (#1295) 2020-02-26 10:26:40 -06:00
Johan Du toit
5ec8f8d9fe 2.3.0 2020-02-10 09:29:12 +02:00
Levi
5368e2acc8 fix documentation 2020-02-10 09:27:16 +02:00
Levi
14be039814 clean up 2020-02-10 09:27:16 +02:00
Levi
6005f36dd7 allow android to save photos to private directory 2020-02-10 09:27:16 +02:00
Johan Du toit
8213cff3dd 2.2.1 2020-01-28 08:31:39 +02:00
Jeff Algera
2ad856a1a7 Code review
Copy the file only if we cannot move it.
2020-01-28 08:11:37 +02:00
Jeff Algera
49e6a775cc Copy file instead of move
iOS 13 beta is not allowing the `moveItemAtURL` command to execute which may cause trimmed clips to fail based on permission.

Instead of moving the file, copy it.
2020-01-28 08:11:37 +02:00
Johan Du toit
d1423768c7 2.2.0 2020-01-22 09:24:51 +02:00
Nathan Greene
eab19caa19 fix: Having a space in the filename on android no longer causes the filetype to be null 2020-01-22 09:21:02 +02:00
Johan-dutoit
bcbde0fa1f 📗 2020-01-21 06:27:41 +02:00
Chris
5d1feb500b fix: issue#1252 - if target is running iOS 11 or greater, do not reference deprecated PhotoKit api 2020-01-21 06:22:09 +02:00
aschnapp
4e699d3a59 use system default picker text color 2020-01-10 10:49:09 +02:00
lizraeli
cd69e948d0 remove commented code 2020-01-09 11:39:53 +02:00
lizraeli
ac142cf9cd Add break statements in switch 2020-01-09 11:39:53 +02:00
Lev Izraelit
997c272f78 Split permission requests for Camera & Gallery 2020-01-09 11:39:53 +02:00
Erik Haider Forsén
085d0b7d08 docs: adds tintColor to API Reference 2019-09-23 15:45:38 +01:00
Johan-dutoit
341e95491b docs (readme): improved linking details 2019-09-05 11:42:50 +01:00
Johan-dutoit
5d1ff8566b docs (readme): improved linking details 2019-09-05 11:23:05 +01:00
Johan-dutoit
5281955b2c 📖 2019-08-30 13:57:42 +01:00
Johan-dutoit
90e7004668 1.1.0 2019-08-30 13:52:33 +01:00
Johan-dutoit
134c5b485b chore(cleanup): Apply prettier 2019-08-30 13:38:24 +01:00
Ryan Nickel
0028ebf64d feat(ios): add support for tintColor 2019-08-30 13:34:29 +01:00
Johan Forslund
aacf1b2d5b fix(android): Support devices with multiple gallery apps 2019-08-30 13:33:06 +01:00
Tomas Harkema
e9e0f87a2a fix(permissions): iOS 11+ doesn't need permissions for picking a single image 2019-08-30 13:32:06 +01:00
hossamnasser938
454fff34df feat(mixed): add support for android 2019-08-29 16:29:05 +01:00
72 changed files with 24554 additions and 11208 deletions

View File

@ -1,23 +0,0 @@
{
"extends": "@react-native-community",
"env": {
"es6": true,
"jest": true
},
"globals": {
"it": true,
"expect": true,
"element": true,
"describe": true,
"by": true,
"device": true,
"beforeAll": true,
"beforeEach": true,
"afterAll": true,
"jest": true,
"jasmine": true
},
"rules": {
"no-dupe-class-members": "off"
}
}

52
.eslintrc.js Normal file
View File

@ -0,0 +1,52 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin/dist/configs/recommended.json');
const typescriptEslintPrettier = require('eslint-config-prettier/@typescript-eslint');
module.exports = {
extends: ['@react-native-community'],
overrides: [
{
files: ['*.ts', '*.tsx'],
// Apply the recommended Typescript defaults and the prettier overrides to all Typescript files
rules: Object.assign(
typescriptEslintRecommended.rules,
typescriptEslintPrettier.rules,
{
'@typescript-eslint/explicit-member-accessibility': 'off',
},
),
},
{
files: ['example/**/*.ts', 'example/**/*.tsx'],
rules: {
// Turn off rules which are useless and annoying for the example files files
'@typescript-eslint/explicit-function-return-type': 'off',
'react-native/no-inline-styles': 'off',
},
},
{
files: ['**/__tests__/**/*.ts', '**/*.spec.ts'],
env: {
jest: true,
},
rules: {
// Turn off rules which are useless and annoying for unit test files
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
rules: {
'no-dupe-class-members': 'off',
},
},
],
};

1
.gitignore vendored
View File

@ -31,7 +31,6 @@ project.xcworkspace
# CocoaPods
/ios/Pods/
example/ios/Pods/
# Android/IntelliJ
#

View File

@ -8,6 +8,11 @@
A React Native module that allows you to use native UI to select a photo/video from the device library or directly from the camera, like so:
🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
🚧🚧🚧🚧[Help & Input Wanted](https://github.com/react-native-community/react-native-image-picker/issues/1358) 🚧🚧🚧🚧
🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
| iOS | Android |
| --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| <img title="iOS" src="https://github.com/react-community/react-native-image-picker/blob/master/images/ios-image.png"> | <img title="Android" src="https://github.com/react-community/react-native-image-picker/blob/master/images/android-image.png"> |
@ -31,6 +36,11 @@ p.s. React Native introduced AndroidX support in 0.60, which is a **breaking cha
```
yarn add react-native-image-picker
# RN >= 0.60
npx pod-install
# RN < 0.60
react-native link react-native-image-picker
```

View File

@ -30,6 +30,12 @@ android {
lintOptions {
abortOnError false
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
repositories {
@ -47,13 +53,13 @@ repositories {
dependencies {
api "com.facebook.react:react-native:+" // From node_modules
testImplementation "junit:junit:4.10"
testImplementation "org.assertj:assertj-core:1.7.0"
testImplementation "org.robolectric:robolectric:3.3.2"
testImplementation('org.robolectric:robolectric:4.3.1') {
// https://github.com/robolectric/robolectric/issues/5245
exclude group: 'com.google.auto.service', module: 'auto-service'
}
testImplementation "org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}"
testImplementation "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}"
testImplementation "org.powermock:powermock-module-junit4:${POWERMOCK_VERSION}"
testImplementation "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
testImplementation "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
testImplementation "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
}

View File

@ -1,6 +1,4 @@
MOCKITO_CORE_VERSION=1.+
POWERMOCK_VERSION=1.6.2
FEST_ASSERT_CORE_VERSION=2.0M10
POWERMOCK_VERSION=1.6.6
ReactNativeImagePicker_compileSdkVersion=28
ReactNativeImagePicker_buildToolsVersion=28.0.3
@ -8,4 +6,4 @@ ReactNativeImagePicker_targetSdkVersion=27
ReactNativeImagePicker_minSdkVersion=16
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true

View File

@ -35,6 +35,7 @@ import com.imagepicker.media.ImageConfig;
import com.imagepicker.permissions.PermissionUtils;
import com.imagepicker.permissions.OnImagePickerPermissionsCallback;
import com.imagepicker.utils.MediaUtils.ReadExifResult;
import com.imagepicker.utils.ReadableMapUtils;
import com.imagepicker.utils.RealPathUtil;
import com.imagepicker.utils.UI;
@ -75,10 +76,13 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
private final int dialogThemeId;
protected Callback callback;
private Callback permissionRequestCallback;
private ReadableMap options;
protected Uri cameraCaptureURI;
private Boolean noData = false;
private Boolean pickVideo = false;
private Boolean pickBoth = false;
private ImageConfig imageConfig = new ImageConfig(null, null, 0, 0, 100, 0, false);
@Deprecated
@ -108,18 +112,18 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
if (!permissionsGranted)
{
responseHelper.invokeError(callback, "Permissions weren't granted");
responseHelper.invokeError(permissionRequestCallback, "Permissions weren't granted");
return false;
}
switch (requestCode)
{
case REQUEST_PERMISSIONS_FOR_CAMERA:
launchCamera(options, callback);
launchCamera(options, permissionRequestCallback);
break;
case REQUEST_PERMISSIONS_FOR_LIBRARY:
launchImageLibrary(options, callback);
launchImageLibrary(options, permissionRequestCallback);
break;
}
@ -224,6 +228,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@ReactMethod
public void launchCamera(final ReadableMap options, final Callback callback)
{
permissionRequestCallback = callback;
if (!isCameraAvailable())
{
responseHelper.invokeError(callback, "Camera not available");
@ -318,6 +324,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@ReactMethod
public void launchImageLibrary(final ReadableMap options, final Callback callback)
{
permissionRequestCallback = callback;
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
responseHelper.invokeError(callback, "can't find current Activity");
@ -347,6 +355,11 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
requestCode = REQUEST_LAUNCH_IMAGE_LIBRARY;
libraryIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if (pickBoth)
{
libraryIntent.setType("image/* video/*");
}
}
if (libraryIntent.resolveActivity(reactContext.getPackageManager()) == null)
@ -357,7 +370,13 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
try
{
currentActivity.startActivityForResult(libraryIntent, requestCode);
String chooseWhichLibraryTitle = null;
if (ReadableMapUtils.hasAndNotEmptyString(options, "chooseWhichLibraryTitle"))
{
chooseWhichLibraryTitle = options.getString("chooseWhichLibraryTitle");
}
currentActivity.startActivityForResult(Intent.createChooser(libraryIntent, chooseWhichLibraryTitle), requestCode);
}
catch (ActivityNotFoundException e)
{
@ -557,10 +576,18 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
final int cameraPermission = ActivityCompat
.checkSelfPermission(activity, Manifest.permission.CAMERA);
final boolean permissionsGrated = writePermission == PackageManager.PERMISSION_GRANTED &&
cameraPermission == PackageManager.PERMISSION_GRANTED;
boolean permissionsGranted = false;
if (!permissionsGrated)
switch (requestCode) {
case REQUEST_PERMISSIONS_FOR_LIBRARY:
permissionsGranted = writePermission == PackageManager.PERMISSION_GRANTED;
break;
case REQUEST_PERMISSIONS_FOR_CAMERA:
permissionsGranted = cameraPermission == PackageManager.PERMISSION_GRANTED && writePermission == PackageManager.PERMISSION_GRANTED;
break;
}
if (!permissionsGranted)
{
final Boolean dontAskAgain = ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) && ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.CAMERA);
@ -608,7 +635,19 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
}
else
{
String[] PERMISSIONS = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
String[] PERMISSIONS;
switch (requestCode) {
case REQUEST_PERMISSIONS_FOR_LIBRARY:
PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
break;
case REQUEST_PERMISSIONS_FOR_CAMERA:
PERMISSIONS = new String[]{Manifest.permission.CAMERA,Manifest.permission.WRITE_EXTERNAL_STORAGE};
break;
default:
PERMISSIONS = new String[]{};
break;
}
if (activity instanceof ReactActivity)
{
((ReactActivity) activity).requestPermissions(PERMISSIONS, requestCode, listener);
@ -703,20 +742,26 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
private void putExtraFileInfo(@NonNull final String path,
@NonNull final ResponseHelper responseHelper)
{
// size && filename
try {
// size && filename
File f = new File(path);
responseHelper.putDouble("fileSize", f.length());
responseHelper.putString("fileName", f.getName());
// type
String extension = MimeTypeMap.getFileExtensionFromUrl(path);
String fileName = f.getName();
if (extension != "") {
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
} else {
int i = fileName.lastIndexOf('.');
if (i > 0) {
extension = fileName.substring(i+1);
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
}
}
} catch (Exception e) {
e.printStackTrace();
}
// type
String extension = MimeTypeMap.getFileExtensionFromUrl(path);
if (extension != null) {
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
}
}
private void parseOptions(final ReadableMap options) {
@ -726,6 +771,10 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
}
imageConfig = imageConfig.updateFromOptions(options);
pickVideo = false;
pickBoth = false;
if (options.hasKey("mediaType") && options.getString("mediaType").equals("mixed")) {
pickBoth = true;
}
if (options.hasKey("mediaType") && options.getString("mediaType").equals("video")) {
pickVideo = true;
}

View File

@ -73,6 +73,9 @@ public class ResponseHelper
public void invokeResponse(@NonNull final Callback callback)
{
if (callback == null) {
return;
}
callback.invoke(response);
}
}

View File

@ -45,11 +45,32 @@ public class MediaUtils
.append(".jpg")
.toString();
final File path = ReadableMapUtils.hasAndNotNullReadableMap(options, "storageOptions")
&& ReadableMapUtils.hasAndNotEmptyString(options.getMap("storageOptions"), "path")
? new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), options.getMap("storageOptions").getString("path"))
: (!forceLocal ? Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
: reactContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES));
// defaults to Public Pictures Directory
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (ReadableMapUtils.hasAndNotNullReadableMap(options, "storageOptions"))
{
final ReadableMap storageOptions = options.getMap("storageOptions");
if (storageOptions.hasKey("privateDirectory"))
{
boolean saveToPrivateDirectory = storageOptions.getBoolean("privateDirectory");
if (saveToPrivateDirectory)
{
// if privateDirectory is set then save to app's private files directory
path = reactContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
}
}
if (ReadableMapUtils.hasAndNotEmptyString(storageOptions, "path"))
{
path = new File(path, storageOptions.getString("path"));
}
}
else if (forceLocal)
{
path = reactContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
}
File result = new File(path, filename);
@ -101,7 +122,7 @@ public class MediaUtils
if (photo == null)
{
return null;
return imageConfig;
}
ImageConfig result = imageConfig;

View File

@ -45,8 +45,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
@RunWith(RobolectricTestRunner.class)
@SuppressStaticInitializationFor("com.facebook.react.common.build.ReactBuildConfig")
@PrepareForTest({Arguments.class})
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"})
@Config(manifest = Config.NONE)
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*", "jdk.internal.reflect.*"})
public class ImagePickerModuleTest
{
private static final int DEFAULT_THEME = R.style.DefaultExplainingPermissionsTheme;
@ -111,4 +110,4 @@ public class ImagePickerModuleTest
}
});
}
}
}

View File

@ -1,14 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
alias: {
'@react-native-community/react-native-image-picker': './src/index.ts',
},
cwd: 'babelrc',
},
],
],
};

View File

@ -2,6 +2,11 @@
```
yarn add react-native-image-picker
# RN >= 0.60
cd ios && pod install
# RN < 0.60
react-native link react-native-image-picker
```

View File

@ -44,30 +44,33 @@ The `callback` will be called with a response object, refer to [The Response Obj
| option | iOS | Android | Info |
| ----------------------------- | --- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| title | OK | OK | Specify `null` or empty string to remove the title |
| cancelButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| takePhotoButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| chooseFromLibraryButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| customButtons | OK | OK | An array containing objects with the name and title of buttons |
| cameraType | OK | - | 'front' or 'back' |
| mediaType | OK | OK | 'photo', 'video', or 'mixed' on iOS, 'photo' or 'video' on Android |
| maxWidth | OK | OK | Photos only |
| maxHeight | OK | OK | Photos only |
| quality | OK | OK | 0 to 1, photos only |
| videoQuality | OK | OK | 'low', 'medium', or 'high' on iOS, 'low' or 'high' on Android |
| durationLimit | OK | OK | Max video recording time, in seconds |
| rotation | - | OK | Photos only, 0 to 360 degrees of rotation |
| allowsEditing | OK | - | bool - enables built-in iOS functionality to resize the image after selection |
| noData | OK | OK | If true, disables the base64 `data` field from being generated (greatly improves performance on large photos) |
| storageOptions | OK | OK | If this key is provided, the image will be saved in your app's `Documents` directory on iOS, or your app's `Pictures` directory on Android (rather than a temporary directory) |
| storageOptions.skipBackup | OK | - | If true, the photo will NOT be backed up to iCloud |
| storageOptions.path | OK | OK | If set, will save the image at `Documents/[path]/` rather than the root `Documents` for iOS, and `Pictures/[path]/` on Android. |
| storageOptions.cameraRoll | OK | OK | If true, the cropped photo will be saved to the iOS Camera Roll or Android DCIM folder. |
| storageOptions.waitUntilSaved | OK | - | If true, will delay the response callback until after the photo/video was saved to the Camera Roll. If the photo or video was just taken, then the file name and timestamp fields are only provided in the response object when this AND `cameraRoll` are both true. |
| permissionDenied.title | - | OK | Title of explaining permissions dialog. By default `Permission denied`. |
| permissionDenied.text | - | OK | Message of explaining permissions dialog. By default `To be able to take pictures with your camera and choose images from your library.`. |
| permissionDenied.reTryTitle | - | OK | Title of re-try button. By default `re-try` |
| permissionDenied.okTitle | - | OK | Title of ok button. By default `I'm sure` |
| title | OK | OK | Specify `null` or empty string to remove the title |
| cancelButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| takePhotoButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| chooseFromLibraryButtonTitle | OK | OK | Specify `null` or empty string to remove this button |
| chooseWhichLibraryTitle | - | OK | Specify `null` or empty string to use default Android title. Is shown when user has multiple apps that can open library. |
| customButtons | OK | OK | An array containing objects with the name and title of buttons |
| tintColor | OK | - | Text color to use on buttons |
| cameraType | OK | - | 'front' or 'back' |
| mediaType | OK | OK | 'photo', 'video', or 'mixed' |
| maxWidth | OK | OK | Photos only |
| maxHeight | OK | OK | Photos only |
| quality | OK | OK | 0 to 1, photos only |
| videoQuality | OK | OK | 'low', 'medium', or 'high' on iOS, 'low' or 'high' on Android |
| durationLimit | OK | OK | Max video recording time, in seconds |
| rotation | - | OK | Photos only, 0 to 360 degrees of rotation |
| allowsEditing | OK | - | bool - enables built-in iOS functionality to resize the image after selection |
| noData | OK | OK | If true, disables the base64 `data` field from being generated (greatly improves performance on large photos) |
| storageOptions | OK | OK | If this key is provided, the image will be saved in your app's `Documents` directory on iOS (rather than a temporary directory). On Android this key does not affect the image location (Android always defaults to the public `Pictures` directory) |
| storageOptions.skipBackup | OK | - | If true, the photo will NOT be backed up to iCloud |
| storageOptions.path | OK | OK | If set, will save the image at `Documents/[path]/` rather than the root `Documents` for iOS, and `Pictures/[path]/` on Android. |
| storageOptions.cameraRoll | OK | OK | If true, the cropped photo will be saved to the iOS Camera Roll or Android DCIM folder. |
| storageOptions.waitUntilSaved | OK | - | If true, will delay the response callback until after the photo/video was saved to the Camera Roll. If the photo or video was just taken, then the file name and timestamp fields are only provided in the response object when this AND `cameraRoll` are both true. |
| storageOptions.privateDirectory | - | OK | If true, the photo will be saved to the apps private files directory (Android/data/your_package/files/Pictures) |
| permissionDenied.title | - | OK | Title of explaining permissions dialog. By default `Permission denied`. |
| permissionDenied.text | - | OK | Message of explaining permissions dialog. By default `To be able to take pictures with your camera and choose images from your library.`. |
| permissionDenied.reTryTitle | - | OK | Title of re-try button. By default `re-try` |
| permissionDenied.okTitle | - | OK | Title of ok button. By default `I'm sure` |
## The Response Object

3
example/.babelrc Normal file
View File

@ -0,0 +1,3 @@
{
"presets": ["module:metro-react-native-babel-preset"]
}

6
example/.buckconfig Normal file
View File

@ -0,0 +1,6 @@
[android]
target = Google Inc.:Google APIs:23
[maven_repositories]
central = https://repo1.maven.org/maven2

70
example/.flowconfig Normal file
View File

@ -0,0 +1,70 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; Ignore polyfills
.*/Libraries/polyfills/.*
; Ignore metro
.*/node_modules/metro/.*
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/
[options]
emoji=true
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable
module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
munge_underscores=true
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
[version]
^0.78.0

1
example/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.pbxproj -text

56
example/.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
# Bundle artifact
*.jsbundle

1
example/.watchmanconfig Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -8,55 +8,23 @@ import {
Text,
TouchableOpacity,
View,
ImageSourcePropType,
} from 'react-native';
import ImagePicker from 'react-native-image-picker';
import ImagePicker, {ImagePickerOptions} from '../';
export default class App extends React.Component {
state = {
avatarSource: null,
videoSource: null,
};
interface Props {}
interface State {
avatarSource: ImageSourcePropType;
videoSource: string;
}
class App extends React.PureComponent<Props, State> {
constructor(props: Props) {
constructor(props) {
super(props);
this.state = {
avatarSource: null,
videoSource: null,
};
this.selectPhotoTapped = this.selectPhotoTapped.bind(this);
this.selectVideoTapped = this.selectVideoTapped.bind(this);
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.selectPhotoTapped}>
<View style={[styles.avatar, styles.avatarContainer]}>
{this.state.avatarSource === null ? (
<Text>Select a Photo</Text>
) : (
<Image style={styles.avatar} source={this.state.avatarSource} />
)}
</View>
</TouchableOpacity>
<TouchableOpacity onPress={this.selectVideoTapped}>
<View style={[styles.avatar, styles.avatarContainer]}>
<Text>Select a Video</Text>
</View>
</TouchableOpacity>
{this.state.videoSource && (
<Text style={styles.videoSource}>{this.state.videoSource}</Text>
)}
</View>
);
}
selectPhotoTapped = () => {
selectPhotoTapped() {
const options = {
quality: 1.0,
maxWidth: 500,
@ -76,18 +44,20 @@ class App extends React.PureComponent<Props, State> {
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
let source = {uri: response.uri};
// You can also display the image using data:
// let source = { uri: 'data:image/jpeg;base64,' + response.data };
this.setState({
avatarSource: {uri: response.uri},
avatarSource: source,
});
}
});
};
}
selectVideoTapped = () => {
const options: ImagePickerOptions = {
selectVideoTapped() {
const options = {
title: 'Video Picker',
takePhotoButtonTitle: 'Take Video...',
mediaType: 'video',
@ -109,7 +79,36 @@ class App extends React.PureComponent<Props, State> {
});
}
});
};
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.selectPhotoTapped.bind(this)}>
<View
style={[styles.avatar, styles.avatarContainer, {marginBottom: 20}]}>
{this.state.avatarSource === null ? (
<Text>Select a Photo</Text>
) : (
<Image style={styles.avatar} source={this.state.avatarSource} />
)}
</View>
</TouchableOpacity>
<TouchableOpacity onPress={this.selectVideoTapped.bind(this)}>
<View style={[styles.avatar, styles.avatarContainer]}>
<Text>Select a Video</Text>
</View>
</TouchableOpacity>
{this.state.videoSource && (
<Text style={{margin: 8, textAlign: 'center'}}>
{this.state.videoSource}
</Text>
)}
</View>
);
}
}
const styles = StyleSheet.create({
@ -124,17 +123,10 @@ const styles = StyleSheet.create({
borderWidth: 1 / PixelRatio.get(),
justifyContent: 'center',
alignItems: 'center',
marginBottom: 20,
},
avatar: {
borderRadius: 75,
width: 150,
height: 150,
},
videoSource: {
margin: 8,
textAlign: 'center',
},
});
export default App;

19
example/README.md Normal file
View File

@ -0,0 +1,19 @@
# Example
An example for experimenting with react-native-image-picker.
## Usage
Install dependencies using:
```bash
yarn install
```
Start the packager with:
```bash
yarn start
```
You will have to reinstall `react-native-image-picker` every time you do changes in the library: `rm -rf node_modules && yarn install` (from `./example` folder).

View File

@ -1,14 +0,0 @@
/**
* @format
*/
import 'react-native';
import React from 'react';
import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});

View File

@ -8,13 +8,23 @@
# - `buck install -r android/app` - compile, install and run application
#
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
lib_deps = []
create_aar_targets(glob(["libs/*.aar"]))
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)
create_jar_targets(glob(["libs/*.jar"]))
for aarfile in glob(['libs/*.aar']):
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
android_library(
name = "all-libs",
@ -35,12 +45,12 @@ android_library(
android_build_config(
name = "build_config",
package = "com.imagepickerexample",
package = "com.example",
)
android_resource(
name = "res",
package = "com.imagepickerexample",
package = "com.example",
res = "src/main/res",
)

View File

@ -9,7 +9,7 @@ import com.android.build.OutputFile
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../../node_modules/react-native/react.gradle"` line.
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
@ -18,9 +18,6 @@ import com.android.build.OutputFile
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
@ -76,11 +73,10 @@ import com.android.build.OutputFile
*/
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
entryFile: "index.js"
]
apply from: "../../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
@ -97,67 +93,30 @@ def enableSeparateBuildPerCPUArchitecture = false
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.imagepickerexample"
applicationId "com.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
include "armeabi-v7a", "x86"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
@ -166,38 +125,22 @@ android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/armeabi-v7a/libjsc.so'
}
}
dependencies {
api project(':react-native-image-picker')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
@ -206,7 +149,3 @@ task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
// set custom root because we're in a monorepo
applyNativeModulesAppBuildGradle(project, "../..")

View File

@ -1,19 +0,0 @@
"""Helper definitions to glob .aar and .jar targets"""
def create_aar_targets(aarfiles):
for aarfile in aarfiles:
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
lib_deps.append(":" + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
def create_jar_targets(jarfiles):
for jarfile in jarfiles:
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
lib_deps.append(":" + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)

View File

@ -8,3 +8,10 @@
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>

View File

@ -1,13 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.imagepickerexample">
package="com.example">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity

View File

@ -1,4 +1,4 @@
package com.imagepickerexample;
package com.example;
import com.facebook.react.ReactActivity;
@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
*/
@Override
protected String getMainComponentName() {
return "ImagePickerExample";
return "Example";
}
}

View File

@ -1,16 +1,15 @@
package com.imagepickerexample;
package com.example;
import android.app.Application;
import android.util.Log;
import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.imagepicker.ImagePickerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
@ -23,16 +22,15 @@ public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ImagePickerPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "example/index";
return "index";
}
};

View File

@ -1,3 +1,3 @@
<resources>
<string name="app_name">ImagePicker Example</string>
<string name="app_name">Example</string>
</resources>

View File

@ -3,7 +3,6 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>
</resources>

View File

@ -2,18 +2,18 @@
buildscript {
ext {
buildToolsVersion = "28.0.3"
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@ -23,16 +23,17 @@ buildscript {
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../../node_modules/jsc-android/dist")
}
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}

View File

@ -16,6 +16,3 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

View File

@ -1,21 +1,5 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -44,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

View File

@ -1,19 +1,3 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -30,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -0,0 +1,8 @@
keystore(
name = "debug",
properties = "debug.keystore.properties",
store = "debug.keystore",
visibility = [
"PUBLIC",
],
)

View File

@ -0,0 +1,4 @@
key.store=debug.keystore
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android

View File

@ -1,7 +1,5 @@
rootProject.name = 'ImagePickerExample'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
rootProject.name = 'Example'
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
// set custom root because we're in a monorepo
applyNativeModulesSettingsGradle(settings, "../..")
include ':app'
include ':app'

View File

@ -1,4 +1,4 @@
{
"name": "ImagePickerExample",
"displayName": "ImagePickerExample"
}
"name": "Example",
"displayName": "Example"
}

View File

@ -1,6 +1,4 @@
/**
* @format
*/
/** @format */
import {AppRegistry} from 'react-native';
import App from './App';

View File

@ -1,421 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
5FEB133B2CC5594A90C9703C /* libPods-ImagePickerExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 164F437F0088080EB33EF39B /* libPods-ImagePickerExample.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* ImagePickerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImagePickerExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ImagePickerExample/AppDelegate.h; sourceTree = "<group>"; };
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ImagePickerExample/AppDelegate.m; sourceTree = "<group>"; };
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ImagePickerExample/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ImagePickerExample/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ImagePickerExample/main.m; sourceTree = "<group>"; };
164F437F0088080EB33EF39B /* libPods-ImagePickerExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImagePickerExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
533335723F055195C6C5FF12 /* Pods-ImagePickerExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerExample.release.xcconfig"; path = "Target Support Files/Pods-ImagePickerExample/Pods-ImagePickerExample.release.xcconfig"; sourceTree = "<group>"; };
656A118D27304B0FC4DB0617 /* Pods-ImagePickerExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-ImagePickerExampleTests/Pods-ImagePickerExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
76CB4888B136E899C99E98E3 /* Pods-ImagePickerExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerExampleTests.release.xcconfig"; path = "Target Support Files/Pods-ImagePickerExampleTests/Pods-ImagePickerExampleTests.release.xcconfig"; sourceTree = "<group>"; };
B8B28EF83DE6D7A39EA210DF /* libPods-ImagePickerExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImagePickerExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
BC4899A681B6AA8B5DD9B48C /* Pods-ImagePickerExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerExample.debug.xcconfig"; path = "Target Support Files/Pods-ImagePickerExample/Pods-ImagePickerExample.debug.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5FEB133B2CC5594A90C9703C /* libPods-ImagePickerExample.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
13B07FAE1A68108700A75B9A /* ImagePickerExample */ = {
isa = PBXGroup;
children = (
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.m */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
13B07FB71A68108700A75B9A /* main.m */,
);
name = ImagePickerExample;
sourceTree = "<group>";
};
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
164F437F0088080EB33EF39B /* libPods-ImagePickerExample.a */,
B8B28EF83DE6D7A39EA210DF /* libPods-ImagePickerExampleTests.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
308473033864D9432937EF22 /* Pods */ = {
isa = PBXGroup;
children = (
BC4899A681B6AA8B5DD9B48C /* Pods-ImagePickerExample.debug.xcconfig */,
533335723F055195C6C5FF12 /* Pods-ImagePickerExample.release.xcconfig */,
656A118D27304B0FC4DB0617 /* Pods-ImagePickerExampleTests.debug.xcconfig */,
76CB4888B136E899C99E98E3 /* Pods-ImagePickerExampleTests.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
);
name = Libraries;
sourceTree = "<group>";
};
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
13B07FAE1A68108700A75B9A /* ImagePickerExample */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
83CBBA001A601CBA00E9B192 /* Products */,
2D16E6871FA4F8E400B85C8A /* Frameworks */,
308473033864D9432937EF22 /* Pods */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
usesTabs = 0;
};
83CBBA001A601CBA00E9B192 /* Products */ = {
isa = PBXGroup;
children = (
13B07F961A680F5B00A75B9A /* ImagePickerExample.app */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
13B07F861A680F5B00A75B9A /* ImagePickerExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ImagePickerExample" */;
buildPhases = (
0F0BF058506A12668AE793EF /* [CP] Check Pods Manifest.lock */,
FD10A7F022414F080027D42C /* Start Packager */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
);
buildRules = (
);
dependencies = (
);
name = ImagePickerExample;
productName = ImagePickerExample;
productReference = 13B07F961A680F5B00A75B9A /* ImagePickerExample.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = Facebook;
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ImagePickerExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = 83CBB9F61A601CBA00E9B192;
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
13B07F861A680F5B00A75B9A /* ImagePickerExample */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
13B07F8E1A680F5B00A75B9A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../../node_modules/react-native/scripts/react-native-xcode.sh";
};
0F0BF058506A12668AE793EF /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-ImagePickerExample-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Start Packager";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
13B07FB21A68108700A75B9A /* Base */,
);
name = LaunchScreen.xib;
path = ImagePickerExample;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BC4899A681B6AA8B5DD9B48C /* Pods-ImagePickerExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
INFOPLIST_FILE = ImagePickerExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = ImagePickerExample;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 533335723F055195C6C5FF12 /* Pods-ImagePickerExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
INFOPLIST_FILE = ImagePickerExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = ImagePickerExample;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
};
83CBBA201A601CBA00E9B192 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
83CBBA211A601CBA00E9B192 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ImagePickerExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13B07F941A680F5B00A75B9A /* Debug */,
13B07F951A680F5B00A75B9A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ImagePickerExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83CBBA201A601CBA00E9B192 /* Debug */,
83CBBA211A601CBA00E9B192 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
}

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:ImagePickerExample.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -1,31 +0,0 @@
platform :ios, '9.0'
require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'ImagePickerExample' do
# Pods for ImagePickerExample
pod 'React', :path => '../../node_modules/react-native/'
pod 'React-Core', :path => '../../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../../node_modules/react-native/React'
pod 'React-RCTActionSheet', :path => '../../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../../node_modules/react-native/Libraries/WebSocket'
pod 'React-cxxreact', :path => '../../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../../node_modules/react-native/third-party-podspecs/Folly.podspec'
use_native_modules!("../..")
end

View File

@ -1,187 +0,0 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- Folly (2018.10.22.00):
- boost-for-react-native
- DoubleConversion
- Folly/Default (= 2018.10.22.00)
- glog
- Folly/Default (2018.10.22.00):
- boost-for-react-native
- DoubleConversion
- glog
- glog (0.3.5)
- React (0.60.5):
- React-Core (= 0.60.5)
- React-DevSupport (= 0.60.5)
- React-RCTActionSheet (= 0.60.5)
- React-RCTAnimation (= 0.60.5)
- React-RCTBlob (= 0.60.5)
- React-RCTImage (= 0.60.5)
- React-RCTLinking (= 0.60.5)
- React-RCTNetwork (= 0.60.5)
- React-RCTSettings (= 0.60.5)
- React-RCTText (= 0.60.5)
- React-RCTVibration (= 0.60.5)
- React-RCTWebSocket (= 0.60.5)
- React-Core (0.60.5):
- Folly (= 2018.10.22.00)
- React-cxxreact (= 0.60.5)
- React-jsiexecutor (= 0.60.5)
- yoga (= 0.60.5.React)
- React-cxxreact (0.60.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsinspector (= 0.60.5)
- React-DevSupport (0.60.5):
- React-Core (= 0.60.5)
- React-RCTWebSocket (= 0.60.5)
- React-jsi (0.60.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsi/Default (= 0.60.5)
- React-jsi/Default (0.60.5):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-jsiexecutor (0.60.5):
- DoubleConversion
- Folly (= 2018.10.22.00)
- glog
- React-cxxreact (= 0.60.5)
- React-jsi (= 0.60.5)
- React-jsinspector (0.60.5)
- react-native-image-picker (1.0.2):
- React
- React-RCTActionSheet (0.60.5):
- React-Core (= 0.60.5)
- React-RCTAnimation (0.60.5):
- React-Core (= 0.60.5)
- React-RCTBlob (0.60.5):
- React-Core (= 0.60.5)
- React-RCTNetwork (= 0.60.5)
- React-RCTWebSocket (= 0.60.5)
- React-RCTImage (0.60.5):
- React-Core (= 0.60.5)
- React-RCTNetwork (= 0.60.5)
- React-RCTLinking (0.60.5):
- React-Core (= 0.60.5)
- React-RCTNetwork (0.60.5):
- React-Core (= 0.60.5)
- React-RCTSettings (0.60.5):
- React-Core (= 0.60.5)
- React-RCTText (0.60.5):
- React-Core (= 0.60.5)
- React-RCTVibration (0.60.5):
- React-Core (= 0.60.5)
- React-RCTWebSocket (0.60.5):
- React-Core (= 0.60.5)
- yoga (0.60.5.React)
DEPENDENCIES:
- DoubleConversion (from `../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- Folly (from `../../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`)
- React (from `../../node_modules/react-native/`)
- React-Core (from `../../node_modules/react-native/React`)
- React-cxxreact (from `../../node_modules/react-native/ReactCommon/cxxreact`)
- React-DevSupport (from `../../node_modules/react-native/React`)
- React-jsi (from `../../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-image-picker (from `../../.`)
- React-RCTActionSheet (from `../../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../../node_modules/react-native/Libraries/Blob`)
- React-RCTImage (from `../../node_modules/react-native/Libraries/Image`)
- React-RCTLinking (from `../../node_modules/react-native/Libraries/LinkingIOS`)
- React-RCTNetwork (from `../../node_modules/react-native/Libraries/Network`)
- React-RCTSettings (from `../../node_modules/react-native/Libraries/Settings`)
- React-RCTText (from `../../node_modules/react-native/Libraries/Text`)
- React-RCTVibration (from `../../node_modules/react-native/Libraries/Vibration`)
- React-RCTWebSocket (from `../../node_modules/react-native/Libraries/WebSocket`)
- yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- boost-for-react-native
EXTERNAL SOURCES:
DoubleConversion:
:podspec: "../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
Folly:
:podspec: "../../node_modules/react-native/third-party-podspecs/Folly.podspec"
glog:
:podspec: "../../node_modules/react-native/third-party-podspecs/glog.podspec"
React:
:path: "../../node_modules/react-native/"
React-Core:
:path: "../../node_modules/react-native/React"
React-cxxreact:
:path: "../../node_modules/react-native/ReactCommon/cxxreact"
React-DevSupport:
:path: "../../node_modules/react-native/React"
React-jsi:
:path: "../../node_modules/react-native/ReactCommon/jsi"
React-jsiexecutor:
:path: "../../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../../node_modules/react-native/ReactCommon/jsinspector"
react-native-image-picker:
:path: "../../."
React-RCTActionSheet:
:path: "../../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation:
:path: "../../node_modules/react-native/Libraries/NativeAnimation"
React-RCTBlob:
:path: "../../node_modules/react-native/Libraries/Blob"
React-RCTImage:
:path: "../../node_modules/react-native/Libraries/Image"
React-RCTLinking:
:path: "../../node_modules/react-native/Libraries/LinkingIOS"
React-RCTNetwork:
:path: "../../node_modules/react-native/Libraries/Network"
React-RCTSettings:
:path: "../../node_modules/react-native/Libraries/Settings"
React-RCTText:
:path: "../../node_modules/react-native/Libraries/Text"
React-RCTVibration:
:path: "../../node_modules/react-native/Libraries/Vibration"
React-RCTWebSocket:
:path: "../../node_modules/react-native/Libraries/WebSocket"
yoga:
:path: "../../node_modules/react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
React: 53c53c4d99097af47cf60594b8706b4e3321e722
React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64
React-cxxreact: 8384287780c4999351ad9b6e7a149d9ed10a2395
React-DevSupport: 197fb409737cff2c4f9986e77c220d7452cb9f9f
React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2
React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30
React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4
react-native-image-picker: c468ffc9b37b5e2ccaac70cd99abaca9631db1dd
React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90
React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e
React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24
React-RCTImage: f5f1c50922164e89bdda67bcd0153952a5cfe719
React-RCTLinking: d0ecbd791e9ddddc41fa1f66b0255de90e8ee1e9
React-RCTNetwork: e26946300b0ab7bb6c4a6348090e93fa21f33a9d
React-RCTSettings: d0d37cb521b7470c998595a44f05847777cc3f42
React-RCTText: b074d89033583d4f2eb5faf7ea2db3a13c7553a2
React-RCTVibration: 2105b2e0e2b66a6408fc69a46c8a7fb5b2fdade0
React-RCTWebSocket: cd932a16b7214898b6b7f788c8bddb3637246ac4
yoga: 312528f5bbbba37b4dcea5ef00e8b4033fdd9411
PODFILE CHECKSUM: 7cf371ab47273829dc5ee93ff0667360d17d01cc
COCOAPODS: 1.7.3

View File

@ -4,12 +4,10 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>ImagePicker Example</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@ -24,21 +22,6 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
@ -53,5 +36,19 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D2A28121D9B038B00D4039D"
BuildableName = "libReact.a"
BlueprintName = "React-tvOS"
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "Example-tvOS.app"
BlueprintName = "Example-tvOS"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E48F1E0B4A5D006451C7"
BuildableName = "Example-tvOSTests.xctest"
BlueprintName = "Example-tvOSTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E48F1E0B4A5D006451C7"
BuildableName = "Example-tvOSTests.xctest"
BlueprintName = "Example-tvOSTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "Example-tvOS.app"
BlueprintName = "Example-tvOS"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "Example-tvOS.app"
BlueprintName = "Example-tvOS"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "Example-tvOS.app"
BlueprintName = "Example-tvOS"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -17,7 +17,7 @@
BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
BuildableName = "libReact.a"
BlueprintName = "React"
ReferencedContainer = "container:../../node_modules/react-native/React/React.xcodeproj">
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
@ -29,9 +29,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "ImagePickerExample.app"
BlueprintName = "ImagePickerExample"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
@ -43,9 +43,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "ImagePickerExampleTests.xctest"
BlueprintName = "ImagePickerExampleTests"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
@ -61,9 +61,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "ImagePickerExampleTests.xctest"
BlueprintName = "ImagePickerExampleTests"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
@ -71,9 +71,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "ImagePickerExample.app"
BlueprintName = "ImagePickerExample"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
@ -94,9 +94,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "ImagePickerExample.app"
BlueprintName = "ImagePickerExample"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
@ -113,9 +113,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "ImagePickerExample.app"
BlueprintName = "ImagePickerExample"
ReferencedContainer = "container:ImagePickerExample.xcodeproj">
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>

View File

@ -1,14 +1,13 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -7,7 +7,6 @@
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@ -15,11 +14,14 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"ImagePickerExample"
initialProperties:nil];
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Example"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@ -30,13 +32,4 @@
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"example/index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end

View File

@ -18,7 +18,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ImagePickerExample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Example" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Example</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) would like to your microphone (for videos)</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) would like access to your photo gallery</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -0,0 +1,68 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
@interface ExampleTests : XCTestCase
@end
@implementation ExampleTests
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
{
if (test(view)) {
return YES;
}
for (UIView *subview in [view subviews]) {
if ([self findSubviewInView:subview matching:test]) {
return YES;
}
}
return NO;
}
- (void)testRendersWelcomeScreen
{
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
__block NSString *redboxError = nil;
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
redboxError = message;
}
});
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
return YES;
}
return NO;
}];
}
RCTSetLogFunction(RCTDefaultLogFunction);
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
}
@end

23
example/package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "Example",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.7",
"react-native-image-picker": "file:../"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.50.0",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}

5959
example/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,11 @@
#import "ImagePickerManager.h"
#import <React/RCTConvert.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h>
#import <React/RCTUtils.h>
#if !TARGET_OS_MACCATALYST
#import <AssetsLibrary/AssetsLibrary.h>
#endif
@import MobileCoreServices;
@ -25,22 +27,26 @@ RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(launchCamera:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback)
{
self.callback = callback;
[self launchImagePicker:RNImagePickerTargetCamera options:options];
dispatch_async(dispatch_get_main_queue(), ^{
[self launchImagePicker:RNImagePickerTargetCamera options:options];
});
}
RCT_EXPORT_METHOD(launchImageLibrary:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback)
{
self.callback = callback;
[self launchImagePicker:RNImagePickerTargetLibrarySingleImage options:options];
dispatch_async(dispatch_get_main_queue(), ^{
[self launchImagePicker:RNImagePickerTargetLibrarySingleImage options:options];
});
}
RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback)
{
self.callback = callback; // Save the callback so we can use it from the delegate methods
self.options = options;
dispatch_async(dispatch_get_main_queue(), ^{
NSString *title = [self.options valueForKey:@"title"];
if ([title isEqual:[NSNull null]] || title.length == 0) {
title = nil; // A more visually appealing UIAlertControl is displayed with a nil title rather than title = @""
@ -48,15 +54,15 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
NSString *cancelTitle = [self.options valueForKey:@"cancelButtonTitle"];
NSString *takePhotoButtonTitle = [self.options valueForKey:@"takePhotoButtonTitle"];
NSString *chooseFromLibraryButtonTitle = [self.options valueForKey:@"chooseFromLibraryButtonTitle"];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
alertController.view.tintColor = [RCTConvert UIColor:options[@"tintColor"]];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
self.callback(@[@{@"didCancel": @YES}]); // Return callback for 'cancel' action (if is required)
}];
[alertController addAction:cancelAction];
if (![takePhotoButtonTitle isEqual:[NSNull null]] && takePhotoButtonTitle.length > 0) {
UIAlertAction *takePhotoAction = [UIAlertAction actionWithTitle:takePhotoButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self actionHandler:action];
@ -69,7 +75,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
}];
[alertController addAction:chooseFromLibraryAction];
}
// Add custom buttons to action sheet
if ([self.options objectForKey:@"customButtons"] && [[self.options objectForKey:@"customButtons"] isKindOfClass:[NSArray class]]) {
self.customButtons = [self.options objectForKey:@"customButtons"];
@ -81,16 +87,16 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
[alertController addAction:customAction];
}
}
UIViewController *root = RCTPresentedViewController();
/* On iPad, UIAlertController presents a popover view rather than an action sheet like on iPhone. We must provide the location
of the location to show the popover in this case. For simplicity, we'll just display it on the bottom center of the screen
to mimic an action sheet */
of the location to show the popover in this case. For simplicity, we'll just display it on the bottom center of the screen
to mimic an action sheet */
alertController.popoverPresentationController.sourceView = root.view;
alertController.popoverPresentationController.sourceRect = CGRectMake(root.view.bounds.size.width / 2.0, root.view.bounds.size.height, 1.0, 1.0);
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
alertController.popoverPresentationController.permittedArrowDirections = 0;
for (id subview in alertController.view.subviews) {
if ([subview isMemberOfClass:[UIView class]]) {
@ -98,7 +104,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
}
}
}
[root presentViewController:alertController animated:YES completion:nil];
});
}
@ -115,7 +121,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
return;
}
}
if ([action.title isEqualToString:[self.options valueForKey:@"takePhotoButtonTitle"]]) { // Take photo
[self launchImagePicker:RNImagePickerTargetCamera];
}
@ -133,7 +139,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
- (void)launchImagePicker:(RNImagePickerTarget)target
{
self.picker = [[UIImagePickerController alloc] init];
if (target == RNImagePickerTargetCamera) {
#if TARGET_IPHONE_SIMULATOR
self.callback(@[@{@"error": @"Camera not available on simulator"}]);
@ -151,10 +157,10 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
else { // RNImagePickerTargetLibrarySingleImage
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
if ([[self.options objectForKey:@"mediaType"] isEqualToString:@"video"]
|| [[self.options objectForKey:@"mediaType"] isEqualToString:@"mixed"]) {
if ([[self.options objectForKey:@"videoQuality"] isEqualToString:@"high"]) {
self.picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
}
@ -164,7 +170,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
else {
self.picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
}
id durationLimit = [self.options objectForKey:@"durationLimit"];
if (durationLimit) {
self.picker.videoMaximumDuration = [durationLimit doubleValue];
@ -178,13 +184,13 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
} else {
self.picker.mediaTypes = @[(NSString *)kUTTypeImage];
}
if ([[self.options objectForKey:@"allowsEditing"] boolValue]) {
self.picker.allowsEditing = true;
}
self.picker.modalPresentationStyle = UIModalPresentationCurrentContext;
self.picker.delegate = self;
// Check permissions
void (^showPickerViewController)() = ^void() {
dispatch_async(dispatch_get_main_queue(), ^{
@ -192,53 +198,57 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
[root presentViewController:self.picker animated:YES completion:nil];
});
};
if (target == RNImagePickerTargetCamera) {
[self checkCameraPermissions:^(BOOL granted) {
if (!granted) {
self.callback(@[@{@"error": @"Camera permissions not granted"}]);
return;
}
showPickerViewController();
}];
}
else { // RNImagePickerTargetLibrarySingleImage
[self checkPhotosPermissions:^(BOOL granted) {
if (!granted) {
self.callback(@[@{@"error": @"Photo library permissions not granted"}]);
return;
}
if (@available(iOS 11.0, *)) {
showPickerViewController();
}];
} else {
[self checkPhotosPermissions:^(BOOL granted) {
if (!granted) {
self.callback(@[@{@"error": @"Photo library permissions not granted"}]);
return;
}
showPickerViewController();
}];
}
}
}
- (NSString * _Nullable)originalFilenameForAsset:(PHAsset * _Nullable)asset assetType:(PHAssetResourceType)type {
if (!asset) { return nil; }
PHAssetResource *originalResource;
// Get the underlying resources for the PHAsset (PhotoKit)
NSArray<PHAssetResource *> *pickedAssetResources = [PHAssetResource assetResourcesForAsset:asset];
// Find the original resource (underlying image) for the asset, which has the desired filename
for (PHAssetResource *resource in pickedAssetResources) {
if (resource.type == type) {
originalResource = resource;
}
}
return originalResource.originalFilename;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
dispatch_block_t dismissCompletionBlock = ^{
NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
NSURL *imageURL = [info valueForKey:UIImagePickerControllerPHAsset];
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
NSString *fileName;
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
NSString *tempFileName = [[NSUUID UUID] UUIDString];
@ -256,18 +266,18 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
NSURL *videoURL = info[UIImagePickerControllerMediaURL];
fileName = videoURL.lastPathComponent;
}
// We default to path to the temporary directory
NSString *path = [[NSTemporaryDirectory()stringByStandardizingPath] stringByAppendingPathComponent:fileName];
// If storage options are provided, we use the documents directory which is persisted
if ([self.options objectForKey:@"storageOptions"] && [[self.options objectForKey:@"storageOptions"] isKindOfClass:[NSDictionary class]]) {
NSDictionary *storageOptions = [self.options objectForKey:@"storageOptions"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
path = [documentsDirectory stringByAppendingPathComponent:fileName];
// Creates documents subdirectory, if provided
if ([storageOptions objectForKey:@"path"]) {
NSString *newPath = [documentsDirectory stringByAppendingPathComponent:[storageOptions objectForKey:@"path"]];
@ -283,10 +293,10 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
}
}
}
// Create the response object
self.response = [[NSMutableDictionary alloc] init];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { // PHOTOS
UIImage *originalImage;
if ([[self.options objectForKey:@"allowsEditing"] boolValue]) {
@ -295,9 +305,17 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
else {
originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
}
if (imageURL) {
PHAsset *pickedAsset = [PHAsset fetchAssetsWithALAssetURLs:@[imageURL] options:nil].lastObject;
PHAsset *pickedAsset;
if (@available(iOS 11.0, *)) {
pickedAsset = [info objectForKey: UIImagePickerControllerPHAsset];
} else {
#if !TARGET_OS_MACCATALYST
pickedAsset = [PHAsset fetchAssetsWithALAssetURLs:@[imageURL] options:nil].lastObject;
#endif
}
NSString *originalFilename = [self originalFilenameForAsset:pickedAsset assetType:PHAssetResourceTypePhoto];
self.response[@"fileName"] = originalFilename ?: [NSNull null];
if (pickedAsset.location) {
@ -308,9 +326,10 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
self.response[@"timestamp"] = [[ImagePickerManager ISO8601DateFormatter] stringFromDate:pickedAsset.creationDate];
}
}
// GIFs break when resized, so we handle them differently
if (imageURL && [[imageURL absoluteString] rangeOfString:@"ext=GIF"].location != NSNotFound) {
#if !TARGET_OS_MACCATALYST
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
[assetsLibrary assetForURL:imageURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
@ -319,38 +338,39 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:repSize error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
[data writeToFile:path atomically:YES];
NSMutableDictionary *gifResponse = [[NSMutableDictionary alloc] init];
[gifResponse setObject:@(originalImage.size.width) forKey:@"width"];
[gifResponse setObject:@(originalImage.size.height) forKey:@"height"];
BOOL vertical = (originalImage.size.width < originalImage.size.height) ? YES : NO;
[gifResponse setObject:@(vertical) forKey:@"isVertical"];
if (![[self.options objectForKey:@"noData"] boolValue]) {
NSString *dataString = [data base64EncodedStringWithOptions:0];
[gifResponse setObject:dataString forKey:@"data"];
}
NSURL *fileURL = [NSURL fileURLWithPath:path];
[gifResponse setObject:[fileURL absoluteString] forKey:@"uri"];
NSNumber *fileSizeValue = nil;
NSError *fileSizeError = nil;
[fileURL getResourceValue:&fileSizeValue forKey:NSURLFileSizeKey error:&fileSizeError];
if (fileSizeValue){
[gifResponse setObject:fileSizeValue forKey:@"fileSize"];
}
self.callback(@[gifResponse]);
} failureBlock:^(NSError *error) {
self.callback(@[@{@"error": error.localizedFailureReason}]);
}];
#endif
return;
}
UIImage *editedImage = [self fixOrientation:originalImage]; // Rotate the image for upload to web
// If needed, downscale image
float maxWidth = editedImage.size.width;
float maxHeight = editedImage.size.height;
@ -361,7 +381,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
maxHeight = [[self.options valueForKey:@"maxHeight"] floatValue];
}
editedImage = [self downscaleImageIfNecessary:editedImage maxWidth:maxWidth maxHeight:maxHeight];
NSData *data;
NSString *mimeType;
if ([[self.options objectForKey:@"imageFileType"] isEqualToString:@"png"]) {
@ -374,36 +394,37 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
}
[self.response setObject:mimeType forKey:@"type"];
[data writeToFile:path atomically:YES];
if (![[self.options objectForKey:@"noData"] boolValue]) {
NSString *dataString = [data base64EncodedStringWithOptions:0]; // base64 encoded image string
[self.response setObject:dataString forKey:@"data"];
}
BOOL vertical = (editedImage.size.width < editedImage.size.height) ? YES : NO;
[self.response setObject:@(vertical) forKey:@"isVertical"];
NSURL *fileURL = [NSURL fileURLWithPath:path];
NSString *filePath = [fileURL absoluteString];
[self.response setObject:filePath forKey:@"uri"];
// add ref to the original image
NSString *origURL = [imageURL absoluteString];
if (origURL) {
[self.response setObject:origURL forKey:@"origURL"];
[self.response setObject:origURL forKey:@"origURL"];
}
NSNumber *fileSizeValue = nil;
NSError *fileSizeError = nil;
[fileURL getResourceValue:&fileSizeValue forKey:NSURLFileSizeKey error:&fileSizeError];
if (fileSizeValue){
[self.response setObject:fileSizeValue forKey:@"fileSize"];
}
[self.response setObject:@(editedImage.size.width) forKey:@"width"];
[self.response setObject:@(editedImage.size.height) forKey:@"height"];
NSDictionary *storageOptions = [self.options objectForKey:@"storageOptions"];
if (storageOptions && [[storageOptions objectForKey:@"cameraRoll"] boolValue] == YES && self.picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
#if !TARGET_OS_MACCATALYST
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([[storageOptions objectForKey:@"waitUntilSaved"] boolValue]) {
[library writeImageToSavedPhotosAlbum:originalImage.CGImage metadata:[info valueForKey:UIImagePickerControllerMediaMetadata] completionBlock:^(NSURL *assetURL, NSError *error) {
@ -426,13 +447,15 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
} else {
[library writeImageToSavedPhotosAlbum:originalImage.CGImage metadata:[info valueForKey:UIImagePickerControllerMediaMetadata] completionBlock:nil];
}
#endif
}
}
else { // VIDEO
NSURL *videoRefURL = info[UIImagePickerControllerReferenceURL];
NSURL *videoRefURL = info[UIImagePickerControllerPHAsset];
NSURL *videoURL = info[UIImagePickerControllerMediaURL];
NSURL *videoDestinationURL = [NSURL fileURLWithPath:path];
#if !TARGET_OS_MACCATALYST
if (videoRefURL) {
PHAsset *pickedAsset = [PHAsset fetchAssetsWithALAssetURLs:@[videoRefURL] options:nil].lastObject;
NSString *originalFilename = [self originalFilenameForAsset:pickedAsset assetType:PHAssetResourceTypeVideo];
@ -445,32 +468,41 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
self.response[@"timestamp"] = [[ImagePickerManager ISO8601DateFormatter] stringFromDate:pickedAsset.creationDate];
}
}
#endif
if ([videoURL.URLByResolvingSymlinksInPath.path isEqualToString:videoDestinationURL.URLByResolvingSymlinksInPath.path] == NO) {
NSFileManager *fileManager = [NSFileManager defaultManager];
// Delete file if it already exists
if ([fileManager fileExistsAtPath:videoDestinationURL.path]) {
[fileManager removeItemAtURL:videoDestinationURL error:nil];
}
if (videoURL) { // Protect against reported crash
NSError *error = nil;
[fileManager moveItemAtURL:videoURL toURL:videoDestinationURL error:&error];
if (error) {
self.callback(@[@{@"error": error.localizedFailureReason}]);
return;
}
NSError *error = nil;
// If we have write access to the source file, move it. Otherwise use copy.
if ([fileManager isWritableFileAtPath:[videoURL path]]) {
[fileManager moveItemAtURL:videoURL toURL:videoDestinationURL error:&error];
} else {
[fileManager copyItemAtURL:videoURL toURL:videoDestinationURL error:&error];
}
if (error) {
self.callback(@[@{@"error": error.localizedFailureReason}]);
return;
}
}
}
[self.response setObject:videoDestinationURL.absoluteString forKey:@"uri"];
if (videoRefURL.absoluteString) {
[self.response setObject:videoRefURL.absoluteString forKey:@"origURL"];
}
NSDictionary *storageOptions = [self.options objectForKey:@"storageOptions"];
if (storageOptions && [[storageOptions objectForKey:@"cameraRoll"] boolValue] == YES && self.picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
#if !TARGET_OS_MACCATALYST
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:videoDestinationURL completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
@ -488,22 +520,23 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
self.response[@"timestamp"] = [[ImagePickerManager ISO8601DateFormatter] stringFromDate:capturedAsset.creationDate];
}
}
self.callback(@[self.response]);
}
}
}];
#endif
}
}
// If storage options are provided, check the skipBackup flag
if ([self.options objectForKey:@"storageOptions"] && [[self.options objectForKey:@"storageOptions"] isKindOfClass:[NSDictionary class]]) {
NSDictionary *storageOptions = [self.options objectForKey:@"storageOptions"];
if ([[storageOptions objectForKey:@"skipBackup"] boolValue]) {
[self addSkipBackupAttributeToItemAtPath:path]; // Don't back up the file to iCloud
}
if ([[storageOptions objectForKey:@"waitUntilSaved"] boolValue] == NO ||
[[storageOptions objectForKey:@"cameraRoll"] boolValue] == NO ||
self.picker.sourceType != UIImagePickerControllerSourceTypeCamera)
@ -515,7 +548,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
self.callback(@[self.response]);
}
};
dispatch_async(dispatch_get_main_queue(), ^{
[picker dismissViewControllerAnimated:YES completion:dismissCompletionBlock];
});
@ -574,12 +607,12 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
- (UIImage*)downscaleImageIfNecessary:(UIImage*)image maxWidth:(float)maxWidth maxHeight:(float)maxHeight
{
UIImage* newImage = image;
// Nothing to do here
if (image.size.width <= maxWidth && image.size.height <= maxHeight) {
return newImage;
}
CGSize scaledSize = CGSizeMake(image.size.width, image.size.height);
if (maxWidth < scaledSize.width) {
scaledSize = CGSizeMake(maxWidth, (maxWidth / scaledSize.width) * scaledSize.height);
@ -587,11 +620,11 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
if (maxHeight < scaledSize.height) {
scaledSize = CGSizeMake((maxHeight / scaledSize.height) * scaledSize.width, maxHeight);
}
// If the pixels are floats, it causes a white line in iOS8 and probably other versions too
scaledSize.width = (int)scaledSize.width;
scaledSize.height = (int)scaledSize.height;
UIGraphicsBeginImageContext(scaledSize); // this will resize
[image drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
newImage = UIGraphicsGetImageFromCurrentImageContext();
@ -599,7 +632,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
NSLog(@"could not scale image");
}
UIGraphicsEndImageContext();
return newImage;
}
@ -607,7 +640,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
if (srcImg.imageOrientation == UIImageOrientationUp) {
return srcImg;
}
CGAffineTransform transform = CGAffineTransformIdentity;
switch (srcImg.imageOrientation) {
case UIImageOrientationDown:
@ -615,13 +648,13 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
transform = CGAffineTransformTranslate(transform, srcImg.size.width, srcImg.size.height);
transform = CGAffineTransformRotate(transform, M_PI);
break;
case UIImageOrientationLeft:
case UIImageOrientationLeftMirrored:
transform = CGAffineTransformTranslate(transform, srcImg.size.width, 0);
transform = CGAffineTransformRotate(transform, M_PI_2);
break;
case UIImageOrientationRight:
case UIImageOrientationRightMirrored:
transform = CGAffineTransformTranslate(transform, 0, srcImg.size.height);
@ -631,14 +664,14 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
case UIImageOrientationUpMirrored:
break;
}
switch (srcImg.imageOrientation) {
case UIImageOrientationUpMirrored:
case UIImageOrientationDownMirrored:
transform = CGAffineTransformTranslate(transform, srcImg.size.width, 0);
transform = CGAffineTransformScale(transform, -1, 1);
break;
case UIImageOrientationLeftMirrored:
case UIImageOrientationRightMirrored:
transform = CGAffineTransformTranslate(transform, srcImg.size.height, 0);
@ -650,7 +683,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
case UIImageOrientationRight:
break;
}
CGContextRef ctx = CGBitmapContextCreate(NULL, srcImg.size.width, srcImg.size.height, CGImageGetBitsPerComponent(srcImg.CGImage), 0, CGImageGetColorSpace(srcImg.CGImage), CGImageGetBitmapInfo(srcImg.CGImage));
CGContextConcatCTM(ctx, transform);
switch (srcImg.imageOrientation) {
@ -660,12 +693,12 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
case UIImageOrientationRightMirrored:
CGContextDrawImage(ctx, CGRectMake(0,0,srcImg.size.height,srcImg.size.width), srcImg.CGImage);
break;
default:
CGContextDrawImage(ctx, CGRectMake(0,0,srcImg.size.width,srcImg.size.height), srcImg.CGImage);
break;
}
CGImageRef cgimg = CGBitmapContextCreateImage(ctx);
UIImage *img = [UIImage imageWithCGImage:cgimg];
CGContextRelease(ctx);
@ -680,7 +713,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options callback:(RCTResponseS
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}

View File

@ -1,17 +0,0 @@
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};

15954
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "react-native-image-picker",
"version": "1.0.2",
"version": "2.3.3",
"description": "A React Native module that allows you to use native UI to select media from the device library or directly from the camera",
"react-native": "src/index.ts",
"types": "lib/typescript/index.d.ts",
@ -36,8 +36,7 @@
"homepage": "https://github.com/react-community/react-native-image-picker#readme",
"license": "MIT",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"start:android": "react-native run-android --root example/",
"start": "react-native start",
"test": "yarn validate:eslint && yarn validate:typescript",
"validate:eslint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"",
"validate:typescript": "tsc --project ./ --noEmit",
@ -56,35 +55,33 @@
],
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.5.5",
"@react-native-community/bob": "^0.7.0",
"@react-native-community/cli": "^2.9.0",
"@babel/core": "^7.4.5",
"@babel/runtime": "^7.4.5",
"@react-native-community/bob": "^0.6.0",
"@react-native-community/eslint-config": "^0.0.5",
"@semantic-release/changelog": "^3.0.4",
"@semantic-release/git": "7.0.16",
"@types/jest": "^24.0.18",
"@semantic-release/git": "7.0.12",
"@types/jest": "^24.0.15",
"@types/react": "^16.8.22",
"@types/react-native": "^0.60.8",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"babel-jest": "^24.9.0",
"babel-plugin-module-resolver": "^3.2.0",
"eslint": "6.2.2",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "3.1.0",
"husky": "^3.0.4",
"jest": "^24.9.0",
"lint-staged": "^9.2.5",
"metro-react-native-babel-preset": "^0.56.0",
"@types/react-native": "^0.57.63",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"babel-jest": "^24.8.0",
"eslint": "5.16.0",
"eslint-config-prettier": "^5.0.0",
"eslint-plugin-prettier": "3.0.1",
"husky": "^2.4.1",
"jest": "^24.8.0",
"lint-staged": "^8.2.1",
"metro-react-native-babel-preset": "^0.54.1",
"prettier": "^1.18.2",
"react": "16.8.6",
"react-native": "0.60.5",
"react-native": "0.60.0-rc.2",
"react-test-renderer": "16.8.6",
"rimraf": "^3.0.0",
"semantic-release": "15.13.24",
"rimraf": "^2.6.3",
"semantic-release": "15.13.16",
"ts-jest": "^24.0.2",
"typescript": "^3.5.3"
"typescript": "^3.5.2"
},
"repository": {
"type": "git",

View File

@ -1,9 +0,0 @@
const root = process.cwd();
module.exports = {
dependencies: {
'react-native-image-picker': {
root,
},
},
};

View File

@ -9,6 +9,7 @@
import NativeInterface from './internal/nativeInterface';
import {ImagePickerOptions, ImagePickerResponse} from './internal/types';
import {processColor} from 'react-native';
const DEFAULT_OPTIONS: ImagePickerOptions = {
title: 'Select a Photo',
@ -24,6 +25,7 @@ const DEFAULT_OPTIONS: ImagePickerOptions = {
reTryTitle: 're-try',
okTitle: "I'm sure",
},
tintColor: '',
};
type Callback = (response: ImagePickerResponse) => void;
@ -39,7 +41,10 @@ class ImagePicker {
): void {
if (typeof optionsOrCallback === 'function') {
return NativeInterface.showImagePicker(
DEFAULT_OPTIONS,
{
...DEFAULT_OPTIONS,
tintColor: processColor(DEFAULT_OPTIONS.tintColor),
},
optionsOrCallback,
);
}
@ -49,21 +54,35 @@ class ImagePicker {
}
return NativeInterface.showImagePicker(
{...DEFAULT_OPTIONS, ...optionsOrCallback},
{
...DEFAULT_OPTIONS,
...optionsOrCallback,
tintColor: processColor(
optionsOrCallback.tintColor || DEFAULT_OPTIONS.tintColor,
),
},
callback,
);
}
launchCamera(options: ImagePickerOptions, callback: Callback): void {
return NativeInterface.launchCamera(
{...DEFAULT_OPTIONS, ...options},
{
...DEFAULT_OPTIONS,
...options,
tintColor: processColor(options.tintColor || DEFAULT_OPTIONS.tintColor),
},
callback,
);
}
launchImageLibrary(options: ImagePickerOptions, callback: Callback): void {
return NativeInterface.launchImageLibrary(
{...DEFAULT_OPTIONS, ...options},
{
...DEFAULT_OPTIONS,
...options,
tintColor: processColor(options.tintColor || DEFAULT_OPTIONS.tintColor),
},
callback,
);
}

View File

@ -36,6 +36,7 @@ export interface ImagePickerOptions {
cancelButtonTitle?: string;
takePhotoButtonTitle?: string;
chooseFromLibraryButtonTitle?: string;
chooseWhichLibraryTitle?: string;
customButtons?: ImagePickerCustomButtonOptions[];
cameraType?: 'front' | 'back';
mediaType?: 'photo' | 'video' | 'mixed';
@ -49,6 +50,7 @@ export interface ImagePickerOptions {
noData?: boolean;
storageOptions?: ImagePickerStorageOptions;
permissionDenied?: ImagePickerPermissionDeniedOptions;
tintColor?: number | string;
}
export interface ImagePickerStorageOptions {
@ -56,6 +58,7 @@ export interface ImagePickerStorageOptions {
path?: string;
cameraRoll?: boolean;
waitUntilSaved?: boolean;
privateDirectory?: boolean;
}
export interface ImagePickerPermissionDeniedOptions {

9995
yarn.lock

File diff suppressed because it is too large Load Diff