BlueWallet/screen/wallets/add.js

96 lines
2.4 KiB
JavaScript
Raw Normal View History

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';
import { ActivityIndicator, View } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
2018-03-17 21:39:21 +01:00
import {
BlueSpacing,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
} 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-03-18 03:48:23 +01:00
let BlueApp = require('../../BlueApp');
2018-05-28 21:18:11 +02:00
let loc = require('../../loc');
2018-01-30 23:42:38 +01:00
export default class WalletsAdd extends Component {
static navigationOptions = {
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons
name={focused ? 'ios-briefcase' : 'ios-briefcase-outline'}
size={26}
style={{ color: tintColor }}
/>
),
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 }}
>
<BlueSpacing />
2018-05-28 21:18:11 +02:00
<BlueCard title={loc.wallets.add.title}>
<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-17 13:38:12 +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={() => {
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-17 13:38:12 +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);
}, 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,
}),
};