You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.6 KiB

7 years ago
import React, { Component } from 'react';
6 years ago
import { Dimensions, View } from 'react-native';
7 years ago
import QRCode from 'react-native-qrcode';
import {
7 years ago
BlueLoading,
BlueFormInputAddress,
7 years ago
SafeBlueArea,
BlueCard,
6 years ago
BlueHeaderDefaultSub,
BlueSpacing,
BlueSpacing40,
7 years ago
} from '../../BlueComponents';
7 years ago
import PropTypes from 'prop-types';
6 years ago
/** @type {AppStorage} */
7 years ago
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
6 years ago
let EV = require('../../events');
const { height, width } = Dimensions.get('window');
const aspectRatio = height / width;
let isIpad;
if (aspectRatio > 1.6) {
isIpad = false;
} else {
isIpad = true;
}
7 years ago
export default class ReceiveDetails extends Component {
static navigationOptions = {
6 years ago
tabBarVisible: false,
7 years ago
};
7 years ago
constructor(props) {
super(props);
7 years ago
let address = props.navigation.state.params.address;
7 years ago
this.state = {
isLoading: true,
7 years ago
address: address,
};
console.log(JSON.stringify(address));
6 years ago
EV(EV.enum.RECEIVE_ADDRESS_CHANGED, this.refreshFunction.bind(this));
}
refreshFunction(newAddress) {
console.log('newAddress =', newAddress);
this.setState({
address: newAddress,
});
7 years ago
}
async componentDidMount() {
console.log('receive/details - componentDidMount');
7 years ago
this.setState({
isLoading: false,
7 years ago
});
7 years ago
}
render() {
6 years ago
console.log('render() receive/details, address=', this.state.address);
7 years ago
if (this.state.isLoading) {
7 years ago
return <BlueLoading />;
7 years ago
}
return (
<SafeBlueArea style={{ flex: 1 }}>
6 years ago
{(() => {
if (isIpad) {
return <BlueSpacing40 />;
} else {
return <BlueSpacing />;
}
6 years ago
})()}
<BlueHeaderDefaultSub leftText={loc.receive.list.header} onClose={() => this.props.navigation.goBack()} />
<BlueCard
containerStyle={{
alignItems: 'center',
flex: 1,
borderColor: 'red',
borderWidth: 7,
}}
>
<BlueFormInputAddress editable value={this.state.address} />
</BlueCard>
6 years ago
<View
style={{
left: (width - ((isIpad && 250) || 312)) / 2,
}}
>
7 years ago
<QRCode
value={this.state.address}
size={(isIpad && 250) || 312}
7 years ago
bgColor={BlueApp.settings.foregroundColor}
7 years ago
fgColor={BlueApp.settings.brandingColor}
/>
6 years ago
</View>
7 years ago
</SafeBlueArea>
);
}
}
7 years ago
ReceiveDetails.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.function,
state: PropTypes.shape({
params: PropTypes.shape({
address: PropTypes.string,
}),
}),
}),
};