Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 09d5baa

Browse files
committed
Redirect navigation flow for 0 value invocies.
Detecting a zero amount invoice in checkType we redirect to a seperate view. Currently only title is changed in the view.
1 parent 35e7871 commit 09d5baa

8 files changed

+215
-1
lines changed

jsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2017",
4+
"allowSyntheticDefaultImports": true,
5+
"noEmit": true,
6+
"checkJs": true,
7+
"jsx": "react",
8+
"lib": [ "dom", "es2017" ]
9+
}
10+
}

src/action/nav-mobile.js

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class NavAction {
119119
this._navigate('Pay');
120120
}
121121

122+
goPayLightningSupplyAmount() {
123+
this._navigate('PayLightningSupplyAmount');
124+
}
125+
122126
goPayLightningConfirm() {
123127
this._navigate('PayLightningConfirm');
124128
}

src/action/nav.js

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ class NavAction {
8181
this._store.route = 'Pay';
8282
}
8383

84+
goPayLightningSupplyAmount() {
85+
this._store.route = 'PayLightningSupplyAmount';
86+
}
87+
8488
goPayLightningConfirm() {
8589
this._store.route = 'PayLightningConfirm';
8690
}

src/action/payment.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ class PaymentAction {
165165
return this._notification.display({ msg: 'Enter an invoice or address' });
166166
}
167167
if (await this.decodeInvoice({ invoice: this._store.payment.address })) {
168-
this._nav.goPayLightningConfirm();
168+
if (
169+
this._store.payment.amount === '0' ||
170+
this._store.payment.amount === 0
171+
) {
172+
this._nav.goPayLightningSupplyAmount();
173+
} else {
174+
this._nav.goPayLightningConfirm();
175+
}
169176
} else if (isAddress(this._store.payment.address)) {
170177
this._nav.goPayBitcoin();
171178
} else {

src/view/main-mobile.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import SettingUnitView from './setting-unit';
3333
import SettingFiatView from './setting-fiat';
3434
import CLIView from './cli';
3535
import PaymentView from './payment-mobile';
36+
import PayLightningSupplyAmountView from './pay-lightning-supply-amount-mobile';
3637
import PayLightningConfirmView from './pay-lightning-confirm-mobile';
3738
import PayLightningDoneView from './pay-lightning-done-mobile';
3839
import PaymentFailedView from './payment-failed-mobile';
@@ -171,6 +172,10 @@ const InvoiceQR = () => (
171172

172173
const Pay = () => <PaymentView store={store} payment={payment} nav={nav} />;
173174

175+
const PayLightningSupplyAmount = () => (
176+
<PayLightningSupplyAmountView store={store} payment={payment} nav={nav} />
177+
);
178+
174179
const PayLightningConfirm = () => (
175180
<PayLightningConfirmView store={store} payment={payment} nav={nav} />
176181
);
@@ -236,6 +241,7 @@ const InvoiceStack = createStackNavigator(
236241
const PayStack = createStackNavigator(
237242
{
238243
Pay,
244+
PayLightningSupplyAmount,
239245
PayLightningConfirm,
240246
Wait,
241247
PayLightningDone,

src/view/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import LoaderSyncing from './loader-syncing';
2121
import Wait from './wait';
2222
import Home from './home';
2323
import Payment from './payment';
24+
import PayLightningSupplyAmount from './pay-lightning-supply-amount';
2425
import PayLightningConfirm from './pay-lightning-confirm';
2526
import PayLightningDone from './pay-lightning-done';
2627
import PaymentFailed from './payment-failed';
@@ -130,6 +131,9 @@ class MainView extends Component {
130131
{route === 'Pay' && (
131132
<Payment store={store} payment={payment} nav={nav} />
132133
)}
134+
{route === 'PayLightningSupplyAmount' && (
135+
<PayLightningSupplyAmount store={store} payment={payment} nav={nav} />
136+
)}
133137
{route === 'PayLightningConfirm' && (
134138
<PayLightningConfirm store={store} payment={payment} nav={nav} />
135139
)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import React from 'react';
2+
import { StyleSheet } from 'react-native';
3+
import { observer } from 'mobx-react';
4+
import PropTypes from 'prop-types';
5+
import Background from '../component/background';
6+
import MainContent from '../component/main-content';
7+
import { NamedField } from '../component/field';
8+
import { Header, Title } from '../component/header';
9+
import { CancelButton, BackButton, SmallGlasButton } from '../component/button';
10+
import Card from '../component/card';
11+
import LightningBoltIcon from '../asset/icon/lightning-bolt';
12+
import { FormStretcher } from '../component/form';
13+
import {
14+
BalanceLabel,
15+
BalanceLabelNumeral,
16+
BalanceLabelUnit,
17+
} from '../component/label';
18+
import { color } from '../component/style';
19+
20+
const styles = StyleSheet.create({
21+
balance: {
22+
marginBottom: 10,
23+
},
24+
numeral: {
25+
color: color.blackText,
26+
},
27+
unit: {
28+
color: color.blackText,
29+
},
30+
totalLbl: {
31+
marginTop: 5,
32+
},
33+
note: {
34+
marginTop: 5,
35+
borderBottomWidth: 0,
36+
},
37+
confirmBtn: {
38+
marginTop: 20,
39+
},
40+
});
41+
42+
const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
43+
<Background color={color.purple}>
44+
<Header color={color.purple}>
45+
<BackButton onPress={() => nav.goPay()} />
46+
<Title title="Supply Lightning Payment Amount">
47+
<LightningBoltIcon height={12} width={6.1} />
48+
</Title>
49+
<CancelButton onPress={() => nav.goHome()} />
50+
</Header>
51+
<MainContent>
52+
<Card>
53+
<FormStretcher>
54+
<BalanceLabel style={styles.balance}>
55+
<BalanceLabelNumeral style={styles.numeral}>
56+
{store.paymentAmountLabel}
57+
</BalanceLabelNumeral>
58+
<BalanceLabelUnit style={styles.unit}>
59+
{store.unitLabel}
60+
</BalanceLabelUnit>
61+
</BalanceLabel>
62+
<NamedField name="Fee">
63+
{store.paymentFeeLabel} {store.unitLabel}
64+
</NamedField>
65+
<NamedField name="Total" style={styles.totalLbl}>
66+
{store.paymentTotalLabel} {store.unitLabel}
67+
</NamedField>
68+
{store.payment.note ? (
69+
<NamedField name="Note" style={styles.note}>
70+
{store.payment.note}
71+
</NamedField>
72+
) : null}
73+
</FormStretcher>
74+
</Card>
75+
</MainContent>
76+
<SmallGlasButton onPress={() => payment.payLightning()}>
77+
Confirm
78+
</SmallGlasButton>
79+
</Background>
80+
);
81+
82+
PayLightningSupplyAmountView.propTypes = {
83+
store: PropTypes.object.isRequired,
84+
nav: PropTypes.object.isRequired,
85+
payment: PropTypes.object.isRequired,
86+
};
87+
88+
export default observer(PayLightningSupplyAmountView);
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import React from 'react';
2+
import { StyleSheet } from 'react-native';
3+
import { observer } from 'mobx-react';
4+
import PropTypes from 'prop-types';
5+
import Background from '../component/background';
6+
import MainContent from '../component/main-content';
7+
import { NamedField } from '../component/field';
8+
import { Header, Title } from '../component/header';
9+
import { CancelButton, BackButton, PillButton } from '../component/button';
10+
import Card from '../component/card';
11+
import LightningBoltIcon from '../asset/icon/lightning-bolt';
12+
import { FormStretcher } from '../component/form';
13+
import {
14+
BalanceLabel,
15+
BalanceLabelNumeral,
16+
BalanceLabelUnit,
17+
} from '../component/label';
18+
import { color } from '../component/style';
19+
20+
const styles = StyleSheet.create({
21+
balance: {
22+
marginBottom: 10,
23+
},
24+
numeral: {
25+
color: color.blackText,
26+
},
27+
unit: {
28+
color: color.blackText,
29+
},
30+
totalLbl: {
31+
marginTop: 5,
32+
},
33+
note: {
34+
marginTop: 5,
35+
borderBottomWidth: 0,
36+
},
37+
confirmBtn: {
38+
marginTop: 20,
39+
},
40+
});
41+
42+
const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
43+
<Background image="purple-gradient-bg">
44+
<Header shadow color={color.purple}>
45+
<BackButton onPress={() => nav.goPay()} />
46+
<Title title="Supply Lightning Amount">
47+
<LightningBoltIcon height={12} width={6.1} />
48+
</Title>
49+
<CancelButton onPress={() => nav.goHome()} />
50+
</Header>
51+
<MainContent>
52+
<Card>
53+
<FormStretcher>
54+
<BalanceLabel style={styles.balance}>
55+
<BalanceLabelNumeral style={styles.numeral}>
56+
{store.paymentAmountLabel}
57+
</BalanceLabelNumeral>
58+
<BalanceLabelUnit style={styles.unit}>
59+
{store.unitLabel}
60+
</BalanceLabelUnit>
61+
</BalanceLabel>
62+
<NamedField name="Fee">
63+
{store.paymentFeeLabel} {store.unitLabel}
64+
</NamedField>
65+
<NamedField name="Total" style={styles.totalLbl}>
66+
{store.paymentTotalLabel} {store.unitLabel}
67+
</NamedField>
68+
{store.payment.note ? (
69+
<NamedField name="Note" style={styles.note}>
70+
{store.payment.note}
71+
</NamedField>
72+
) : null}
73+
</FormStretcher>
74+
<PillButton
75+
style={styles.confirmBtn}
76+
onPress={() => payment.payLightning()}
77+
>
78+
Confirm
79+
</PillButton>
80+
</Card>
81+
</MainContent>
82+
</Background>
83+
);
84+
85+
PayLightningSupplyAmountView.propTypes = {
86+
store: PropTypes.object.isRequired,
87+
nav: PropTypes.object.isRequired,
88+
payment: PropTypes.object.isRequired,
89+
};
90+
91+
export default observer(PayLightningSupplyAmountView);

0 commit comments

Comments
 (0)