REF: Single call for buy bitcoin

This commit is contained in:
marcosrdz 2020-09-07 11:35:51 -04:00 committed by Overtorment
parent a590e28997
commit 04b155e1cc
3 changed files with 22 additions and 23 deletions

View file

@ -438,7 +438,7 @@ export default class ScanLndInvoice extends React.Component {
<ActivityIndicator />
</View>
) : (
<View style={styles.payButtonContainer}>
<View style={styles.payButtonContainer}>
<BlueButton title={loc.lnd.payButton} onPress={() => this.pay()} disabled={this.shouldDisablePayButton()} />
</View>
)}

View file

@ -1,12 +1,13 @@
import React, { Component } from 'react';
import { StyleSheet, StatusBar } from 'react-native';
import { StyleSheet, StatusBar, Linking, Platform } from 'react-native';
import { BlueNavigationStyle, BlueLoading, SafeBlueArea } from '../../BlueComponents';
import PropTypes from 'prop-types';
import { WebView } from 'react-native-webview';
import { AppStorage, LightningCustodianWallet, WatchOnlyWallet } from '../../class';
import InAppBrowser from 'react-native-inappbrowser-reborn';
import * as NavigationService from '../../NavigationService';
const currency = require('../../blue_modules/currency');
const BlueApp: AppStorage = require('../../BlueApp');
const styles = StyleSheet.create({
root: {
flex: 1,
@ -108,3 +109,19 @@ BuyBitcoin.navigationOptions = ({ navigation }) => ({
title: '',
headerLeft: null,
});
BuyBitcoin.navigate = async wallet => {
const uri = await BuyBitcoin.generateURL(wallet);
if (Platform.OS === 'ios') {
InAppBrowser.isAvailable()
.then(_value => InAppBrowser.open(uri, { dismissButtonStyle: 'done' }))
.catch(error => {
console.log(error);
Linking.openURL(uri);
});
} else {
NavigationService.navigate('BuyBitcoin', {
wallet,
});
}
};

View file

@ -29,7 +29,6 @@ import {
BlueWalletNavigationHeader,
BlueAlertWalletExportReminder,
} from '../../BlueComponents';
import InAppBrowser from 'react-native-inappbrowser-reborn';
import WalletGradient from '../../class/wallet-gradient';
import { Icon } from 'react-native-elements';
import { LightningCustodianWallet, WatchOnlyWallet } from '../../class';
@ -646,25 +645,8 @@ export default class WalletTransactions extends Component {
}
};
navigateToBuyBitcoin = async () => {
const uri = await BuyBitcoin.generateURL(this.state.wallet);
if (getSystemName() === 'Mac OS X') {
InAppBrowser.isAvailable()
.then(_value => InAppBrowser.open(uri, { dismissButtonStyle: 'done' }))
.catch(_error => Linking.openURL(uri));
} else if (Platform.OS === 'ios') {
InAppBrowser.isAvailable()
.then(_value => InAppBrowser.open(uri, { dismissButtonStyle: 'done' }))
.catch(_error =>
this.props.navigation.navigate('BuyBitcoin', {
wallet: this.state.wallet,
}),
);
} else {
this.props.navigation.navigate('BuyBitcoin', {
wallet: this.state.wallet,
});
}
navigateToBuyBitcoin = () => {
BuyBitcoin.navigate(this.state.wallet);
};
render() {