Merge branch 'master' into filepicker

This commit is contained in:
Marcos Rodriguez 2020-01-04 09:35:27 -06:00
commit 41054fe7a2
2 changed files with 56 additions and 75 deletions

View file

@ -25,11 +25,16 @@ Community: [telegram group](https://t.me/bluewallet)
<img src="https://i.imgur.com/hHYJnMj.png" width="100%">
## BUILD & RUN IT
Please refer to the engines field in package.json file for the minimum required versions of Node and npm. It is preferred that you use an even-numbered version of Node as these are LTS versions.
To view the version of Node and npm in your environment, run the following in your console:
```
node --version && npm --version
```
* In your console:
```
@ -38,6 +43,8 @@ cd BlueWallet
npm install
```
Please make sure that your console is running the most stable versions of npm and node (even-numbered versions).
* To run on Android:
You will now need to either connect an Android device to your computer or run an emulated Android device using AVD Manager which comes shipped with Android Studio. To run an emulator using AVD Manager:

View file

@ -1,51 +1,35 @@
import React, { Component } from 'react';
/* eslint-disable react/prop-types */
import React, { useEffect, useState } from 'react';
import { View, ActivityIndicator, Image, Text, TouchableOpacity, FlatList } from 'react-native';
import { SafeBlueArea, BlueNavigationStyle, BlueText, BlueSpacing20, BluePrivateBalance } from '../../BlueComponents';
import LinearGradient from 'react-native-linear-gradient';
import PropTypes from 'prop-types';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import WalletGradient from '../../class/walletGradient';
import { useNavigationParam } from 'react-navigation-hooks';
import { Chain } from '../../models/bitcoinUnits';
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
const BlueApp = require('../../BlueApp');
const loc = require('../../loc');
export default class SelectWallet extends Component {
static navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(navigation, true, navigation.getParam('dismissAcion')),
title: loc.wallets.select_wallet,
const SelectWallet = () => {
const chainType = useNavigationParam('chainType') || Chain.ONCHAIN;
const onWalletSelect = useNavigationParam('onWalletSelect');
const [isLoading, setIsLoading] = useState(true);
const data = chainType
? BlueApp.getWallets().filter(item => item.chain === chainType && item.allowSend())
: BlueApp.getWallets().filter(item => item.allowSend()) || [];
useEffect(() => {
setIsLoading(false);
});
constructor(props) {
super(props);
props.navigation.setParams({ dismissAcion: this.dismissComponent });
this.state = {
isLoading: true,
data: [],
};
this.chainType = props.navigation.getParam('chainType');
}
dismissComponent = () => {
this.props.navigation.goBack(null);
};
componentDidMount() {
const wallets = this.chainType
? BlueApp.getWallets().filter(item => item.chain === this.chainType && item.allowSend())
: BlueApp.getWallets().filter(item => item.allowSend());
this.setState({
data: wallets,
isLoading: false,
});
}
_renderItem = ({ item }) => {
const renderItem = ({ item }) => {
return (
<TouchableOpacity
onPress={() => {
ReactNativeHapticFeedback.trigger('selection', { ignoreAndroidSystemSettings: false });
this.props.navigation.getParam('onWalletSelect')(item);
onWalletSelect(item);
}}
>
<View
@ -132,46 +116,36 @@ export default class SelectWallet extends Component {
);
};
render() {
if (this.state.isLoading) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignContent: 'center', paddingTop: 20 }}>
<ActivityIndicator />
</View>
);
} else if (this.state.data.length <= 0) {
return (
<SafeBlueArea style={{ flex: 1 }}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingTop: 20 }}>
<BlueText style={{ textAlign: 'center' }}>There are currently no Bitcoin wallets available.</BlueText>
<BlueSpacing20 />
<BlueText style={{ textAlign: 'center' }}>
A Bitcoin wallet is required to refill Lightning wallets. Please, create or import one.
</BlueText>
</View>
</SafeBlueArea>
);
}
if (isLoading) {
return (
<SafeBlueArea>
<FlatList
style={{ flex: 1 }}
extraData={this.state.data}
data={this.state.data}
renderItem={this._renderItem}
keyExtractor={(_item, index) => `${index}`}
/>
<View style={{ flex: 1, justifyContent: 'center', alignContent: 'center', paddingTop: 20 }}>
<ActivityIndicator />
</View>
);
} else if (data.length <= 0) {
return (
<SafeBlueArea style={{ flex: 1 }}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingTop: 20 }}>
<BlueText style={{ textAlign: 'center' }}>There are currently no Bitcoin wallets available.</BlueText>
<BlueSpacing20 />
<BlueText style={{ textAlign: 'center' }}>
A Bitcoin wallet is required to refill Lightning wallets. Please, create or import one.
</BlueText>
</View>
</SafeBlueArea>
);
} else {
return (
<SafeBlueArea style={{ flex: 1 }}>
<FlatList extraData={data} data={data} renderItem={renderItem} keyExtractor={(_item, index) => `${index}`} />
</SafeBlueArea>
);
}
}
SelectWallet.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
setParams: PropTypes.func,
getParam: PropTypes.func,
}),
};
SelectWallet.navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(navigation, true, () => navigation.goBack(null)),
title: loc.wallets.select_wallet,
});
export default SelectWallet;