Overtorment
6 years ago
7 changed files with 0 additions and 434 deletions
@ -1,16 +0,0 @@ |
|||||
import { createStackNavigator } from 'react-navigation'; |
|
||||
|
|
||||
import list from './receive/list'; |
|
||||
|
|
||||
const ReceiveNavigator = createStackNavigator( |
|
||||
{ |
|
||||
SendList: { |
|
||||
screen: list, |
|
||||
}, |
|
||||
}, |
|
||||
{ |
|
||||
mode: 'modal', |
|
||||
}, |
|
||||
); |
|
||||
|
|
||||
export default ReceiveNavigator; |
|
@ -1,98 +0,0 @@ |
|||||
import React, { Component } from 'react'; |
|
||||
import { FlatList, StyleSheet } from 'react-native'; |
|
||||
import { BlueLoading, SafeBlueArea, BlueCard, BlueListItem, BlueHeader } from '../../BlueComponents'; |
|
||||
import PropTypes from 'prop-types'; |
|
||||
/** @type {AppStorage} */ |
|
||||
let BlueApp = require('../../BlueApp'); |
|
||||
let EV = require('../../events'); |
|
||||
let loc = require('../../loc'); |
|
||||
|
|
||||
export default class ReceiveList extends Component { |
|
||||
constructor(props) { |
|
||||
super(props); |
|
||||
this.state = { |
|
||||
isLoading: true, |
|
||||
}; |
|
||||
this.walletsCount = 0; |
|
||||
EV(EV.enum.WALLETS_COUNT_CHANGED, () => { |
|
||||
return this.componentDidMount(); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
async componentDidMount() { |
|
||||
console.log('receive/list - componentDidMount'); |
|
||||
let list = []; |
|
||||
|
|
||||
this.walletsCount = 0; |
|
||||
for (let w of BlueApp.getWallets()) { |
|
||||
list.push({ |
|
||||
title: w.getAddress(), |
|
||||
subtitle: w.getLabel(), |
|
||||
}); |
|
||||
this.walletsCount++; |
|
||||
} |
|
||||
|
|
||||
this.setState({ |
|
||||
isLoading: false, |
|
||||
list: list, |
|
||||
dataSource: list, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
_keyExtractor = (item, index) => item.hash; |
|
||||
|
|
||||
render() { |
|
||||
const { navigate } = this.props.navigation; |
|
||||
|
|
||||
if (this.state.isLoading) { |
|
||||
return <BlueLoading />; |
|
||||
} |
|
||||
|
|
||||
return ( |
|
||||
<SafeBlueArea forceInset={{ horizontal: 'always' }}> |
|
||||
<BlueHeader |
|
||||
centerComponent={{ |
|
||||
text: loc.receive.list.header, |
|
||||
style: { color: BlueApp.settings.foregroundColor, fontSize: 23 }, |
|
||||
}} |
|
||||
/> |
|
||||
|
|
||||
<BlueCard containerStyle={{ padding: 0 }}> |
|
||||
<FlatList |
|
||||
data={this.state.dataSource} |
|
||||
style={Styles.flatList} |
|
||||
keyExtractor={this._keyExtractor} |
|
||||
renderItem={item => { |
|
||||
return ( |
|
||||
<BlueListItem |
|
||||
title={item.title} |
|
||||
subtitle={item.subtitle} |
|
||||
onPress={() => { |
|
||||
navigate('ReceiveDetails', { address: item.title }); |
|
||||
}} |
|
||||
leftIcon={{ |
|
||||
name: 'bitcoin', |
|
||||
type: 'font-awesome', |
|
||||
color: BlueApp.settings.foregroundColor, |
|
||||
}} |
|
||||
/> |
|
||||
); |
|
||||
}} |
|
||||
/> |
|
||||
</BlueCard> |
|
||||
</SafeBlueArea> |
|
||||
); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const Styles = StyleSheet.create({ |
|
||||
flatList: { |
|
||||
flex: 1, |
|
||||
}, |
|
||||
}); |
|
||||
|
|
||||
ReceiveList.propTypes = { |
|
||||
navigation: PropTypes.shape({ |
|
||||
navigate: PropTypes.func, |
|
||||
}), |
|
||||
}; |
|
@ -1,17 +0,0 @@ |
|||||
import { createStackNavigator } from 'react-navigation'; |
|
||||
|
|
||||
import list from './send/list'; |
|
||||
|
|
||||
const SendNavigator = createStackNavigator( |
|
||||
{ |
|
||||
SendList: { |
|
||||
screen: list, |
|
||||
}, |
|
||||
}, |
|
||||
{ |
|
||||
headerMode: 'none', |
|
||||
mode: 'modal', |
|
||||
}, |
|
||||
); |
|
||||
|
|
||||
export default SendNavigator; |
|
@ -1,113 +0,0 @@ |
|||||
import React, { Component } from 'react'; |
|
||||
import { ActivityIndicator, View, FlatList, StyleSheet } from 'react-native'; |
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons'; |
|
||||
import { SafeBlueArea, BlueCard, BlueListItem, BlueHeader } from '../../BlueComponents'; |
|
||||
import PropTypes from 'prop-types'; |
|
||||
let EV = require('../../events'); |
|
||||
/** @type {AppStorage} */ |
|
||||
let BlueApp = require('../../BlueApp'); |
|
||||
let loc = require('../../loc'); |
|
||||
|
|
||||
export default class SendList extends Component { |
|
||||
static navigationOptions = { |
|
||||
tabBarLabel: loc.send.list.tabBarLabel, |
|
||||
tabBarIcon: ({ tintColor, focused }) => ( |
|
||||
<Ionicons name={focused ? 'md-paper-plane' : 'md-paper-plane'} size={26} style={{ color: tintColor }} /> |
|
||||
), |
|
||||
}; |
|
||||
|
|
||||
constructor(props) { |
|
||||
super(props); |
|
||||
this.state = { |
|
||||
isLoading: true, |
|
||||
}; |
|
||||
this.walletsCount = 0; |
|
||||
EV(EV.enum.WALLETS_COUNT_CHANGED, () => { |
|
||||
return this.componentDidMount(); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
async componentDidMount() { |
|
||||
console.log('receive/list - componentDidMount'); |
|
||||
let list = []; |
|
||||
|
|
||||
this.walletsCount = 0; |
|
||||
for (let w of BlueApp.getWallets()) { |
|
||||
list.push({ |
|
||||
title: w.getAddress(), |
|
||||
subtitle: w.getLabel(), |
|
||||
}); |
|
||||
this.walletsCount++; |
|
||||
} |
|
||||
|
|
||||
this.setState({ |
|
||||
isLoading: false, |
|
||||
list: list, |
|
||||
dataSource: list, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
_keyExtractor = (item, index) => item.hash; |
|
||||
|
|
||||
render() { |
|
||||
const { navigate } = this.props.navigation; |
|
||||
|
|
||||
if (this.state.isLoading) { |
|
||||
return ( |
|
||||
<SafeBlueArea forceInset={{ horizontal: 'always' }}> |
|
||||
<View style={{ flex: 1, paddingTop: 20 }}> |
|
||||
<ActivityIndicator /> |
|
||||
</View> |
|
||||
</SafeBlueArea> |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
return ( |
|
||||
<SafeBlueArea forceInset={{ horizontal: 'always' }}> |
|
||||
<BlueHeader |
|
||||
centerComponent={{ |
|
||||
text: loc.send.list.header, |
|
||||
style: { color: BlueApp.settings.foregroundColor, fontSize: 23 }, |
|
||||
}} |
|
||||
/> |
|
||||
|
|
||||
<BlueCard containerStyle={{ padding: 0 }}> |
|
||||
<FlatList |
|
||||
data={this.state.dataSource} |
|
||||
keyExtractor={this._keyExtractor} |
|
||||
extraData={this.state.dataSource} |
|
||||
style={Styles.flatList} |
|
||||
renderItem={item => { |
|
||||
return ( |
|
||||
<BlueListItem |
|
||||
title={item.title} |
|
||||
subtitle={item.subtitle} |
|
||||
onPress={() => { |
|
||||
navigate('SendDetails', { fromAddress: item.title }); |
|
||||
}} |
|
||||
leftIcon={{ |
|
||||
name: 'bitcoin', |
|
||||
type: 'font-awesome', |
|
||||
color: BlueApp.settings.foregroundColor, |
|
||||
}} |
|
||||
/> |
|
||||
); |
|
||||
}} |
|
||||
/> |
|
||||
</BlueCard> |
|
||||
</SafeBlueArea> |
|
||||
); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const Styles = StyleSheet.create({ |
|
||||
flatList: { |
|
||||
flex: 1, |
|
||||
}, |
|
||||
}); |
|
||||
|
|
||||
SendList.propTypes = { |
|
||||
navigation: PropTypes.shape({ |
|
||||
navigate: PropTypes.func, |
|
||||
}), |
|
||||
}; |
|
@ -1,17 +0,0 @@ |
|||||
import { createStackNavigator } from 'react-navigation'; |
|
||||
|
|
||||
import list from './transactions/list'; |
|
||||
|
|
||||
const TransactionsNavigator = createStackNavigator( |
|
||||
{ |
|
||||
TransactionsList: { |
|
||||
screen: list, |
|
||||
}, |
|
||||
}, |
|
||||
{ |
|
||||
headerMode: 'none', |
|
||||
mode: 'modal', |
|
||||
}, |
|
||||
); |
|
||||
|
|
||||
export default TransactionsNavigator; |
|
@ -1,158 +0,0 @@ |
|||||
import React, { Component } from 'react'; |
|
||||
import { FlatList } from 'react-native'; |
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons'; |
|
||||
import { Header, Icon } from 'react-native-elements'; |
|
||||
import { BlueLoading, BlueList, SafeBlueArea, BlueCard, BlueText, BlueListItem } from '../../BlueComponents'; |
|
||||
import PropTypes from 'prop-types'; |
|
||||
let loc = require('../../loc'); |
|
||||
let EV = require('../../events'); |
|
||||
/** @type {AppStorage} */ |
|
||||
let BlueApp = require('../../BlueApp'); |
|
||||
|
|
||||
export default class TransactionsList extends Component { |
|
||||
static navigationOptions = { |
|
||||
tabBarLabel: loc.transactions.list.tabBarLabel, |
|
||||
tabBarIcon: ({ tintColor, focused }) => ( |
|
||||
<Ionicons name={focused ? 'ios-list-box' : 'ios-list-box-outline'} size={26} style={{ color: tintColor }} /> |
|
||||
), |
|
||||
}; |
|
||||
|
|
||||
constructor(props) { |
|
||||
super(props); |
|
||||
this.state = { |
|
||||
isLoading: true, |
|
||||
}; |
|
||||
|
|
||||
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED, this.refreshFunction.bind(this)); |
|
||||
} |
|
||||
|
|
||||
async componentDidMount() { |
|
||||
console.log('transaction/list- componentDidMount'); |
|
||||
this.refreshFunction(); |
|
||||
} // end
|
|
||||
|
|
||||
refreshFunction() { |
|
||||
this.setState( |
|
||||
{ |
|
||||
isLoading: true, |
|
||||
}, |
|
||||
() => { |
|
||||
setTimeout(() => { |
|
||||
this.setState({ |
|
||||
isLoading: false, |
|
||||
final_balance: BlueApp.getBalance(), |
|
||||
dataSource: BlueApp.getTransactions(), |
|
||||
}); |
|
||||
}, 1); |
|
||||
}, |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
txMemo(hash) { |
|
||||
if (BlueApp.tx_metadata[hash] && BlueApp.tx_metadata[hash]['memo']) { |
|
||||
return ' | ' + BlueApp.tx_metadata[hash]['memo']; |
|
||||
} |
|
||||
return ''; |
|
||||
} |
|
||||
|
|
||||
refresh() { |
|
||||
this.setState( |
|
||||
{ |
|
||||
isLoading: true, |
|
||||
}, |
|
||||
async function() { |
|
||||
let that = this; |
|
||||
setTimeout(async function() { |
|
||||
// more responsive
|
|
||||
let noErr = true; |
|
||||
try { |
|
||||
await BlueApp.fetchWalletTransactions(); |
|
||||
await BlueApp.fetchWalletBalances(); |
|
||||
} catch (err) { |
|
||||
noErr = false; |
|
||||
console.warn(err); |
|
||||
} |
|
||||
if (noErr) await BlueApp.saveToDisk(); // caching
|
|
||||
EV(EV.enum.WALLETS_COUNT_CHANGED); // TODO: some other event type?
|
|
||||
that.setState({ |
|
||||
isLoading: false, |
|
||||
final_balance: BlueApp.getBalance(), |
|
||||
dataSource: BlueApp.getTransactions(), |
|
||||
}); |
|
||||
}, 10); |
|
||||
}, |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
_keyExtractor = (item, index) => item.hash; |
|
||||
|
|
||||
render() { |
|
||||
console.warn(this.state.dataSource); |
|
||||
const { navigate } = this.props.navigation; |
|
||||
|
|
||||
if (this.state.isLoading) { |
|
||||
return <BlueLoading />; |
|
||||
} |
|
||||
|
|
||||
return ( |
|
||||
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}> |
|
||||
<Header |
|
||||
backgroundColor={BlueApp.settings.brandingColor} |
|
||||
centerComponent={{ |
|
||||
text: this.state.final_balance + ' BTC', |
|
||||
style: { color: BlueApp.settings.foregroundColor, fontSize: 25 }, |
|
||||
}} |
|
||||
rightComponent={<Icon name="refresh" color={BlueApp.settings.foregroundColor} onPress={() => this.refresh()} />} |
|
||||
/> |
|
||||
<BlueCard title={loc.transactions.list.title}> |
|
||||
<BlueText style={{ marginBottom: 10 }}>{loc.transactions.list.description}</BlueText> |
|
||||
|
|
||||
<BlueList> |
|
||||
<FlatList |
|
||||
data={this.state.dataSource} |
|
||||
extraData={this.state.dataSource} |
|
||||
keyExtractor={this._keyExtractor} |
|
||||
renderItem={rowData => { |
|
||||
return ( |
|
||||
<BlueListItem |
|
||||
avatar={ |
|
||||
<Icon |
|
||||
color={(() => { |
|
||||
return (rowData.confirmations && ((rowData.value < 0 && '#900') || '#080')) || '#ebebeb'; |
|
||||
})()} |
|
||||
name={(() => { |
|
||||
return (rowData.value < 0 && 'call-made') || 'call-received'; |
|
||||
})()} |
|
||||
/> |
|
||||
} |
|
||||
title={rowData.value / 100000000 + ' BTC' + this.txMemo(rowData.hash)} |
|
||||
subtitle={ |
|
||||
rowData.received |
|
||||
.replace(['T'], ' ') |
|
||||
.replace(['Z'], ' ') |
|
||||
.split('.')[0] + |
|
||||
' | ' + |
|
||||
loc.transactions.list.conf + |
|
||||
': ' + |
|
||||
rowData.confirmations + |
|
||||
'\nYOLO' |
|
||||
} |
|
||||
onPress={() => { |
|
||||
navigate('TransactionDetails', { hash: rowData.hash }); |
|
||||
}} |
|
||||
/> |
|
||||
); |
|
||||
}} |
|
||||
/> |
|
||||
</BlueList> |
|
||||
</BlueCard> |
|
||||
</SafeBlueArea> |
|
||||
); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
TransactionsList.propTypes = { |
|
||||
navigation: PropTypes.shape({ |
|
||||
navigate: PropTypes.func, |
|
||||
}), |
|
||||
}; |
|
Loading…
Reference in new issue