-
Notifications
You must be signed in to change notification settings - Fork 7
/
Capture.js
75 lines (67 loc) · 1.64 KB
/
Capture.js
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
import React, { Component } from 'react';
import { Text, View, Dimensions } from 'react-native';
import { Container, Header, Title, Content, Button, Icon, Grid, Col } from 'native-base';
import Camera from 'react-native-camera';
export default class Capture extends Component {
snap() {
this.camera.capture()
.then((data) => {
this.props.toggleSend("data:image/png;base64," + data.data);
})
.catch(err => console.error(err));
}
render() {
return (
<View style={styles.main}>
<Camera
ref={(cam) => {
this.camera = cam;
}}
captureTarget="memory"
style={styles.camera}
aspect={Camera.constants.Aspect.fill}>
</Camera>
<View style={styles.buttonContainer}>
<View style={styles.smallButtonContainer}>
<Button
onPress={this.snap.bind(this)}
transparent
style={styles.captureButton}>
<Icon name='ios-camera-outline' />
</Button>
</View>
</View>
</View>
);
}
}
const styles = {
main: {
flex: 1
},
camera: {
opacity: 1,
position: "absolute",
backgroundColor: 'white',
flex: 1,
height: Dimensions.get('window').height,
width: Dimensions.get('window').width
},
buttonContainer: {
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-end',
alignItems: 'center'
},
smallButtonContainer: {
width: 50,
height: 50,
marginBottom: 50
},
captureButton: {
borderRadius: 100,
width: 50,
height: 50,
backgroundColor: "white"
}
}