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.

115 lines
2.8 KiB

7 years ago
import { SegwitP2SHWallet } from '../../class';
7 years ago
import React, { Component } from 'react';
6 years ago
import { ActivityIndicator, Dimensions, View } from 'react-native';
7 years ago
import {
BlueSpacing,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
6 years ago
BlueHeaderDefaultSub,
BlueSpacing40,
7 years ago
} from '../../BlueComponents';
7 years ago
import PropTypes from 'prop-types';
7 years ago
let EV = require('../../events');
6 years ago
let A = require('../../analytics');
/** @type {AppStorage} */
7 years ago
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
6 years ago
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 WalletsAdd extends Component {
static navigationOptions = {
6 years ago
tabBarVisible: false,
7 years ago
};
7 years ago
constructor(props) {
super(props);
this.state = {
isLoading: true,
7 years ago
};
7 years ago
}
async componentDidMount() {
this.setState({
isLoading: false,
7 years ago
});
7 years ago
}
render() {
if (this.state.isLoading) {
return (
7 years ago
<View style={{ flex: 1, paddingTop: 20 }}>
7 years ago
<ActivityIndicator />
</View>
);
}
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1, paddingTop: 40 }}>
6 years ago
{(() => {
if (isIpad) {
return <BlueSpacing40 />;
} else {
return <BlueSpacing />;
}
})()}
<BlueHeaderDefaultSub leftText={loc.wallets.add.title} onClose={() => this.props.navigation.goBack()} />
6 years ago
<BlueCard>
<BlueText>{loc.wallets.add.description}</BlueText>
7 years ago
<BlueButton
7 years ago
large
6 years ago
icon={{
name: 'qrcode',
type: 'font-awesome',
color: BlueApp.settings.buttonTextColor,
}}
title={loc.wallets.add.scan}
7 years ago
onPress={() => {
this.props.navigation.navigate('ScanQrWif');
7 years ago
}}
7 years ago
/>
<BlueButton
7 years ago
large
6 years ago
icon={{
name: 'bitcoin',
type: 'font-awesome',
color: BlueApp.settings.buttonTextColor,
}}
title={loc.wallets.add.create}
7 years ago
onPress={() => {
this.props.navigation.goBack();
setTimeout(async () => {
let w = new SegwitP2SHWallet();
w.setLabel(loc.wallets.add.label_new_segwit);
7 years ago
w.generate();
BlueApp.wallets.push(w);
await BlueApp.saveToDisk();
EV(EV.enum.WALLETS_COUNT_CHANGED);
6 years ago
A(A.ENUM.CREATED_WALLET);
7 years ago
}, 1);
}}
7 years ago
/>
</BlueCard>
</SafeBlueArea>
);
}
}
7 years ago
WalletsAdd.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
}),
};