2018-03-18 03:48:23 +01:00
|
|
|
import { SegwitP2SHWallet } from '../../class';
|
2018-01-30 23:42:38 +01:00
|
|
|
import React, { Component } from 'react';
|
2018-06-28 03:43:28 +02:00
|
|
|
import { ActivityIndicator, Dimensions, View } from 'react-native';
|
2018-03-17 21:39:21 +01:00
|
|
|
import {
|
|
|
|
BlueSpacing,
|
|
|
|
BlueButton,
|
|
|
|
SafeBlueArea,
|
|
|
|
BlueCard,
|
|
|
|
BlueText,
|
2018-06-28 03:43:28 +02:00
|
|
|
BlueHeaderDefaultSub,
|
|
|
|
BlueSpacing40,
|
2018-03-17 21:39:21 +01:00
|
|
|
} from '../../BlueComponents';
|
2018-03-18 03:48:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2018-03-17 21:39:21 +01:00
|
|
|
let EV = require('../../events');
|
2018-07-06 18:28:04 +02:00
|
|
|
let A = require('../../analytics');
|
|
|
|
/** @type {AppStorage} */
|
2018-03-18 03:48:23 +01:00
|
|
|
let BlueApp = require('../../BlueApp');
|
2018-05-28 21:18:11 +02:00
|
|
|
let loc = require('../../loc');
|
2018-06-28 03:43:28 +02:00
|
|
|
const { height, width } = Dimensions.get('window');
|
|
|
|
const aspectRatio = height / width;
|
|
|
|
let isIpad;
|
|
|
|
if (aspectRatio > 1.6) {
|
|
|
|
isIpad = false;
|
|
|
|
} else {
|
|
|
|
isIpad = true;
|
|
|
|
}
|
2018-01-30 23:42:38 +01:00
|
|
|
|
|
|
|
export default class WalletsAdd extends Component {
|
|
|
|
static navigationOptions = {
|
2018-06-28 03:43:28 +02:00
|
|
|
tabBarVisible: false,
|
2018-03-17 21:39:21 +01:00
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isLoading: true,
|
2018-03-17 21:39:21 +01:00
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
2018-03-17 21:39:21 +01:00
|
|
|
});
|
2018-01-30 23:42:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.state.isLoading) {
|
|
|
|
return (
|
2018-03-17 21:39:21 +01:00
|
|
|
<View style={{ flex: 1, paddingTop: 20 }}>
|
2018-01-30 23:42:38 +01:00
|
|
|
<ActivityIndicator />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2018-03-17 21:39:21 +01:00
|
|
|
<SafeBlueArea
|
|
|
|
forceInset={{ horizontal: 'always' }}
|
|
|
|
style={{ flex: 1, paddingTop: 40 }}
|
|
|
|
>
|
2018-06-28 03:43:28 +02:00
|
|
|
{(() => {
|
|
|
|
if (isIpad) {
|
|
|
|
return <BlueSpacing40 />;
|
|
|
|
} else {
|
|
|
|
return <BlueSpacing />;
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
<BlueHeaderDefaultSub
|
|
|
|
leftText={loc.wallets.add.title}
|
|
|
|
onClose={() => this.props.navigation.goBack()}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<BlueCard>
|
2018-05-28 21:18:11 +02:00
|
|
|
<BlueText>{loc.wallets.add.description}</BlueText>
|
2018-01-30 23:42:38 +01:00
|
|
|
|
|
|
|
<BlueButton
|
2018-03-17 21:39:21 +01:00
|
|
|
large
|
2018-06-25 00:22:46 +02:00
|
|
|
icon={{
|
|
|
|
name: 'qrcode',
|
|
|
|
type: 'font-awesome',
|
|
|
|
color: BlueApp.settings.buttonTextColor,
|
|
|
|
}}
|
2018-05-28 21:18:11 +02:00
|
|
|
title={loc.wallets.add.scan}
|
2018-03-17 21:39:21 +01:00
|
|
|
onPress={() => {
|
2018-05-20 11:38:50 +02:00
|
|
|
this.props.navigation.navigate('ScanQrWif');
|
2018-03-17 21:39:21 +01:00
|
|
|
}}
|
2018-01-30 23:42:38 +01:00
|
|
|
/>
|
|
|
|
|
|
|
|
<BlueButton
|
2018-03-17 21:39:21 +01:00
|
|
|
large
|
2018-06-25 00:22:46 +02:00
|
|
|
icon={{
|
|
|
|
name: 'bitcoin',
|
|
|
|
type: 'font-awesome',
|
|
|
|
color: BlueApp.settings.buttonTextColor,
|
|
|
|
}}
|
2018-05-28 21:18:11 +02:00
|
|
|
title={loc.wallets.add.create}
|
2018-03-17 21:39:21 +01:00
|
|
|
onPress={() => {
|
|
|
|
this.props.navigation.goBack();
|
|
|
|
setTimeout(async () => {
|
|
|
|
let w = new SegwitP2SHWallet();
|
2018-05-28 21:18:11 +02:00
|
|
|
w.setLabel(loc.wallets.add.label_new_segwit);
|
2018-03-17 21:39:21 +01:00
|
|
|
w.generate();
|
|
|
|
BlueApp.wallets.push(w);
|
|
|
|
await BlueApp.saveToDisk();
|
|
|
|
EV(EV.enum.WALLETS_COUNT_CHANGED);
|
2018-07-06 18:28:04 +02:00
|
|
|
A(A.ENUM.CREATED_WALLET);
|
2018-03-17 21:39:21 +01:00
|
|
|
}, 1);
|
|
|
|
}}
|
2018-01-30 23:42:38 +01:00
|
|
|
/>
|
|
|
|
</BlueCard>
|
|
|
|
</SafeBlueArea>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-03-18 03:48:23 +01:00
|
|
|
|
|
|
|
WalletsAdd.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
}),
|
|
|
|
};
|