const React = require('react'); const Component = React.Component; const { View, Button, StyleSheet, TouchableOpacity } = require('react-native'); const { globalStyle, themeStyle } = require('lib/components/global-style.js'); import { RNCamera } from 'react-native-camera'; const Icon = require('react-native-vector-icons/Ionicons').default; const { _ } = require('lib/locale.js'); class CameraView extends Component { constructor() { super(); this.state = { snapping: false, }; this.back_onPress = this.back_onPress.bind(this); this.photo_onPress = this.photo_onPress.bind(this); } back_onPress() { if (this.props.onCancel) this.props.onCancel(); } async photo_onPress() { if (!this.camera || !this.props.onPhoto) return; this.setState({ snapping: true }); const result = await this.camera.takePictureAsync({ quality: 0.8, exif: true, fixOrientation: true }); if (this.props.onPhoto) this.props.onPhoto(result); this.setState({ snapping: false }); } render() { const theme = themeStyle(this.props.theme); const photoIcon = this.state.snapping ? 'md-checkmark' : 'md-camera'; return ( { this.camera = ref; }} type={RNCamera.Constants.Type.back} permissionDialogTitle={_('Permission to use camera')} permissionDialogMessage={_('Your permission to use your camera is required.')} > ); } } module.exports = CameraView;