FIX: Dismiss add screen

This commit is contained in:
Marcos Rodriguez Vélez 2018-12-29 13:24:51 -05:00
parent 2ba180a4fa
commit 66bce8874a
6 changed files with 86 additions and 85 deletions

47
App.js
View File

@ -1,10 +1,7 @@
/* global alert */
import React from 'react';
import { Linking } from 'react-native';
import { NavigationActions } from 'react-navigation';
import MainBottomTabs from './MainBottomTabs';
import { LightningCustodianWallet } from './class';
let BlueApp = require('./BlueApp');
export default class App extends React.Component {
navigator = null;
@ -29,33 +26,25 @@ export default class App extends React.Component {
return;
}
if (event.url.indexOf('bitcoin:') === 0 || event.url.indexOf('BITCOIN:') === 0) {
if (BlueApp.getWallets().map(item => item.type !== new LightningCustodianWallet().type).length > 1) {
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'SendDetails',
params: {
uri: event.url,
},
}),
);
} else {
alert('Before sending Bitcoins, you must first add a Bitcoin wallet.');
}
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'SendDetails',
params: {
uri: event.url,
},
}),
);
} else if (event.url.indexOf('lightning:') === 0 || event.url.indexOf('LIGHTNING:') === 0) {
if (BlueApp.getWallets().map(item => item.type === new LightningCustodianWallet().type).length > 1) {
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'ScanLndInvoice',
params: {
uri: event.url,
},
}),
);
} else {
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
}
this.navigator &&
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'ScanLndInvoice',
params: {
uri: event.url,
},
}),
);
}
};

View File

@ -7,4 +7,4 @@ export const FiatUnit = Object.freeze({
CNY: { endPointKey: 'CNY', symbol: '¥', locale: 'zh-CN' },
JPY: { endPointKey: 'JPY', symbol: '¥', locale: 'ja-JP' },
INR: { endPointKey: 'INR', symbol: '₹', locale: 'hi-HN' },
});
});

View File

@ -11,7 +11,7 @@ const loc = require('../../loc');
export default class LNDViewAdditionalInvoiceInformation extends Component {
static navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(navigation, true, () => navigation.dismiss()),
title: "Additional Information",
title: 'Additional Information',
});
state = { walletInfo: undefined };

View File

@ -25,29 +25,34 @@ export default class ScanLndInvoice extends React.Component {
constructor(props) {
super(props);
let fromSecret;
if (props.navigation.state.params.fromSecret) fromSecret = props.navigation.state.params.fromSecret;
let fromWallet = {};
if (!fromSecret) {
const lightningWallets = BlueApp.getWallets().filter(item => item.type === LightningCustodianWallet.type);
if (lightningWallets.length > 0) {
fromSecret = lightningWallets[0].getSecret();
if (!BlueApp.getWallets().some(item => item.type === LightningCustodianWallet.type)) {
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
} else {
let fromSecret;
if (props.navigation.state.params.fromSecret) fromSecret = props.navigation.state.params.fromSecret;
let fromWallet = {};
if (!fromSecret) {
const lightningWallets = BlueApp.getWallets().filter(item => item.type === LightningCustodianWallet.type);
if (lightningWallets.length > 0) {
fromSecret = lightningWallets[0].getSecret();
}
}
}
for (let w of BlueApp.getWallets()) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
for (let w of BlueApp.getWallets()) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
}
}
}
this.state = {
fromWallet,
fromSecret,
destination: '',
};
this.state = {
fromWallet,
fromSecret,
destination: '',
};
}
}
async componentDidMount() {

View File

@ -22,6 +22,7 @@ import BitcoinBIP70TransactionDecode from '../../bip70/bip70';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import { HDLegacyP2PKHWallet, HDSegwitP2SHWallet } from '../../class';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
const bip21 = require('bip21');
let EV = require('../../events');
let BigNumber = require('bignumber.js');
@ -40,46 +41,51 @@ export default class SendDetails extends Component {
constructor(props) {
super(props);
console.log('props.navigation.state.params=', props.navigation.state.params);
let address;
let memo;
if (props.navigation.state.params) address = props.navigation.state.params.address;
if (props.navigation.state.params) memo = props.navigation.state.params.memo;
let fromAddress;
if (props.navigation.state.params) fromAddress = props.navigation.state.params.fromAddress;
let fromSecret;
if (props.navigation.state.params) fromSecret = props.navigation.state.params.fromSecret;
let fromWallet = null;
const wallets = BlueApp.getWallets();
for (let w of wallets) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
if (!BlueApp.getWallets().some(item => item.type !== LightningCustodianWallet.type)) {
alert('Before sending Bitcoins, you must first add a Bitcoin wallet.');
props.navigation.goBack();
} else {
console.log('props.navigation.state.params=', props.navigation.state.params);
let address;
let memo;
if (props.navigation.state.params) address = props.navigation.state.params.address;
if (props.navigation.state.params) memo = props.navigation.state.params.memo;
let fromAddress;
if (props.navigation.state.params) fromAddress = props.navigation.state.params.fromAddress;
let fromSecret;
if (props.navigation.state.params) fromSecret = props.navigation.state.params.fromSecret;
let fromWallet = null;
for (let w of wallets) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
}
if (w.getAddress() === fromAddress) {
fromWallet = w;
}
}
if (w.getAddress() === fromAddress) {
fromWallet = w;
}
// fallback to first wallet if it exists
if (!fromWallet && wallets[0]) fromWallet = wallets[0];
this.state = {
isFeeSelectionModalVisible: false,
fromAddress,
fromWallet,
fromSecret,
isLoading: true,
address,
memo,
fee: 1,
networkTransactionFees: new NetworkTransactionFee(1, 1, 1),
feeSliderValue: 1,
bip70TransactionExpiration: null,
};
}
// fallback to first wallet if it exists
if (!fromWallet && wallets[0]) fromWallet = wallets[0];
this.state = {
isFeeSelectionModalVisible: false,
fromAddress,
fromWallet,
fromSecret,
isLoading: true,
address,
memo,
fee: 1,
networkTransactionFees: new NetworkTransactionFee(1, 1, 1),
feeSliderValue: 1,
bip70TransactionExpiration: null,
};
}
async componentDidMount() {

View File

@ -186,7 +186,6 @@ export default class WalletsAdd extends Component {
width: width / 1.5,
}}
onPress={() => {
this.props.navigation.goBack();
setTimeout(async () => {
let w;
@ -236,6 +235,7 @@ export default class WalletsAdd extends Component {
EV(EV.enum.WALLETS_COUNT_CHANGED);
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
this.props.navigation.dismiss();
}, 1);
}}
/>
@ -258,5 +258,6 @@ WalletsAdd.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
dismiss: PropTypes.func,
}),
};