BlueWallet/screen/send/scanQrAddress.js

67 lines
1.8 KiB
JavaScript
Raw Normal View History

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';
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 = {
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 => {
if (this.state.isLoading) return;
this.setState({ isLoading: true }, () => {
2019-05-02 16:33:03 -04:00
const onBarScannedProp = this.props.navigation.getParam('onBarScanned');
this.props.navigation.goBack();
2019-05-02 16:33:03 -04:00
onBarScannedProp(ret.data);
});
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
}),
};