This commit is contained in:
Dmytro Ponomarenko 2018-03-01 16:05:04 +02:00
parent 8d525cea05
commit ce3fd49580
3 changed files with 12 additions and 10 deletions

View File

@ -35,7 +35,7 @@ export default class CameraScreen extends Component {
laserColor={"blue"}
frameColor={"yellow"}
onReadCode={((event) => Alert.alert(`Qr code found ${event.nativeEvent.qrcodeStringValue} `))}
onReadCode={((event) => Alert.alert(`Qr code found ${event.nativeEvent.codeStringValue} `))}
hideControls={true}
isShowFrameForScanner={true}
// offsetForScannerFrame = {10}

View File

@ -85,7 +85,7 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
@property (nonatomic) AVCaptureMovieFileOutput *movieFileOutput;
@property (nonatomic) AVCaptureStillImageOutput *stillImageOutput;
@property (nonatomic, strong) AVCaptureMetadataOutput *metadataOutput;
@property (nonatomic, strong) NSString *qrcodeStringValue;
@property (nonatomic, strong) NSString *codeStringValue;
// utilities
@ -1050,9 +1050,9 @@ didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadataObjects
if ([metadataObject isKindOfClass:[AVMetadataMachineReadableCodeObject class]] && [self isSupportedBarCodeType:metadataObject.type]) {
AVMetadataMachineReadableCodeObject *code = (AVMetadataMachineReadableCodeObject*)[self.previewLayer transformedMetadataObjectForMetadataObject:metadataObject];
if (self.onReadCode && code.stringValue && ![code.stringValue isEqualToString:self.qrcodeStringValue]) {
self.qrcodeStringValue = code.stringValue;
self.onReadCode(@{@"qrcodeStringValue": code.stringValue});
if (self.onReadCode && code.stringValue && ![code.stringValue isEqualToString:self.codeStringValue]) {
self.codeStringValue = code.stringValue;
self.onReadCode(@{@"codeStringValue": code.stringValue});
[self stopAnimatingScanner];
}
}

View File

@ -21,6 +21,8 @@ const FLASH_MODE_AUTO = 'auto';
const FLASH_MODE_ON = 'on';
const FLASH_MODE_OFF = 'off';
const OVERLAY_DEFAULT_COLOR = '#ffffff77';
const OFFSET_FRAME = 30;
const FRAME_HEIGHT = 200;
export default class CameraScreenBase extends Component {
@ -100,13 +102,13 @@ export default class CameraScreenBase extends Component {
}
getScannerOptions() {
const scannerOptions = this.props.scannerOptions || {}
scannerOptions.offsetFrame = this.props.offsetForScannerFrame || 30
scannerOptions.frameHeight = this.props.heightForScannerFrame || 200
const scannerOptions = this.props.scannerOptions || {};
scannerOptions.offsetFrame = this.props.offsetForScannerFrame || OFFSET_FRAME;
scannerOptions.frameHeight = this.props.heightForScannerFrame || FRAME_HEIGHT;
if (this.props.colorForScannerFrame) {
scannerOptions.colorForFrame = processColor(this.props.colorForScannerFrame)
scannerOptions.colorForFrame = processColor(this.props.colorForScannerFrame);
} else {
scannerOptions.colorForFrame = processColor("white")
scannerOptions.colorForFrame = processColor("white");
}
return scannerOptions;
}