Add internal prop determining if barcode scanner is wanted.
This commit is contained in:
parent
d15022d560
commit
b5af30248e
@ -17,6 +17,7 @@ public class RCTCamera {
|
||||
private final HashMap<Integer, CameraInfoWrapper> _cameraInfos;
|
||||
private final HashMap<Integer, Integer> _cameraTypeToIndex;
|
||||
private final Map<Number, Camera> _cameras;
|
||||
private boolean _barcodeScannerEnabled = false;
|
||||
private int _orientation = -1;
|
||||
private int _actualDeviceOrientation = 0;
|
||||
private int _adjustedDeviceOrientation = 0;
|
||||
@ -134,6 +135,14 @@ public class RCTCamera {
|
||||
adjustPreviewLayout(RCTCameraModule.RCT_CAMERA_TYPE_BACK);
|
||||
}
|
||||
|
||||
public boolean isBarcodeScannerEnabled() {
|
||||
return _barcodeScannerEnabled;
|
||||
}
|
||||
|
||||
public void setBarcodeScannerEnabled(boolean barcodeScannerEnabled) {
|
||||
_barcodeScannerEnabled = barcodeScannerEnabled;
|
||||
}
|
||||
|
||||
public int getActualDeviceOrientation() {
|
||||
return _actualDeviceOrientation;
|
||||
}
|
||||
|
||||
@ -105,6 +105,10 @@ public class RCTCameraView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBarcodeScannerEnabled(boolean barcodeScannerEnabled) {
|
||||
RCTCamera.getInstance().setBarcodeScannerEnabled(barcodeScannerEnabled);
|
||||
}
|
||||
|
||||
private boolean setActualDeviceOrientation(Context context) {
|
||||
int actualDeviceOrientation = getDeviceOrientation(context);
|
||||
if (_actualDeviceOrientation != actualDeviceOrientation) {
|
||||
|
||||
@ -61,4 +61,9 @@ public class RCTCameraViewManager extends ViewGroupManager<RCTCameraView> {
|
||||
public void setCaptureAudio(RCTCameraView view, boolean captureAudio) {
|
||||
// TODO - implement video mode
|
||||
}
|
||||
|
||||
@ReactProp(name = "barcodeScannerEnabled")
|
||||
public void setBarcodeScannerEnabled(RCTCameraView view, boolean barcodeScannerEnabled) {
|
||||
view.setBarcodeScannerEnabled(barcodeScannerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
3
index.js
3
index.js
@ -46,6 +46,8 @@ function convertNativeProps(props) {
|
||||
newProps.barCodeTypes = [];
|
||||
}
|
||||
|
||||
newProps.barcodeScannerEnabled = typeof props.onBarCodeRead === 'function'
|
||||
|
||||
return newProps;
|
||||
}
|
||||
|
||||
@ -89,6 +91,7 @@ export default class Camera extends Component {
|
||||
]),
|
||||
keepAwake: PropTypes.bool,
|
||||
onBarCodeRead: PropTypes.func,
|
||||
barcodeScannerEnabled: PropTypes.bool,
|
||||
onFocusChanged: PropTypes.func,
|
||||
onZoomChanged: PropTypes.func,
|
||||
mirrorImage: PropTypes.bool,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user