Merge pull request #1463 from react-native-community/fix/barcode-default-prop

fix(barcode-prop): fix default value and add more values
This commit is contained in:
João Guilherme Fidelis 2018-04-13 13:18:48 -03:00 committed by GitHub
commit f2e9ef950f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -31,6 +31,21 @@ public class BarcodeFormatUtils {
map.put(Barcode.UPC_E, "UPC_E"); map.put(Barcode.UPC_E, "UPC_E");
map.put(Barcode.PDF417, "PDF417"); map.put(Barcode.PDF417, "PDF417");
map.put(Barcode.AZTEC, "AZTEC"); map.put(Barcode.AZTEC, "AZTEC");
map.put(Barcode.ALL_FORMATS, "ALL");
map.put(Barcode.CALENDAR_EVENT, "CALENDAR_EVENT");
map.put(Barcode.CONTACT_INFO, "CONTACT_INFO");
map.put(Barcode.DRIVER_LICENSE, "DRIVER_LICENSE");
map.put(Barcode.EMAIL, "EMAIL");
map.put(Barcode.GEO, "GEO");
map.put(Barcode.ISBN, "ISBN");
map.put(Barcode.PHONE, "PHONE");
map.put(Barcode.PRODUCT, "PRODUCT");
map.put(Barcode.SMS, "SMS");
map.put(Barcode.TEXT, "TEXT");
map.put(Barcode.UPC_A, "UPC_A");
map.put(Barcode.URL, "URL");
map.put(Barcode.WIFI, "WIFI");
map.put(-1, "None");
FORMATS = map; FORMATS = map;
@ -40,7 +55,6 @@ public class BarcodeFormatUtils {
rmap.put(map.valueAt(i), map.keyAt(i)); rmap.put(map.valueAt(i), map.keyAt(i));
} }
rmap.put("ALL", 0);
REVERSE_FORMATS = Collections.unmodifiableMap(rmap); REVERSE_FORMATS = Collections.unmodifiableMap(rmap);
} }

View File

@ -59,7 +59,7 @@ type EventCallbackArgumentsType = {
nativeEvent: Object, nativeEvent: Object,
}; };
type PropsType = (typeof View.props) & { type PropsType = typeof View.props & {
zoom?: number, zoom?: number,
ratio?: string, ratio?: string,
focusDepth?: number, focusDepth?: number,
@ -87,7 +87,6 @@ type StateType = {
isAuthorizationChecked: boolean, isAuthorizationChecked: boolean,
}; };
const CameraManager: Object = NativeModules.RNCameraManager || const CameraManager: Object = NativeModules.RNCameraManager ||
NativeModules.RNCameraModule || { NativeModules.RNCameraModule || {
stubbed: true, stubbed: true,
@ -114,7 +113,7 @@ const CameraManager: Object = NativeModules.RNCameraManager ||
}, },
GoogleVisionBarcodeDetection: { GoogleVisionBarcodeDetection: {
BarcodeType: 0, BarcodeType: 0,
} },
}; };
const EventThrottleMs = 500; const EventThrottleMs = 500;
@ -183,7 +182,8 @@ export default class Camera extends React.Component<PropsType, StateType> {
whiteBalance: CameraManager.WhiteBalance.auto, whiteBalance: CameraManager.WhiteBalance.auto,
faceDetectionMode: (CameraManager.FaceDetection || {}).fast, faceDetectionMode: (CameraManager.FaceDetection || {}).fast,
barCodeTypes: Object.values(CameraManager.BarCodeType), barCodeTypes: Object.values(CameraManager.BarCodeType),
googleVisionBarcodeType: (CameraManager.GoogleVisionBarcodeDetection || {}).BarcodeType, googleVisionBarcodeType: ((CameraManager.GoogleVisionBarcodeDetection || {}).BarcodeType || {})
.None,
faceDetectionLandmarks: ((CameraManager.FaceDetection || {}).Landmarks || {}).none, faceDetectionLandmarks: ((CameraManager.FaceDetection || {}).Landmarks || {}).none,
faceDetectionClassifications: ((CameraManager.FaceDetection || {}).Classifications || {}).none, faceDetectionClassifications: ((CameraManager.FaceDetection || {}).Classifications || {}).none,
permissionDialogTitle: '', permissionDialogTitle: '',
@ -330,7 +330,9 @@ export default class Camera extends React.Component<PropsType, StateType> {
ref={this._setReference} ref={this._setReference}
onMountError={this._onMountError} onMountError={this._onMountError}
onCameraReady={this._onCameraReady} onCameraReady={this._onCameraReady}
onGoogleVisionBarcodesDetected={this._onObjectDetected(this.props.onGoogleVisionBarcodesDetected)} onGoogleVisionBarcodesDetected={this._onObjectDetected(
this.props.onGoogleVisionBarcodesDetected,
)}
onBarCodeRead={this._onObjectDetected(this.props.onBarCodeRead)} onBarCodeRead={this._onObjectDetected(this.props.onBarCodeRead)}
onFacesDetected={this._onObjectDetected(this.props.onFacesDetected)} onFacesDetected={this._onObjectDetected(this.props.onFacesDetected)}
onTextRecognized={this._onObjectDetected(this.props.onTextRecognized)} onTextRecognized={this._onObjectDetected(this.props.onTextRecognized)}