react-native-scanbot-barcode-scanner-sdk 4.2.0 → 4.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries.txt +31 -31
- package/RNScanbotBarcodeSDK.podspec +1 -4
- package/android/build.gradle +6 -5
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.kt +9 -7
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerView.kt +114 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewEvents.kt +56 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewManager.kt +256 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/JSONObject.kt +18 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/ReadableMap.kt +3 -4
- package/android/src/newarch/ScanbotBarcodeScannerViewManagerSpec.kt +19 -0
- package/android/src/oldarch/ScanbotBarcodeScannerViewManagerSpec.kt +29 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraView.d.ts +3 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraView.js +122 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.d.ts +89 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.js +2 -0
- package/dist/components/spec/ScanbotBarcodeScannerViewNativeComponent.d.ts +54 -0
- package/dist/components/spec/ScanbotBarcodeScannerViewNativeComponent.js +12 -0
- package/dist/configurations.d.ts +241 -0
- package/dist/configurations.js +2 -0
- package/dist/customConfigurations.d.ts +94 -0
- package/dist/customConfigurations.js +2 -0
- package/dist/customResults.d.ts +5 -0
- package/dist/customResults.js +2 -0
- package/dist/customTypes.d.ts +7 -0
- package/dist/customTypes.js +2 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +34 -0
- package/dist/results.d.ts +29 -0
- package/dist/results.js +2 -0
- package/dist/types.d.ts +1194 -0
- package/dist/types.js +2 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.h +25 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.m +194 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.h +20 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.mm +259 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.h +99 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.m +196 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewManager.mm +73 -0
- package/package.json +16 -21
- package/src/components/barcode-camera-view/ScanbotBarcodeCameraView.tsx +112 -0
- package/src/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.ts +106 -0
- package/src/components/spec/ScanbotBarcodeScannerViewNativeComponent.ts +59 -0
- package/src/index.ts +58 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +0 -401
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventEmitter.java +0 -78
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventReceiver.java +0 -119
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/ui/ScanbotViewWrapper.java +0 -26
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.kt +0 -24
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +0 -43
- package/android/src/new-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +0 -125
- package/android/src/old-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +0 -114
- package/index.d.ts +0 -42
- package/index.js +0 -20
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.h +0 -44
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.mm +0 -338
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraViewManager.mm +0 -71
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.h +0 -36
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.mm +0 -181
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraViewManager.h +0 -28
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraViewManager.mm +0 -89
- package/js/RTNScanbotBarcodeCameraViewNativeComponent.ts +0 -186
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.ts +0 -175
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +0 -270
- package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.ts +0 -7
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { BarcodeScannerResult } from '../../results';
|
|
4
|
-
import { AspectRatio, BarcodeDocumentFormat, BarcodeFormat, BarcodesExtensionFilter, CodeDensity, EngineMode, Gs1HandlingMode, MSIPlesseyChecksumAlgorithm } from '../../types';
|
|
5
|
-
|
|
6
|
-
export interface ScanbotBarcodeCameraViewProperties {
|
|
7
|
-
onBarcodeScannerResult?: (result: BarcodeScannerResult) => void;
|
|
8
|
-
configuration?: ScanbotBarcodeCameraViewConfiguration;
|
|
9
|
-
style: StyleProp<ViewStyle>;
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ScanbotBarcodeCameraNativeViewProperties {
|
|
14
|
-
onNativeBarcodeScannerResult?: (result: BarcodeScannerResult) => void;
|
|
15
|
-
requestComponentReload?: () => void;
|
|
16
|
-
configuration?: ScanbotBarcodeCameraViewConfiguration;
|
|
17
|
-
style: StyleProp<ViewStyle>;
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ScanbotBarcodeCameraViewBarcode {
|
|
22
|
-
text: string;
|
|
23
|
-
textWithExtension: string;
|
|
24
|
-
type: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* This class contians all the configurations needed for Scanbot Barcode Camera View.
|
|
29
|
-
*/
|
|
30
|
-
export interface ScanbotBarcodeCameraViewConfiguration extends FinderConfig, BarcodeAdditionalParameters {
|
|
31
|
-
/**
|
|
32
|
-
* Whether flash is toggled on or off.
|
|
33
|
-
*/
|
|
34
|
-
flashEnabled?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* List of accepted Barcode Formats; any formats that are not included in this
|
|
37
|
-
* list will not be detected by the `BarcodeCameraView`. By default, the list
|
|
38
|
-
* includes all supported barcode types.
|
|
39
|
-
*/
|
|
40
|
-
barcodeFormats?: BarcodeFormat[];
|
|
41
|
-
/**
|
|
42
|
-
* An optional array of barcode document formats that acts as a detection filter.
|
|
43
|
-
* By default all supported document formats will be detected.
|
|
44
|
-
*/
|
|
45
|
-
acceptedDocumentFormats?: BarcodeDocumentFormat[];
|
|
46
|
-
/**
|
|
47
|
-
* The engine mode of the barcode recognizer. Defaults to NEXT_GEN.
|
|
48
|
-
* To use legacy recognizer, please specify LEGACY
|
|
49
|
-
*/
|
|
50
|
-
engineMode?: EngineMode;
|
|
51
|
-
/**
|
|
52
|
-
* The relative initial zoom level of the camera in the range [0,1], where 0 is zoomed out and 1 is zoomed in.
|
|
53
|
-
* The default value is 0.-
|
|
54
|
-
*/
|
|
55
|
-
cameraZoomFactor?: number;
|
|
56
|
-
/**
|
|
57
|
-
* The extension filter for EAN and UPC barcodes.
|
|
58
|
-
*/
|
|
59
|
-
barcodesExtensionFilter?: BarcodesExtensionFilter;
|
|
60
|
-
/**
|
|
61
|
-
* Enable or disable barcode detection. If disabled, the camera preview is active but no barcodes will be detected.
|
|
62
|
-
* Default is enabled.
|
|
63
|
-
*/
|
|
64
|
-
scanningEnabled?: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* This class contains all the finder configurations.
|
|
69
|
-
*/
|
|
70
|
-
export interface FinderConfig {
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The finder view is a rectangular overlay view that clips the camera view,
|
|
74
|
-
* so that the detection will focus just a specific area. You can specify
|
|
75
|
-
* the size and positioning, as well as other UI properties.
|
|
76
|
-
* Set this property to `true` if you want to use the Finder View, `false` otherwise (default: false)
|
|
77
|
-
*/
|
|
78
|
-
shouldUseFinderView?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* The finder view rectangular overlay border width
|
|
81
|
-
*/
|
|
82
|
-
finderLineWidth?: number;
|
|
83
|
-
/**
|
|
84
|
-
* The finder view rectangular overlay border color
|
|
85
|
-
*/
|
|
86
|
-
finderLineColor?: string;
|
|
87
|
-
/**
|
|
88
|
-
* The overlay background color, around the finder view rectangle
|
|
89
|
-
*/
|
|
90
|
-
finderBackgroundColor?: string;
|
|
91
|
-
/**
|
|
92
|
-
* The overlay background color opacity, around the finder view rectangle
|
|
93
|
-
*/
|
|
94
|
-
finderBackgroundOpacity?: number;
|
|
95
|
-
/**
|
|
96
|
-
* The finder view rectangle aspect ratio
|
|
97
|
-
*/
|
|
98
|
-
finderAspectRatio?: AspectRatio;
|
|
99
|
-
/**
|
|
100
|
-
* Set the finderInsets left, top, bottom, right
|
|
101
|
-
*/
|
|
102
|
-
finderInset?: FinderInset
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* This class contains properties to Set the finder insets for the finder view.
|
|
107
|
-
*/
|
|
108
|
-
export interface FinderInset {
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* set the left inset
|
|
112
|
-
*/
|
|
113
|
-
left: number;
|
|
114
|
-
/**
|
|
115
|
-
* set the top inset
|
|
116
|
-
*/
|
|
117
|
-
top: number;
|
|
118
|
-
/**
|
|
119
|
-
* set the bottom inset
|
|
120
|
-
*/
|
|
121
|
-
bottom: number;
|
|
122
|
-
/**
|
|
123
|
-
* set the right inset
|
|
124
|
-
*/
|
|
125
|
-
right: number;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* An interface that contains additional parameters for barcodes detection and filtering.
|
|
130
|
-
*/
|
|
131
|
-
export interface BarcodeAdditionalParameters {
|
|
132
|
-
/**
|
|
133
|
-
* If `true`, enables the mode which slightly decreases the scanning quality and the energy consumption, thus increasing the scanning speed.
|
|
134
|
-
* The default is `false`.
|
|
135
|
-
* Android only.
|
|
136
|
-
*/
|
|
137
|
-
lowPowerMode?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Optional minimum required text length of the detected barcode.
|
|
140
|
-
* The default is 0 (setting is turned off).
|
|
141
|
-
* NOTE: This feature works on ITF and MSI Plessey barcodes only.
|
|
142
|
-
*/
|
|
143
|
-
minimumTextLength?: number;
|
|
144
|
-
/**
|
|
145
|
-
* Optional maximum required text length of the detected barcode.
|
|
146
|
-
* The default is 0 (setting is turned off).
|
|
147
|
-
* NOTE: This feature works on ITF and MSI Plessey barcodes only.
|
|
148
|
-
*/
|
|
149
|
-
maximumTextLength?: number;
|
|
150
|
-
/**
|
|
151
|
-
* Optional minimum required quiet zone on the barcode.
|
|
152
|
-
* Measured in modules (the size of narrowest bar in the barcode).
|
|
153
|
-
* The default is 10.
|
|
154
|
-
* NOTE: This feature works on ITF and MSI Plessey barcodes only.
|
|
155
|
-
*/
|
|
156
|
-
minimum1DBarcodesQuietZone?: number;
|
|
157
|
-
/**
|
|
158
|
-
* With this option enabled, the scanner removes check digits for UPC, EAN and MSI Plessey codes.
|
|
159
|
-
* Has no effect if both single and double digit MSI Plessey checksums are enabled.
|
|
160
|
-
* The default is `false`.
|
|
161
|
-
*/
|
|
162
|
-
stripCheckDigits?: boolean;
|
|
163
|
-
/** The GS1 handling mode. The default value is PARSE. */
|
|
164
|
-
gs1HandlingMode?: Gs1HandlingMode;
|
|
165
|
-
/**
|
|
166
|
-
* The checksum algorithm for MSI Plessey barcodes.
|
|
167
|
-
* The default value is MSIPlesseyChecksumAlgorithm.MOD_10.
|
|
168
|
-
*/
|
|
169
|
-
msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
|
|
170
|
-
/**
|
|
171
|
-
* Low density. Finds up to 6 QR codes in one image or video frame. This is the default value.
|
|
172
|
-
* High density. Finds up to 24 QR codes in one image or video frame.
|
|
173
|
-
*/
|
|
174
|
-
codeDensity?: CodeDensity;
|
|
175
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EmitterSubscription, findNodeHandle, NativeMethods, Platform } from 'react-native';
|
|
3
|
-
import { Dimensions } from 'react-native';
|
|
4
|
-
import { ScanbotBarcodeCameraNativeViewProperties, ScanbotBarcodeCameraViewConfiguration, ScanbotBarcodeCameraViewProperties } from './scanbot-barcode-camera-view-types';
|
|
5
|
-
import ScanbotNativeBarcodeCameraView, { BarcodeCameraViewNativeCommands } from './scanbot-native-barcode-camera-view';
|
|
6
|
-
|
|
7
|
-
import { BarcodeScannerResult } from '../../results';
|
|
8
|
-
|
|
9
|
-
const Device = {
|
|
10
|
-
isPortrait: () => {
|
|
11
|
-
const dim = Dimensions.get('screen');
|
|
12
|
-
return dim.height >= dim.width;
|
|
13
|
-
},
|
|
14
|
-
isLandscape: () => {
|
|
15
|
-
const dim = Dimensions.get('screen');
|
|
16
|
-
return dim.width >= dim.height;
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
interface ScanbotBarcodeCameraViewState {
|
|
21
|
-
orientation: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type Properties = ScanbotBarcodeCameraViewProperties;
|
|
25
|
-
export class ScanbotBarcodeCameraView extends React.Component<Properties, {}> {
|
|
26
|
-
|
|
27
|
-
// Camera View Reference
|
|
28
|
-
cameraViewReference: React.RefObject<React.Component<ScanbotBarcodeCameraNativeViewProperties> & Readonly<NativeMethods>>
|
|
29
|
-
|
|
30
|
-
// String length of auto-generated component key
|
|
31
|
-
static UNIQUE_VIEW_KEY_LENGTH = 6;
|
|
32
|
-
|
|
33
|
-
// Listener for orientation changes
|
|
34
|
-
dimensionsChangeSubscription: EmitterSubscription | null = null;
|
|
35
|
-
|
|
36
|
-
// This attribute allows us to retrieve a key for the component depending on the current state.
|
|
37
|
-
// If the component has been invalidated, it returns a new key and the view gets recreated,
|
|
38
|
-
// otherwise it uses the last generated one
|
|
39
|
-
_cameraKey = '';
|
|
40
|
-
get cameraKey(): string {
|
|
41
|
-
if (!this.isDirty) {
|
|
42
|
-
return this._cameraKey;
|
|
43
|
-
}
|
|
44
|
-
this.isDirty = false;
|
|
45
|
-
this._cameraKey = ScanbotBarcodeCameraView.getRandomId(
|
|
46
|
-
ScanbotBarcodeCameraView.UNIQUE_VIEW_KEY_LENGTH,
|
|
47
|
-
);
|
|
48
|
-
return this._cameraKey;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// We keep track of the state of children components, so that we can re-render the component
|
|
52
|
-
// in some special cases (Android)
|
|
53
|
-
previousChildrenIds: string[] = [];
|
|
54
|
-
get childrenIds(): string[] {
|
|
55
|
-
const children = this.props.children
|
|
56
|
-
? React.Children.map(this.props.children, child => child)
|
|
57
|
-
: [];
|
|
58
|
-
|
|
59
|
-
return children?.map((c: any) => `${c.type.name}-${c.key}`) ?? [];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// When true, a new component key will be generated on the next render,
|
|
63
|
-
// causing the component to be recreated
|
|
64
|
-
isDirty = true;
|
|
65
|
-
|
|
66
|
-
state: ScanbotBarcodeCameraViewState = {
|
|
67
|
-
orientation: Device.isPortrait() ? 'portrait' : 'landscape',
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
constructor(props: ScanbotBarcodeCameraViewProperties) {
|
|
71
|
-
super(props);
|
|
72
|
-
this.cameraViewReference = React.createRef();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Returns a random string ID of the given length
|
|
76
|
-
static getRandomId(
|
|
77
|
-
length: number = ScanbotBarcodeCameraView.UNIQUE_VIEW_KEY_LENGTH,
|
|
78
|
-
): string {
|
|
79
|
-
let result = '';
|
|
80
|
-
const characters =
|
|
81
|
-
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
82
|
-
const charactersLength = characters.length;
|
|
83
|
-
for (let i = 0; i < length; i++) {
|
|
84
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Event Listener for orientation changes
|
|
90
|
-
orientationChangeHandler = () => {
|
|
91
|
-
this.sendCommandToCameraView("orientationChanged");
|
|
92
|
-
this._invalidate();
|
|
93
|
-
this.setState({
|
|
94
|
-
orientation: Device.isPortrait() ? 'portrait' : 'landscape',
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
receiveEvent(event: any) {}
|
|
99
|
-
|
|
100
|
-
// Maps the native bridge callback event from the Barcode Scanner
|
|
101
|
-
_onBarcodeScannerResult = (event: any) => {
|
|
102
|
-
if (!this.props.onBarcodeScannerResult) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let outResult: BarcodeScannerResult | undefined = undefined;
|
|
107
|
-
if (Platform.OS === 'ios') {
|
|
108
|
-
// The new-architecture Fabric Component callback returns a JSON string as a result
|
|
109
|
-
if (event.nativeEvent.jsonResult) {
|
|
110
|
-
outResult = JSON.parse(event.nativeEvent.jsonResult)?.result;
|
|
111
|
-
} else {
|
|
112
|
-
// Support for the old architecture
|
|
113
|
-
outResult = event.nativeEvent.result;
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
outResult = event.nativeEvent.result;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (outResult) {
|
|
120
|
-
this.props.onBarcodeScannerResult(outResult);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
render() {
|
|
125
|
-
|
|
126
|
-
this.evaluateComponentState();
|
|
127
|
-
|
|
128
|
-
const style = this.preprocessStyle();
|
|
129
|
-
const props = this.preprocessProps();
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<ScanbotNativeBarcodeCameraView
|
|
133
|
-
{...props}
|
|
134
|
-
style={style}
|
|
135
|
-
key={this.cameraKey}
|
|
136
|
-
ref={this.cameraViewReference}
|
|
137
|
-
onNativeBarcodeScannerResult={this._onBarcodeScannerResult}
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
componentDidMount() {
|
|
143
|
-
this.registerDimensionsListener();
|
|
144
|
-
this.previousChildrenIds = this.childrenIds;
|
|
145
|
-
this.sendCommandToCameraView("componentDidMount");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
componentDidUpdate() {
|
|
149
|
-
this.sendCommandToCameraView("componentDidUpdate");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
componentWillUnmount() {
|
|
153
|
-
this.unregisterDimensionsListener();
|
|
154
|
-
this.previousChildrenIds = [];
|
|
155
|
-
this.sendCommandToCameraView("componentWillUnmount");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
evaluateComponentState = () => {
|
|
159
|
-
// We want to force a re-layout every time new children are added or removed
|
|
160
|
-
// from the BarcodeCameraView on Android; this will allow the native code to
|
|
161
|
-
// re-compute the size of every view inside the layout
|
|
162
|
-
if (Platform.OS === 'android') {
|
|
163
|
-
const currentChildrenIds = this.childrenIds;
|
|
164
|
-
|
|
165
|
-
const invalidate = () => {
|
|
166
|
-
this._invalidate();
|
|
167
|
-
this.previousChildrenIds = currentChildrenIds;
|
|
168
|
-
};
|
|
169
|
-
if (currentChildrenIds.length !== this.previousChildrenIds.length) {
|
|
170
|
-
invalidate();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
for (let i = 0; i < this.previousChildrenIds.length; i++) {
|
|
175
|
-
const previous = this.previousChildrenIds[i];
|
|
176
|
-
const current = currentChildrenIds[i];
|
|
177
|
-
if (previous !== current) {
|
|
178
|
-
invalidate();
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
preprocessStyle = () => {
|
|
186
|
-
const style = this.props.style as any;
|
|
187
|
-
const newStyle = { ...style } || {};
|
|
188
|
-
// Override / Define styles here
|
|
189
|
-
return newStyle;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
sanitizeNumbers = (obj: ScanbotBarcodeCameraViewConfiguration) => {
|
|
193
|
-
const outObj = {...obj};
|
|
194
|
-
outObj.cameraZoomFactor = obj.cameraZoomFactor ?? -1;
|
|
195
|
-
outObj.finderAspectRatio = obj.finderAspectRatio ?? { width: -1, height: -1 };
|
|
196
|
-
outObj.finderBackgroundOpacity = obj.finderBackgroundOpacity ?? -1;
|
|
197
|
-
outObj.finderInset = obj.finderInset ?? { left: -1, top: -1, bottom: -1, right: -1 };
|
|
198
|
-
outObj.finderLineWidth = obj.finderLineWidth ?? -1;
|
|
199
|
-
outObj.maximumTextLength = obj.maximumTextLength ?? -1;
|
|
200
|
-
outObj.minimumTextLength = obj.minimumTextLength ?? -1;
|
|
201
|
-
outObj.minimum1DBarcodesQuietZone = obj.minimum1DBarcodesQuietZone ?? -1;
|
|
202
|
-
|
|
203
|
-
return outObj;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
preprocessProps = () => {
|
|
207
|
-
const props = { ...this.props };
|
|
208
|
-
delete props.style;
|
|
209
|
-
|
|
210
|
-
const config = props.configuration;
|
|
211
|
-
if (config != null) {
|
|
212
|
-
props.configuration = this.sanitizeNumbers(config as any);
|
|
213
|
-
|
|
214
|
-
// When using new arch on iOS platform, if we don't specify default values for boolean properties all of them will be
|
|
215
|
-
// considered as false while code genenarion
|
|
216
|
-
if (Platform.OS === 'ios') {
|
|
217
|
-
// For now only scanningEnabled should be set as true by default
|
|
218
|
-
if (props.configuration.scanningEnabled === undefined)
|
|
219
|
-
props.configuration.scanningEnabled = true;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return props;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// Invalidates the component so that it gets recreated on the next render
|
|
227
|
-
_invalidate = () => {
|
|
228
|
-
this.isDirty = true;
|
|
229
|
-
this.cameraViewReference = React.createRef();
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
registerDimensionsListener() {
|
|
233
|
-
if (this.usesEmitterSubscription()) {
|
|
234
|
-
this.dimensionsChangeSubscription = Dimensions.addEventListener('change', this.orientationChangeHandler) as unknown as EmitterSubscription;
|
|
235
|
-
} else {
|
|
236
|
-
Dimensions.addEventListener('change', this.orientationChangeHandler);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
unregisterDimensionsListener() {
|
|
241
|
-
if (this.usesEmitterSubscription()) {
|
|
242
|
-
if (this.dimensionsChangeSubscription) {
|
|
243
|
-
this.dimensionsChangeSubscription.remove();
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
(Dimensions as any).removeEventListener('change', this.orientationChangeHandler);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Since React Native 0.70 the method removeEventListener has been removed in favour of EmitterSubscription (returned by addEventListener)
|
|
251
|
-
// .remove() method; here we check if removeEventListener still exists in Dimensions to check if React Native < 0.70 is used
|
|
252
|
-
usesEmitterSubscription(): boolean {
|
|
253
|
-
return (Dimensions as any).removeEventListener == null || (Dimensions as any).removeEventListener == undefined;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
sendCommandToCameraView = (command: string, args: any = []) => {
|
|
257
|
-
const viewId = findNodeHandle(this.cameraViewReference.current);
|
|
258
|
-
if (!viewId) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
this.sendCommandToViewId(viewId, command, args);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
sendCommandToViewId = (viewId: number, command: string, args: any = []) => {
|
|
265
|
-
const cameraView = this.cameraViewReference?.current;
|
|
266
|
-
if (cameraView) {
|
|
267
|
-
BarcodeCameraViewNativeCommands[command](cameraView);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { HostComponent } from "react-native";
|
|
2
|
-
import { ScanbotBarcodeCameraNativeViewProperties } from "./scanbot-barcode-camera-view-types";
|
|
3
|
-
|
|
4
|
-
const nativeBarcodeCameraView = require('../../../js/RTNScanbotBarcodeCameraViewNativeComponent').default;
|
|
5
|
-
export const BarcodeCameraViewNativeCommands = require('../../../js/RTNScanbotBarcodeCameraViewNativeComponent').Commands;
|
|
6
|
-
|
|
7
|
-
export default (nativeBarcodeCameraView as HostComponent<ScanbotBarcodeCameraNativeViewProperties>);
|