Skip to content

Commit

Permalink
chore: feedback from sam
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Jul 13, 2023
1 parent 48d79c1 commit ae0d34e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ const en: BaseTranslation = {
title: "Receive Bitcoin",
usdTitle: "Receive USD",
error: "Failed to generate invoice. Please contact support if this problem persists.",
copyInvoice: "Copy Invoice",
shareInvoice: "Share Invoice",
copyInvoice: "Copy",
shareInvoice: "Share",
addAmount: "Request Specific Amount",
expired: "The invoice has expired",
expiresIn: "Expires in",
Expand Down
8 changes: 4 additions & 4 deletions app/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,11 +1621,11 @@ type RootTranslation = {
*/
error: string
/**
* C​o​p​y​ ​I​n​v​o​i​c​e
* C​o​p​y
*/
copyInvoice: string
/**
* S​h​a​r​e​ ​I​n​v​o​i​c​e
* S​h​a​r​e
*/
shareInvoice: string
/**
Expand Down Expand Up @@ -4814,11 +4814,11 @@ export type TranslationFunctions = {
*/
error: () => LocalizedString
/**
* Copy Invoice
* Copy
*/
copyInvoice: () => LocalizedString
/**
* Share Invoice
* Share
*/
shareInvoice: () => LocalizedString
/**
Expand Down
4 changes: 2 additions & 2 deletions app/i18n/raw-i18n/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@
"title": "Receive Bitcoin",
"usdTitle": "Receive USD",
"error": "Failed to generate invoice. Please contact support if this problem persists.",
"copyInvoice": "Copy Invoice",
"shareInvoice": "Share Invoice",
"copyInvoice": "Copy",
"shareInvoice": "Share",
"addAmount": "Request Specific Amount",
"expired": "The invoice has expired",
"expiresIn": "Expires in",
Expand Down
62 changes: 36 additions & 26 deletions app/screens/receive-bitcoin-screen/receive-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useI18nContext } from "@app/i18n/i18n-react"
import { requestNotificationPermission } from "@app/utils/notifications"
import { useIsFocused, useNavigation } from "@react-navigation/native"
import React, { useEffect } from "react"
import { Pressable, View } from "react-native"
import { Pressable, TouchableOpacity, View } from "react-native"
import { testProps } from "../../utils/testProps"
import { withMyLnUpdateSub } from "./my-ln-updates-sub"
import { makeStyles, Text, useTheme } from "@rneui/themed"
Expand Down Expand Up @@ -127,30 +127,39 @@ const ReceiveScreen = () => {
/>

<View style={styles.invoiceActions}>
<View style={styles.copyInvoiceContainer}>
<Pressable
{...testProps(LL.ReceiveScreen.copyInvoice())}
onPress={request.copyToClipboard}
>
<Text color={colors.grey2}>
<Icon color={colors.grey2} name="copy-outline" />
<Text> </Text>
{LL.ReceiveScreen.copyInvoice()}
</Text>
</Pressable>
</View>
<View style={styles.shareInvoiceContainer}>
<Pressable
{...testProps(LL.ReceiveScreen.shareInvoice())}
onPress={request.share}
>
<Text color={colors.grey2}>
<Icon color={colors.grey2} name="share-outline" />
<Text> </Text>
{LL.ReceiveScreen.shareInvoice()}
</Text>
</Pressable>
</View>
{request.state !== PaymentRequestState.Loading && (
<>
<View style={styles.copyInvoiceContainer}>
<TouchableOpacity
{...testProps(LL.ReceiveScreen.copyInvoice())}
onPress={request.copyToClipboard}
>
<Text color={colors.grey2}>
<Icon color={colors.grey2} name="copy-outline" />
<Text> </Text>
{LL.ReceiveScreen.copyInvoice()}
</Text>
</TouchableOpacity>
</View>
<TouchableOpacity onPress={request.copyToClipboard}>
<View>
<Text color={colors.grey2}>{request.readablePaymentRequest}</Text>
</View>
</TouchableOpacity>
<View style={styles.shareInvoiceContainer}>
<TouchableOpacity
{...testProps(LL.ReceiveScreen.shareInvoice())}
onPress={request.share}
>
<Text color={colors.grey2}>
<Icon color={colors.grey2} name="share-outline" />
<Text> </Text>
{LL.ReceiveScreen.shareInvoice()}
</Text>
</TouchableOpacity>
</View>
</>
)}
</View>

<View style={styles.extraDetails}>
Expand Down Expand Up @@ -201,7 +210,7 @@ const ReceiveScreen = () => {
const useStyles = makeStyles(({ colors }) => ({
screenStyle: {
paddingHorizontal: 16,
paddingVertical: 2,
paddingBottom: 12,
flexGrow: 1,
},
tabRow: {
Expand Down Expand Up @@ -259,6 +268,7 @@ const useStyles = makeStyles(({ colors }) => ({
flexDirection: "row",
justifyContent: "center",
marginBottom: 10,
height: 20,
},
copyInvoiceContainer: {
flex: 2,
Expand Down
10 changes: 10 additions & 0 deletions app/screens/receive-bitcoin-screen/use-receive-bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ export const useReceiveBitcoin = () => {
extraDetails = `${pr.info.data.username}@${lnAddressHostname}`
}

let readablePaymentRequest = ""
if (pr?.info?.data?.invoiceType === Invoice.Lightning) {
const uri = pr.info?.data?.getFullUriFn({})
readablePaymentRequest = `${uri.slice(0, 6)}..${uri.slice(-6)}`
} else if (pr?.info?.data?.invoiceType === Invoice.OnChain) {
const address = pr.info?.data?.address || ""
readablePaymentRequest = `${address.slice(0, 6)}..${address.slice(-6)}`
}

return {
...prcd,
setType,
Expand All @@ -442,5 +451,6 @@ export const useReceiveBitcoin = () => {
share,
isSetLightningAddressModalVisible,
toggleIsSetLightningAddressModalVisible,
readablePaymentRequest,
}
}

0 comments on commit ae0d34e

Please sign in to comment.