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.

121 lines
3.0 KiB

7 years ago
import React, { Component } from 'react';
6 years ago
import { Dimensions, Text, TouchableOpacity } from 'react-native';
import { Icon } from 'react-native-elements';
7 years ago
import Ionicons from 'react-native-vector-icons/Ionicons';
import QRCode from 'react-native-qrcode';
import {
7 years ago
BlueLoading,
6 years ago
BlueHeader,
BlueFormInputAddress,
7 years ago
SafeBlueArea,
BlueCard,
} 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
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons
name={focused ? 'ios-cash' : 'ios-cash-outline'}
size={26}
style={{ color: tintColor }}
/>
),
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
<BlueHeader
leftComponent={
<Text
style={{
fontWeight: 'bold',
fontSize: 34,
color: BlueApp.settings.foregroundColor,
}}
>
{loc.receive.list.header}
</Text>
}
rightComponent={
<TouchableOpacity onPress={() => this.props.navigation.goBack()}>
<Icon
name="times"
size={16}
type="font-awesome"
color={BlueApp.settings.foregroundColor}
/>
</TouchableOpacity>
}
6 years ago
/>
6 years ago
<BlueCard style={{ alignItems: 'center', flex: 1 }}>
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
<BlueFormInputAddress editable value={this.state.address} />
7 years ago
</BlueCard>
</SafeBlueArea>
);
}
}
7 years ago
ReceiveDetails.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.function,
state: PropTypes.shape({
params: PropTypes.shape({
address: PropTypes.string,
}),
}),
}),
};