react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
92 lines (91 loc) • 4.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ScanbotDocumentScannerView = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _ScanbotDocumentScannerViewNativeComponent = _interopRequireWildcard(require("../spec/ScanbotDocumentScannerViewNativeComponent"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const ScanbotDocumentScannerView = exports.ScanbotDocumentScannerView = /*#__PURE__*/(0, _react.forwardRef)(({
onDocumentScannerResult,
onDetectionResult,
...props
}, forwardedRef) => {
const viewRef = (0, _react.useRef)(null);
(0, _react.useImperativeHandle)(forwardedRef, () => {
return {
freezeCamera() {
if (viewRef.current) {
_ScanbotDocumentScannerViewNativeComponent.Commands.freezeCamera(viewRef.current);
}
},
unfreezeCamera() {
if (viewRef.current) {
_ScanbotDocumentScannerViewNativeComponent.Commands.unfreezeCamera(viewRef.current);
}
},
snapDocument() {
if (viewRef.current) {
_ScanbotDocumentScannerViewNativeComponent.Commands.snapDocument(viewRef.current);
}
}
};
}, []);
const _onDocumentScannerResult = (0, _react.useCallback)(event => {
const result = event.nativeEvent.result;
if (result) {
onDocumentScannerResult(result);
}
}, [onDocumentScannerResult]);
const _onDetectionResult = (0, _react.useCallback)(event => {
if (event.nativeEvent.result) {
onDetectionResult && onDetectionResult(_reactNative.Platform.OS === 'ios' ? JSON.parse(event.nativeEvent.result) : event.nativeEvent.result);
}
}, [onDetectionResult]);
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
style: [styles.container, props.style]
}, /*#__PURE__*/_react.default.createElement(_ScanbotDocumentScannerViewNativeComponent.default, {
ref: viewRef,
style: styles.container,
onDocumentScannerResult: _onDocumentScannerResult,
onDetectionResult: _onDetectionResult,
acceptedAngleScore: props.acceptedAngleScore,
acceptedBrightnessThreshold: props.acceptedBrightnessThreshold,
acceptedSizeScore: props.acceptedSizeScore,
autoSnappingEnabled: props.autoSnappingEnabled,
autoSnappingSensitivity: props.autoSnappingSensitivity,
autoSnappingDelay: props.autoSnappingDelay,
cameraModule: props.cameraModule,
cameraPreviewMode: props.cameraPreviewMode,
flashEnabled: props.flashEnabled,
ignoreBadAspectRatio: props.ignoreBadAspectRatio,
photoQualityPrioritization: props.photoQualityPrioritization,
touchToFocusEnabled: props.touchToFocusEnabled,
requiredAspectRatios: props.requiredAspectRatios,
finderEnabled: props.finderEnabled,
finderLineColor: props.finderLineColor,
finderLineWidth: props.finderLineWidth,
finderOverlayColor: props.finderOverlayColor,
finderCornerRadius: props.finderCornerRadius,
finderMinimumPadding: props.finderMinimumPadding,
finderAspectRatio: props.finderAspectRatio,
polygonEnabled: props.polygonEnabled,
polygonBackgroundColor: props.polygonBackgroundColor,
polygonBackgroundColorOK: props.polygonBackgroundColorOK,
polygonColor: props.polygonColor,
polygonColorOK: props.polygonColorOK,
polygonLineWidth: props.polygonLineWidth,
polygonCornerRadius: props.polygonCornerRadius,
polygonAutoSnapProgressColor: props.polygonAutoSnapProgressColor,
polygonAutoSnapProgressLineWidth: props.polygonAutoSnapProgressLineWidth,
polygonAutoSnapProgressEnabled: props.polygonAutoSnapProgressEnabled
}));
});
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
}
});
//# sourceMappingURL=ScanbotDocumentScannerView.js.map