Merge pull request #145 from wix/updateCameraKitUsageIOS
fix bug with returning on previous screen
This commit is contained in:
commit
2cd1e257f2
@ -17,7 +17,6 @@
|
||||
#import "RCTConvert.h"
|
||||
#endif
|
||||
|
||||
|
||||
#import "CKCamera.h"
|
||||
#import "CKCameraOverlayView.h"
|
||||
#import "CKGalleryManager.h"
|
||||
@ -823,6 +822,15 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||
|
||||
#pragma mark - Frame for Scanner Settings
|
||||
|
||||
- (void)didMoveToWindow {
|
||||
[super didMoveToWindow];
|
||||
if (self.sessionRunning && self.dataReadingFrame) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self startAnimatingScanner:self.dataReadingFrame];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setScannerOptions:(NSDictionary *)scannerOptions {
|
||||
if (scannerOptions[offsetForScannerFrame]) {
|
||||
self.frameOffset = [scannerOptions[offsetForScannerFrame] floatValue];
|
||||
@ -830,7 +838,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||
if (scannerOptions[heightForScannerFrame]) {
|
||||
self.heightFrame = [scannerOptions[heightForScannerFrame] floatValue];
|
||||
}
|
||||
|
||||
if (scannerOptions[colorForFrame]) {
|
||||
UIColor *acolor = [RCTConvert UIColor:scannerOptions[colorForFrame]];
|
||||
self.frameColor = (acolor) ? acolor : [UIColor whiteColor];
|
||||
@ -839,18 +846,21 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||
|
||||
- (void)addFrameForScanner {
|
||||
CGFloat frameWidth = self.bounds.size.width - 2 * self.frameOffset;
|
||||
self.dataReadingFrame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frameWidth, self.heightFrame)]; //
|
||||
self.dataReadingFrame.backgroundColor = [UIColor clearColor];
|
||||
[self createCustomFramesForView:self.dataReadingFrame];
|
||||
[self addSubview:self.dataReadingFrame];
|
||||
//[self.cameraPreviewView.layer addSublayer:self.dataReadingFrame.layer];
|
||||
self.dataReadingFrame.center = self.center;
|
||||
|
||||
[self startAnimatingScanner:self.dataReadingFrame];
|
||||
[self addVisualEffects:self.dataReadingFrame.frame];
|
||||
|
||||
CGRect visibleRect = [self.previewLayer metadataOutputRectOfInterestForRect:self.dataReadingFrame.frame];
|
||||
self.metadataOutput.rectOfInterest = visibleRect;
|
||||
if (!self.dataReadingFrame) {
|
||||
self.dataReadingFrame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frameWidth, self.heightFrame)]; //
|
||||
self.dataReadingFrame.center = self.center;
|
||||
self.dataReadingFrame.backgroundColor = [UIColor clearColor];
|
||||
[self createCustomFramesForView:self.dataReadingFrame];
|
||||
[self addSubview:self.dataReadingFrame];
|
||||
|
||||
|
||||
[self startAnimatingScanner:self.dataReadingFrame];
|
||||
|
||||
[self addVisualEffects:self.dataReadingFrame.frame];
|
||||
|
||||
CGRect visibleRect = [self.previewLayer metadataOutputRectOfInterestForRect:self.dataReadingFrame.frame];
|
||||
self.metadataOutput.rectOfInterest = visibleRect;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createCustomFramesForView:(UIView *)frameView {
|
||||
@ -917,8 +927,13 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
|
||||
}
|
||||
|
||||
- (void)startAnimatingScanner:(UIView *)inputView {
|
||||
self.greenScanner = [[UIView alloc] initWithFrame:CGRectMake(2, 0, inputView.frame.size.width - 4, 2)];
|
||||
self.greenScanner.backgroundColor = [UIColor whiteColor];
|
||||
if (!self.greenScanner) {
|
||||
self.greenScanner = [[UIView alloc] initWithFrame:CGRectMake(2, 0, inputView.frame.size.width - 4, 2)];
|
||||
self.greenScanner.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
if (self.greenScanner.frame.origin.y != 0) {
|
||||
[self.greenScanner setFrame:CGRectMake(2, 0, inputView.frame.size.width - 4, 2)];
|
||||
}
|
||||
[inputView addSubview:self.greenScanner];
|
||||
[UIView animateWithDuration:3 delay:0 options:(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat) animations:^{
|
||||
CGFloat middleX = inputView.frame.size.width / 2;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user