2018-01-30 22:42:38 +00:00
|
|
|
import React from 'react';
|
2019-05-02 16:33:03 -04:00
|
|
|
import { Image, TouchableOpacity } from 'react-native';
|
2018-03-18 02:48:23 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-05-02 16:33:03 -04:00
|
|
|
import { RNCamera } from 'react-native-camera';
|
2018-10-22 18:51:30 -04:00
|
|
|
import { SafeBlueArea } from '../../BlueComponents';
|
2018-01-30 22:42:38 +00:00
|
|
|
|
|
|
|
export default class CameraExample extends React.Component {
|
2018-05-12 21:27:34 +01:00
|
|
|
static navigationOptions = {
|
2018-09-18 21:59:16 -04:00
|
|
|
header: null,
|
2018-05-12 21:27:34 +01:00
|
|
|
};
|
|
|
|
|
2018-01-30 22:42:38 +00:00
|
|
|
state = {
|
2018-03-17 22:39:21 +02:00
|
|
|
isLoading: false,
|
2018-01-30 22:42:38 +00:00
|
|
|
};
|
|
|
|
|
2019-05-02 16:33:03 -04:00
|
|
|
onBarCodeScanned = ret => {
|
2019-02-03 15:36:32 -05:00
|
|
|
if (this.state.isLoading) return;
|
|
|
|
this.setState({ isLoading: true }, () => {
|
2019-05-02 16:33:03 -04:00
|
|
|
const onBarScannedProp = this.props.navigation.getParam('onBarScanned');
|
2019-02-03 15:36:32 -05:00
|
|
|
this.props.navigation.goBack();
|
2019-05-02 16:33:03 -04:00
|
|
|
onBarScannedProp(ret.data);
|
2019-02-03 15:36:32 -05:00
|
|
|
});
|
2019-05-02 16:33:03 -04:00
|
|
|
}; // end
|
2018-01-30 22:42:38 +00:00
|
|
|
|
|
|
|
render() {
|
2019-05-02 16:33:03 -04:00
|
|
|
return (
|
|
|
|
<SafeBlueArea style={{ flex: 1 }}>
|
|
|
|
<RNCamera
|
|
|
|
captureAudio={false}
|
|
|
|
androidCameraPermissionOptions={{
|
|
|
|
title: 'Permission to use camera',
|
|
|
|
message: 'We need your permission to use your camera',
|
|
|
|
buttonPositive: 'OK',
|
|
|
|
buttonNegative: 'Cancel',
|
|
|
|
}}
|
|
|
|
style={{ flex: 1, justifyContent: 'space-between' }}
|
|
|
|
onBarCodeRead={this.onBarCodeScanned}
|
|
|
|
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
|
|
|
|
/>
|
|
|
|
<TouchableOpacity
|
|
|
|
style={{
|
|
|
|
width: 40,
|
|
|
|
height: 40,
|
|
|
|
marginLeft: 24,
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
justifyContent: 'center',
|
|
|
|
borderRadius: 20,
|
|
|
|
position: 'absolute',
|
|
|
|
top: 64,
|
|
|
|
}}
|
|
|
|
onPress={() => this.props.navigation.goBack(null)}
|
|
|
|
>
|
|
|
|
<Image style={{ alignSelf: 'center' }} source={require('../../img/close.png')} />
|
|
|
|
</TouchableOpacity>
|
|
|
|
</SafeBlueArea>
|
|
|
|
);
|
2018-01-30 22:42:38 +00:00
|
|
|
}
|
2018-03-17 22:39:21 +02:00
|
|
|
}
|
2018-03-18 02:48:23 +00:00
|
|
|
|
|
|
|
CameraExample.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
2019-01-24 02:36:01 -05:00
|
|
|
goBack: PropTypes.func,
|
|
|
|
dismiss: PropTypes.func,
|
|
|
|
getParam: PropTypes.func,
|
2018-03-18 02:48:23 +00:00
|
|
|
}),
|
|
|
|
};
|