-
Notifications
You must be signed in to change notification settings - Fork 1
/
PhotoCapture.js
78 lines (67 loc) · 1.56 KB
/
PhotoCapture.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
76
77
'use strict';
var React = require('react-native');
var {
StyleSheet,
Text,
TextInput,
View,
TouchableHighlight,
ActivityIndicatorIOS,
Image,
Component
} = React;
var Button = require('react-native-button');
var Camera = require('react-native-camera');
var PhotoReview = require('./PhotoReview');
var PhotoCapture = React.createClass({
statics: {
title: 'Take a picture'
},
_handleChangePage() {
this.props.navigator.push({
title: PhotoReview.title,
component: PhotoReview,
passProps: {
photo: this.state.photo,
firstName: this.props.firstName,
lastName: this.props.lastName,
host: this.props.host,
baseUrl: this.props.baseUrl
}
});
},
getInitialState() {
return {
cameraType: Camera.constants.Type.front,
captureTarget: Camera.constants.CaptureTarget.memory
}
},
render() {
return (
<Camera
ref="cam"
style={styles.container}
type={this.state.cameraType}>
<Button style={{color: 'blue', margin: 10}} onPress={this._takePicture}>
Take Picture
</Button>
</Camera>
);
},
_takePicture() {
var that = this;
this.refs.cam.capture({ target: this.state.captureTarget }, function(err, data) {
that.state.photo = "data:image/jpg;base64," + data;
that._handleChangePage();
});
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'transparent'
}
});
module.exports = PhotoCapture;