Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display amount on Receive screen above QR code #1602

Draft
wants to merge 3 commits into
base: master
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions components/CollapsedQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import QRCode from 'react-native-qrcode-svg';

import HCESession, { NFCContentType, NFCTagType4 } from 'react-native-hce';

import Button from './../components/Button';
import Amount from './Amount';
import Button from './Button';
import CopyButton from './CopyButton';
import { localeString } from './../utils/LocaleUtils';
import { themeColor } from './../utils/ThemeUtils';
import Touchable from './Touchable';
import Conversion from './Conversion';

const logo = require('../assets/images/Launcher.png');

Expand Down Expand Up @@ -51,6 +53,7 @@ interface CollapsedQRProps {
expanded?: boolean;
textBottom?: boolean;
truncateLongValue?: boolean;
satAmount?: string | number;
}

interface CollapsedQRState {
Expand Down Expand Up @@ -117,13 +120,27 @@ export default class CollapsedQR extends React.Component<
hideText,
expanded,
textBottom,
truncateLongValue
truncateLongValue,
satAmount
} = this.props;

const { width, height } = Dimensions.get('window');

return (
<React.Fragment>
{satAmount != null && (
<View
style={{
flexDirection: 'column',
alignItems: 'center'
}}
>
<Amount sats={satAmount} toggleable></Amount>
<View>
<Conversion sats={satAmount} sensitive />
</View>
</View>
)}
{!hideText && !textBottom && (
<ValueText
value={value}
Expand Down
8 changes: 6 additions & 2 deletions views/Invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export default class InvoiceView extends React.Component<InvoiceProps> {
cltv_expiry,
expirationDate,
getPaymentRequest,
getKeysendMessage
getKeysendMessage,
getAmount
} = invoice;
const privateInvoice = invoice.private;
const noteKey = getRPreimage || payment_hash;
Expand All @@ -68,7 +69,10 @@ export default class InvoiceView extends React.Component<InvoiceProps> {
<Icon
name="qr-code"
onPress={() => {
navigation.navigate('QR', { value: getPaymentRequest });
navigation.navigate('QR', {
value: getPaymentRequest,
satAmount: getAmount
});
}}
color={themeColor('text')}
underlayColor="transparent"
Expand Down
5 changes: 4 additions & 1 deletion views/PaymentRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ export default class PaymentRequest extends React.Component<
<Icon
name="qr-code"
onPress={() => {
navigation.navigate('QR', { value: paymentRequest });
navigation.navigate('QR', {
value: paymentRequest,
satAmount: requestAmount
});
myxmaster marked this conversation as resolved.
Show resolved Hide resolved
}}
color={themeColor('text')}
underlayColor="transparent"
Expand Down
20 changes: 15 additions & 5 deletions views/QR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ interface QRProps {

interface QRState {
value: string;
satAmount?: number;
}

export default class QR extends React.PureComponent<QRProps, QRState> {
constructor(props: any) {
super(props);
const value: string = this.props.navigation.getParam('value', '');
const satAmount: number | undefined =
this.props.navigation.getParam('satAmount');

this.state = {
value
value,
satAmount
};
}

render() {
const { navigation } = this.props;
const { value } = this.state;
const { value, satAmount } = this.state;

return (
<Screen>
Expand All @@ -38,11 +43,16 @@ export default class QR extends React.PureComponent<QRProps, QRState> {
/>
<View
style={{
top: 5,
padding: 15
paddingLeft: 15,
paddingRight: 15
}}
>
<CollapsedQR value={value} expanded textBottom />
<CollapsedQR
value={value}
satAmount={satAmount}
expanded
textBottom
/>
</View>
</Screen>
);
Expand Down
10 changes: 9 additions & 1 deletion views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ export default class Receive extends React.Component<
</TouchableOpacity>
)}
{haveInvoice && !creatingInvoiceError && (
<View style={{ marginTop: 10 }}>
<View>
{selectedIndex == 0 &&
!belowDustLimit &&
haveUnifiedInvoice && (
Expand All @@ -1324,6 +1324,7 @@ export default class Receive extends React.Component<
expanded
textBottom
truncateLongValue
satAmount={satAmount}
/>
)}
{selectedIndex == 1 &&
Expand All @@ -1338,6 +1339,7 @@ export default class Receive extends React.Component<
expanded
textBottom
truncateLongValue
satAmount={satAmount}
/>
)}
{selectedIndex == 2 &&
Expand All @@ -1352,6 +1354,11 @@ export default class Receive extends React.Component<
expanded
textBottom
truncateLongValue
satAmount={
satAmount === '0'
? undefined
: satAmount
}
/>
)}
{selectedIndex !== 2 &&
Expand All @@ -1366,6 +1373,7 @@ export default class Receive extends React.Component<
expanded
textBottom
truncateLongValue
satAmount={satAmount}
/>
)}
<View
Expand Down