parent
7a12d7841d
commit
1d48cb0c71
|
@ -68,7 +68,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
#define CAMERA_OPTION_ON_READ_QR_CODE @"onReadQRCode"
|
||||
#define TIMER_FOCUS_TIME_SECONDS 5
|
||||
|
||||
@interface CKCamera () <AVCaptureFileOutputRecordingDelegate, AVCaptureMetadataOutputObjectsDelegate>
|
||||
@interface CKCamera () <AVCaptureMetadataOutputObjectsDelegate>
|
||||
|
||||
|
||||
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;
|
||||
|
@ -121,7 +121,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
- (void)dealloc
|
||||
{
|
||||
[self removeObservers];
|
||||
//NSLog(@"dealloc");
|
||||
// NSLog(@"dealloc");
|
||||
}
|
||||
|
||||
-(PHFetchOptions *)fetchOptions {
|
||||
|
@ -140,9 +140,9 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
[subview removeFromSuperview];
|
||||
[super removeReactSubview:subview];
|
||||
}
|
||||
|
||||
|
||||
- (void)removeFromSuperview
|
||||
{
|
||||
|
||||
|
@ -156,7 +156,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
|
||||
|
@ -175,7 +174,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
[self.layer addSublayer:self.previewLayer];
|
||||
self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
|
||||
#endif
|
||||
|
||||
UIView *focusView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
focusView.backgroundColor = [UIColor clearColor];
|
||||
focusView.layer.borderColor = [UIColor yellowColor].CGColor;
|
||||
|
@ -194,7 +192,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(void)setCameraOptions:(NSDictionary *)cameraOptions {
|
||||
_cameraOptions = cameraOptions;
|
||||
|
||||
|
@ -246,7 +243,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
// }
|
||||
}
|
||||
|
||||
|
||||
-(void)setupCaptionSession {
|
||||
// Setup the capture session.
|
||||
// In general it is not safe to mutate an AVCaptureSession or any of its inputs, outputs, or connections from multiple threads at the same time.
|
||||
|
@ -298,17 +294,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
self.setupResult = CKSetupResultSessionConfigurationFailed;
|
||||
}
|
||||
|
||||
[self.session commitConfiguration];
|
||||
|
||||
[self setOnReadCode:self.onReadCode];
|
||||
} );
|
||||
}
|
||||
|
||||
-(void)setOnReadCode:(RCTDirectEventBlock)onReadCode
|
||||
{
|
||||
if (onReadCode) {
|
||||
_onReadCode = onReadCode;
|
||||
|
||||
AVCaptureMetadataOutput * output = [[AVCaptureMetadataOutput alloc] init];
|
||||
if ([self.session canAddOutput:output]) {
|
||||
self.metadataOutput = output;
|
||||
|
@ -316,7 +301,10 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
[self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
|
||||
[self.metadataOutput setMetadataObjectTypes:[self.metadataOutput availableMetadataObjectTypes]];
|
||||
}
|
||||
}
|
||||
|
||||
[self.session commitConfiguration];
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
-(void)handleCameraPermission {
|
||||
|
@ -817,9 +805,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
|||
|
||||
+(CGSize)cropImageToPreviewSize:(UIImage*)image size:(CGSize)previewSize {
|
||||
|
||||
CGRect ans = CGRectZero;
|
||||
CGSize centerSize = CGSizeZero;
|
||||
|
||||
float imageToPreviewWidthScale = image.size.width/previewSize.width;
|
||||
float imageToPreviewHeightScale = image.size.width/previewSize.width;
|
||||
|
||||
|
@ -1092,8 +1077,8 @@ didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadataObjects
|
|||
for(AVMetadataObject *metadataObject in metadataObjects)
|
||||
{
|
||||
if ([metadataObject isKindOfClass:[AVMetadataMachineReadableCodeObject class]] && [self isSupportedBarCodeType:metadataObject.type]) {
|
||||
AVMetadataMachineReadableCodeObject *code = (AVMetadataMachineReadableCodeObject*)[self.previewLayer transformedMetadataObjectForMetadataObject:metadataObject];
|
||||
|
||||
AVMetadataMachineReadableCodeObject *code = (AVMetadataMachineReadableCodeObject*)[self.previewLayer transformedMetadataObjectForMetadataObject:metadataObject];
|
||||
if (self.onReadCode && code.stringValue && ![code.stringValue isEqualToString:self.codeStringValue]) {
|
||||
self.onReadCode(@{@"codeStringValue": code.stringValue});
|
||||
[self stopAnimatingScanner];
|
||||
|
@ -1124,7 +1109,5 @@ const NSString *colorForFrame = @"colorForFrame";
|
|||
const NSString *isNeedMultipleScanBarcode = @"isNeedMultipleScanBarcode";
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue