BlueWallet/screen/wallets/add.js

121 lines
3.0 KiB
JavaScript
Raw Normal View History

2018-03-17 21:39:21 +01:00
let BlueApp = require('../../BlueApp');
import {
AppStorage,
LegacyWallet,
SegwitBech32Wallet,
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 { SafeAreaView } from 'react-navigation';
import { Button } from 'react-native-elements';
import { Icon, Card, Header } from 'react-native-elements';
import {
BlueSpacing,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
BlueListItem,
BlueHeader,
} from '../../BlueComponents';
let EV = require('../../events');
2018-01-30 23:42:38 +01:00
/*
<Button
backgroundColor={BlueApp.settings.buttonBackground}
large icon={{name: 'qrcode', type: 'font-awesome'}} title='Scan QR WIF as Legacy Address (P2PKH)'
onPress={() => {
this.props.navigation.navigate('ScanQrWifLegacyAddress')
}}
2018-03-17 21:39:21 +01:00
/> */
2018-01-30 23:42:38 +01:00
export default class WalletsAdd extends Component {
static navigationOptions = {
tabBarLabel: 'Wallets',
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() {
2018-03-17 21:39:21 +01:00
const { navigate } = this.props.navigation;
2018-01-30 23:42:38 +01:00
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-01-30 23:42:38 +01:00
<BlueCard title="Add Wallet">
2018-03-17 21:39:21 +01:00
<BlueText>
You can either scan backup paper wallet (in WIF - Wallet Import
Format), or create a new wallet. Segwit wallets supported by
default.
</BlueText>
2018-01-30 23:42:38 +01:00
<BlueButton
2018-03-17 21:39:21 +01:00
large
icon={{ name: 'qrcode', type: 'font-awesome' }}
title="Scan"
onPress={() => {
this.props.navigation.navigate('ScanQrWifSegwitP2SHAddress');
}}
2018-01-30 23:42:38 +01:00
/>
<BlueButton
2018-03-17 21:39:21 +01:00
large
icon={{ name: 'bitcoin', type: 'font-awesome' }}
title="Create"
onPress={() => {
this.props.navigation.goBack();
setTimeout(async () => {
let w = new SegwitP2SHWallet();
w.setLabel('New SegWit');
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>
2018-03-17 21:39:21 +01:00
<BlueButton
icon={{ name: 'arrow-left', type: 'octicon' }}
title="Go Back"
onPress={() => {
this.props.navigation.goBack();
}}
/>
2018-01-30 23:42:38 +01:00
</SafeBlueArea>
);
}
}