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.

129 lines
3.2 KiB

7 years ago
import React, { Component } from 'react';
7 years ago
import { ListView } from 'react-native';
7 years ago
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
7 years ago
BlueLoading,
BlueList,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
BlueListItem,
BlueHeader,
} from '../../BlueComponents';
7 years ago
import PropTypes from 'prop-types';
7 years ago
let EV = require('../../events');
7 years ago
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
7 years ago
let ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
7 years ago
export default class WalletsList extends Component {
static navigationOptions = {
tabBarLabel: 'Wallets',
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons
name={focused ? 'ios-briefcase' : 'ios-briefcase-outline'}
size={26}
style={{ color: tintColor }}
/>
),
7 years ago
};
7 years ago
constructor(props) {
super(props);
this.state = {
isLoading: true,
7 years ago
};
EV(EV.enum.WALLETS_COUNT_CHANGED, this.refreshFunction.bind(this));
7 years ago
}
async componentDidMount() {
7 years ago
this.refreshFunction();
7 years ago
} // end of componendDidMount
7 years ago
refreshFunction() {
this.setState(
{
isLoading: true,
},
() => {
setTimeout(() => {
this.setState({
isLoading: false,
dataSource: ds.cloneWithRows(BlueApp.getWallets()),
});
}, 1);
},
);
7 years ago
}
render() {
7 years ago
const { navigate } = this.props.navigation;
7 years ago
if (this.state.isLoading) {
7 years ago
return <BlueLoading />;
7 years ago
}
return (
<SafeBlueArea>
<BlueHeader
7 years ago
centerComponent={{
text: 'Blue Wallet',
style: { color: '#fff', fontSize: 25 },
}}
7 years ago
/>
7 years ago
<BlueCard title="My Bitcoin Wallets">
<BlueText style={{ marginBottom: 10 }}>
A wallet represents a pair of a secret (private key) and an address
you can share to receive coins.
7 years ago
</BlueText>
<BlueList>
<ListView
7 years ago
enableEmptySections
7 years ago
maxHeight={290}
dataSource={this.state.dataSource}
7 years ago
renderRow={rowData => {
return (
<BlueListItem
onPress={() => {
navigate('WalletDetails', {
address: rowData.getAddress(),
});
}}
leftIcon={{
name: 'bitcoin',
type: 'font-awesome',
color: '#fff',
}}
title={
rowData.getLabel() + ' | ' + rowData.getBalance() + ' BTC'
}
subtitle={rowData.getShortAddress()}
hideChevron={false}
/>
);
}}
7 years ago
/>
7 years ago
</BlueList>
7 years ago
</BlueCard>
<BlueButton
7 years ago
icon={{ name: 'plus-small', type: 'octicon' }}
7 years ago
onPress={() => {
7 years ago
navigate('AddWallet');
7 years ago
}}
title="Add Wallet"
/>
</SafeBlueArea>
);
}
7 years ago
}
7 years ago
WalletsList.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
}),
};