Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BarcodeScanner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

import React from 'react';
import { Component, PropTypes} from 'react';
import {
requireNativeComponent,
Expand All @@ -12,7 +13,6 @@ import Viewfinder from './Viewfinder';
class BarcodeScannerView extends Component {
constructor(props) {
super(props);

this.onChange = this.onChange.bind(this);
}

Expand Down Expand Up @@ -57,6 +57,7 @@ BarcodeScannerView.propTypes = {
showLoadingIndicator: PropTypes.bool,
showViewFinder: PropTypes.bool,
torchMode: PropTypes.string,
autoFocus: PropTypes.string,
viewFinderBackgroundColor: PropTypes.string,
viewFinderBorderColor: PropTypes.string,
viewFinderBorderWidth: PropTypes.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class BarcodeScannerManager extends ViewGroupManager<BarcodeScannerView>
private static final String REACT_CLASS = "RNBarcodeScannerView";

private static final String DEFAULT_TORCH_MODE = "off";
private static final String DEFAULT_FOCUS_MODE = "on";
private static final String DEFAULT_CAMERA_TYPE = "back";

private BarcodeScannerView mScannerView;
Expand All @@ -38,12 +39,20 @@ public void setTorchMode(BarcodeScannerView view, @Nullable String torchMode) {
}
}

@ReactProp(name = "autoFocus")
public void setAutoFocus(BarcodeScannerView view, @Nullable String autoFocus) {
if (autoFocus != null) {
view.setFocus(autoFocus.equals("on"));
}
}

@Override
public BarcodeScannerView createViewInstance(ThemedReactContext context) {
context.addLifecycleEventListener(this);
mScannerView = new BarcodeScannerView(context);
mScannerView.setCameraType(DEFAULT_CAMERA_TYPE);
mScannerView.setFlash(DEFAULT_TORCH_MODE.equals("on"));
mScannerView.setFocus(DEFAULT_FOCUS_MODE.equals("on"));
mScannerViewVisible = true;
return mScannerView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public void setFlash(boolean flag) {
mPreview.setFlash(flag);
}

public void setFocus(boolean flag) {
mPreview.setAutoFocus(flag);
}

public void stopCamera() {
mPreview.stopCamera();
}
Expand Down