-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
73 lines (64 loc) · 1.92 KB
/
index.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
import React, { Component } from 'react';
import {
View,
Text,
requireNativeComponent,
NativeModules,
Dimensions,
Platform,
} from 'react-native';
import PropTypes from 'prop-types';
let FastCamera, FastCameraMethods;
if (Platform.OS === 'ios') {
FastCamera = requireNativeComponent('FastCamera');
FastCameraMethods = NativeModules.FastCamera;
}
const { width, height } = Dimensions.get('window');
const androidCamera = () => (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ fontSize: 18, color: 'red' }}>android not supported yet!</Text>
</View>
);
const iOSCamera = (props) => {
console.log('props::: ', props);
return (
<View style={{ }}>
<FastCamera
style={{ height, width }}
onSaveSuccess={data => {
// console.log('onSaveSuccess: ', data.nativeEvent);
props.onSaveSuccess ? props.onSaveSuccess(data.nativeEvent.image) : null;
}}
onGalleryImage={data => {
// console.log('onGalleryImage: ', data.nativeEvent);
props.onGalleryImage ? props.onGalleryImage(data.nativeEvent.image) : null;
}}
onFlashToggle={data => {
// console.log('flash info: ', data.nativeEvent);
props.onFlashToggle ? props.onFlashToggle(data.nativeEvent.isflashOn) : null;
}}
/>
{props.children}
</View>
);
}
class MyFastCamera extends Component {
constructor(props) {
super(props);
this.state = {
showSelectedPictureOptions: false, // set when the user select or take a picture.
imageInfo: null,
modalVisible: false,
};
}
render() {
return Platform.OS === 'ios' ? iOSCamera(this.props) : androidCamera(this.props);
}
}
MyFastCamera.propTypes = {
onSaveSuccess: PropTypes.func,
onGalleryImage: PropTypes.func,
onFlashToggle: PropTypes.func,
};
export default MyFastCamera;
export const Methods = FastCameraMethods;