forked from react-native-camera/react-native-camera
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbarcode-finder.js
More file actions
131 lines (122 loc) · 2.93 KB
/
barcode-finder.js
File metadata and controls
131 lines (122 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import React, {
Component,
} from 'react';
import PropTypes from 'prop-types';
import {
Platform,
StyleSheet,
View,
} from 'react-native';
/**
HOW TO MAKE CUSTOM BARCODE FINDER
1. make a copy of barcode-finder.js and place it in your project
2. add it to your project
3. add it as a child to the Camera
<Camera>
<MyCustomBarcodeFinder />
</Camera>
NOTE: The scan area is cropped and as long the first to <View> components remain intact it should show the correct size.
<View style={[styles.container]}>
<View style={[styles.finder, this.getSizeStyles()]}>
{ place your design here }
**/
class BarcodeFinder extends Component {
constructor(props) {
super(props);
}
getSizeStyles() {
return ({
width: this.props.width,
height: this.props.height
});
}
render() {
return (
<View style={[styles.container]}>
<View style={[styles.finder, this.getSizeStyles()]}>
<View style={[
{borderColor: this.props.style.borderColor},
styles.topLeftEdge,
{
borderLeftWidth: this.props.style.borderWidth,
borderTopWidth: this.props.style.borderWidth,
}
]} />
<View style={[
{borderColor: this.props.style.borderColor},
styles.topRightEdge,
{
borderRightWidth: this.props.style.borderWidth,
borderTopWidth: this.props.style.borderWidth,
}
]} />
<View style={[
{borderColor: this.props.style.borderColor},
styles.bottomLeftEdge,
{
borderLeftWidth: this.props.style.borderWidth,
borderBottomWidth: this.props.style.borderWidth,
}
]} />
<View style={[
{borderColor: this.props.style.borderColor},
styles.bottomRightEdge,
{
borderRightWidth: this.props.style.borderWidth,
borderBottomWidth: this.props.style.borderWidth,
}
]} />
</View>
</View>
);
}
};
BarcodeFinder.propTypes = {
style: PropTypes.object,
width: PropTypes.number,
height: PropTypes.number
};
var styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
},
finder: {
alignItems: 'center',
justifyContent: 'center',
},
topLeftEdge: {
position: 'absolute',
top: 0,
left: 0,
width: 40,
height: 20,
},
topRightEdge: {
position: 'absolute',
top: 0,
right: 0,
width: 40,
height: 20,
},
bottomLeftEdge: {
position: 'absolute',
bottom: 0,
left: 0,
width: 40,
height: 20,
},
bottomRightEdge: {
position: 'absolute',
bottom: 0,
right: 0,
width: 40,
height: 20,
},
});
module.exports = BarcodeFinder;