diff --git a/Example/Example.js b/Example/Example.js
index 88820de..41691ea 100644
--- a/Example/Example.js
+++ b/Example/Example.js
@@ -13,9 +13,10 @@ const styles = StyleSheet.create({
flex: 1,
},
preview: {
- flex: 1,
+ alignSelf: "stretch",
justifyContent: 'flex-end',
alignItems: 'center',
+ height: 200
},
overlay: {
position: 'absolute',
diff --git a/Example/ios/Example/Info.plist b/Example/ios/Example/Info.plist
index 2e46f9d..600fd2f 100644
--- a/Example/ios/Example/Info.plist
+++ b/Example/ios/Example/Info.plist
@@ -7,7 +7,7 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
@@ -22,12 +22,25 @@
1
LSRequiresIPhoneOS
+ NSAppTransportSecurity
+
+ NSExceptionDomains
+
+ localhost
+
+ NSExceptionAllowsInsecureHTTPLoads
+
+
+
+
NSCameraUsageDescription
This app needs access to the camera to take photos.
NSLocationWhenInUseUsageDescription
- This app needs access to the location to geolocalize your captures.
+
NSMicrophoneUsageDescription
This app needs access to the microphone to take videos.
+ NSPhotoLibraryAddUsageDescription
+ Your message to user when the photo library is accessed for the first time
NSPhotoLibraryUsageDescription
This app needs access to the photo library to save your captures.
UILaunchStoryboardName
@@ -39,24 +52,10 @@
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
+ UIInterfaceOrientationLandscapeLeft
UIViewControllerBasedStatusBarAppearance
- NSLocationWhenInUseUsageDescription
-
- NSAppTransportSecurity
-
-
- NSExceptionDomains
-
- localhost
-
- NSExceptionAllowsInsecureHTTPLoads
-
-
-
-
diff --git a/ios/RCTCameraManager.h b/ios/RCTCameraManager.h
index ad3b0a5..f57be0a 100644
--- a/ios/RCTCameraManager.h
+++ b/ios/RCTCameraManager.h
@@ -16,8 +16,7 @@ typedef NS_ENUM(NSInteger, RCTCameraCaptureSessionPreset) {
RCTCameraCaptureSessionPresetPhoto = 3,
RCTCameraCaptureSessionPreset480p = 4,
RCTCameraCaptureSessionPreset720p = 5,
- RCTCameraCaptureSessionPreset1080p = 6,
- RCTCameraCaptureSessionPresetPreview = 7
+ RCTCameraCaptureSessionPreset1080p = 6
};
typedef NS_ENUM(NSInteger, RCTCameraCaptureMode) {
@@ -72,11 +71,11 @@ typedef NS_ENUM(NSInteger, RCTCameraTorchMode) {
@property (nonatomic, assign) NSInteger videoTarget;
@property (nonatomic, assign) NSInteger orientation;
@property (nonatomic, assign) BOOL mirrorImage;
+@property (nonatomic, assign) BOOL cropToPreview;
@property (nonatomic, strong) NSArray* barCodeTypes;
@property (nonatomic, strong) RCTPromiseResolveBlock videoResolve;
@property (nonatomic, strong) RCTPromiseRejectBlock videoReject;
@property (nonatomic, strong) RCTCamera *camera;
-@property (nonatomic, assign) BOOL cropToViewport;
- (void)changeOrientation:(NSInteger)orientation;
diff --git a/ios/RCTCameraManager.m b/ios/RCTCameraManager.m
index 74cee13..d2e09c3 100644
--- a/ios/RCTCameraManager.m
+++ b/ios/RCTCameraManager.m
@@ -106,8 +106,7 @@ RCT_EXPORT_MODULE();
@"720p": @(RCTCameraCaptureSessionPreset720p),
@"AVCaptureSessionPreset1280x720": @(RCTCameraCaptureSessionPreset720p),
@"1080p": @(RCTCameraCaptureSessionPreset1080p),
- @"AVCaptureSessionPreset1920x1080": @(RCTCameraCaptureSessionPreset1080p),
- @"preview": @(RCTCameraCaptureSessionPresetPreview)
+ @"AVCaptureSessionPreset1920x1080": @(RCTCameraCaptureSessionPreset1080p)
},
@"CaptureTarget": @{
@"memory": @(RCTCameraCaptureTargetMemory),
@@ -141,7 +140,6 @@ RCT_EXPORT_VIEW_PROPERTY(onFocusChanged, BOOL);
RCT_EXPORT_VIEW_PROPERTY(onZoomChanged, BOOL);
RCT_CUSTOM_VIEW_PROPERTY(captureQuality, NSInteger, RCTCamera) {
- self.cropToViewport = false;
NSInteger quality = [RCTConvert NSInteger:json];
NSString *qualityString;
switch (quality) {
@@ -167,10 +165,6 @@ RCT_CUSTOM_VIEW_PROPERTY(captureQuality, NSInteger, RCTCamera) {
case RCTCameraCaptureSessionPreset480p:
qualityString = AVCaptureSessionPreset640x480;
break;
- case RCTCameraCaptureSessionPresetPreview:
- qualityString = AVCaptureSessionPresetPhoto;
- self.cropToViewport = true;
- break;
}
[self setCaptureQuality:qualityString];
@@ -300,6 +294,10 @@ RCT_CUSTOM_VIEW_PROPERTY(mirrorImage, BOOL, RCTCamera) {
self.mirrorImage = [RCTConvert BOOL:json];
}
+RCT_CUSTOM_VIEW_PROPERTY(cropToPreview, BOOL, RCTCamera) {
+ self.cropToPreview = [RCTConvert BOOL:json];
+}
+
RCT_CUSTOM_VIEW_PROPERTY(barCodeTypes, NSArray, RCTCamera) {
self.barCodeTypes = [RCTConvert NSArray:json];
}
@@ -630,6 +628,15 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
// create cgimage
CGImageRef cgImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
+ // Crop it (if capture quality is set to preview)
+ if (self.cropToPreview) {
+ CGSize viewportSize = CGSizeMake(self.previewLayer.frame.size.width, self.previewLayer.frame.size.height);
+ CGRect captureRect = CGRectMake(0, 0, CGImageGetWidth(cgImage), CGImageGetHeight(cgImage));
+ CGRect croppedSize = AVMakeRectWithAspectRatioInsideRect(viewportSize, captureRect);
+
+ cgImage = CGImageCreateWithImageInRect(cgImage, croppedSize);
+ }
+
// Rotate it
CGImageRef rotatedCGImage;
if ([options objectForKey:@"rotation"]) {
@@ -659,15 +666,6 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
rotatedCGImage = cgImage;
}
- // Crop it (if capture quality is set to preview)
- if (self.cropToViewport) {
- CGSize viewportSize = CGSizeMake(self.previewLayer.frame.size.width, self.previewLayer.frame.size.height);
- CGRect captureRect = CGRectMake(0, 0, CGImageGetWidth(rotatedCGImage), CGImageGetHeight(rotatedCGImage));
- CGRect croppedSize = AVMakeRectWithAspectRatioInsideRect(viewportSize, captureRect);
-
- rotatedCGImage = CGImageCreateWithImageInRect(rotatedCGImage, croppedSize);
- }
-
// Erase stupid TIFF stuff
[imageMetadata removeObjectForKey:(NSString *)kCGImagePropertyTIFFDictionary];