Skip to content

Commit 834525c

Browse files
Add a sample
1 parent 38759d9 commit 834525c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+9631
-0
lines changed

.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

.flowconfig

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; Flow doesn't support platforms
12+
.*/Libraries/Utilities/LoadingView.js
13+
14+
[untyped]
15+
.*/node_modules/@react-native-community/cli/.*/.*
16+
17+
[include]
18+
19+
[libs]
20+
node_modules/react-native/interface.js
21+
node_modules/react-native/flow/
22+
23+
[options]
24+
emoji=true
25+
26+
exact_by_default=true
27+
28+
format.bracket_spacing=false
29+
30+
module.file_ext=.js
31+
module.file_ext=.json
32+
module.file_ext=.ios.js
33+
34+
munge_underscores=true
35+
36+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
37+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
38+
39+
suppress_type=$FlowIssue
40+
suppress_type=$FlowFixMe
41+
suppress_type=$FlowFixMeProps
42+
suppress_type=$FlowFixMeState
43+
44+
[lints]
45+
sketchy-null-number=warn
46+
sketchy-null-mixed=warn
47+
sketchy-number=warn
48+
untyped-type-import=warn
49+
nonstrict-import=warn
50+
deprecated-type=warn
51+
unsafe-getters-setters=warn
52+
unnecessary-invariant=warn
53+
signature-verification-failure=warn
54+
55+
[strict]
56+
deprecated-type
57+
nonstrict-import
58+
sketchy-null
59+
unclear-type
60+
unsafe-getters-setters
61+
untyped-import
62+
untyped-type-import
63+
64+
[version]
65+
^0.162.0

.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# Android/IntelliJ
25+
#
26+
build/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
*.hprof
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
!debug.keystore
44+
45+
# fastlane
46+
#
47+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48+
# screenshots whenever they are needed.
49+
# For more information about the recommended setup visit:
50+
# https://docs.fastlane.tools/best-practices/source-control/
51+
52+
*/fastlane/report.xml
53+
*/fastlane/Preview.html
54+
*/fastlane/screenshots
55+
56+
# Bundle artifact
57+
*.jsbundle
58+
59+
# CocoaPods
60+
/ios/Pods/

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
arrowParens: 'avoid',
7+
};

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import React from 'react';
2+
import {Text} from 'react-native';
3+
import {
4+
DynamsoftBarcodeReader,
5+
DynamsoftCameraView,
6+
BarcodeResult,
7+
EnumDBRPresetTemplate,
8+
Region,
9+
EnumBarcodeFormat,
10+
DBRRuntimeSettings
11+
} from 'dynamsoft-capture-vision-react-native';
12+
13+
14+
class App extends React.Component {
15+
state = {
16+
results: null
17+
};
18+
19+
componentDidMount() {
20+
(async () => {
21+
try {
22+
await DynamsoftBarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
23+
} catch (e) {
24+
console.log(e)
25+
}
26+
27+
28+
this.reader = await DynamsoftBarcodeReader.createInstance();
29+
await this.reader.updateDBRRuntimeSettings(EnumDBRPresetTemplate.DEFAULT);
30+
let settings: DBRRuntimeSettings = await this.reader.getDBRRuntimeSettings();
31+
// Set the expected barcode count to 0 when you are not sure how many barcodes you are scanning.
32+
// Set the expected barcode count to 1 can maximize the barcode decoding speed.
33+
settings.expectedBarcodesCount = 0;
34+
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE;
35+
await this.reader.updateDBRRuntimeSettings(settings)
36+
37+
await this.reader.startScanning();
38+
this.reader.addResultListener((results: BarcodeResult[]) => {
39+
this.setState({results: results})
40+
})
41+
})();
42+
43+
44+
}
45+
46+
async componentWillUnmount() {
47+
await this.reader.stopScanning()
48+
this.reader.removeResultListener()
49+
}
50+
51+
52+
render() {
53+
let region: Region;
54+
let barcode_text = "";
55+
region = {
56+
regionTop: 30,
57+
regionLeft: 15,
58+
regionBottom: 70,
59+
regionRight: 85,
60+
regionMeasuredByPercentage: true
61+
}
62+
let results: BarcodeResult[] = this.state.results;
63+
if (results && results.length > 0){
64+
for (var i=0; i<results.length; i++) {
65+
barcode_text += results[i].barcodeFormatString+":"+results[i].barcodeText+"\n"
66+
}
67+
}
68+
69+
return (
70+
<DynamsoftCameraView
71+
style={{
72+
flex: 1,
73+
}}
74+
ref = {(ref)=>{this.scanner = ref}}
75+
isOverlayVisible={true}
76+
isScanRegionVisible={true}
77+
scanRegion={region}
78+
>
79+
<Text style={{
80+
flex: 0.9,
81+
textAlignVertical: "bottom",
82+
textAlign: "center",
83+
color: "white",
84+
fontSize: 18,
85+
}}>{results && results.length > 0 ? barcode_text : "null"}</Text>
86+
</DynamsoftCameraView>
87+
88+
89+
);
90+
}
91+
}
92+
93+
export default App;

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.4'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

0 commit comments

Comments
 (0)