diff --git a/loc/en.json b/loc/en.json index a0dc6902d..13420ef26 100644 --- a/loc/en.json +++ b/loc/en.json @@ -627,7 +627,6 @@ "pay_this_contact": "Pay this contact", "rename_contact": "Rename contact", "copy_payment_code": "Copy Payment Code", - "copied": "Copied", "rename": "Rename", "provide_name": "Provide new name for this contact", "add_contact": "Add Contact", diff --git a/navigation/DetailViewScreensStack.tsx b/navigation/DetailViewScreensStack.tsx index ee2c973a4..6e4024c76 100644 --- a/navigation/DetailViewScreensStack.tsx +++ b/navigation/DetailViewScreensStack.tsx @@ -72,6 +72,7 @@ import ViewEditMultisigCosignersStackRoot from './ViewEditMultisigCosignersStack import WalletExportStack from './WalletExportStack'; import WalletXpubStackRoot from './WalletXpubStack'; import { StackActions } from '@react-navigation/native'; +import PaymentCodeStackRoot from './PaymentCodeStack'; const DetailViewStackScreensStack = () => { const theme = useTheme(); @@ -220,6 +221,8 @@ const DetailViewStackScreensStack = () => { closeButtonFunc: popToTop, })(theme)} /> + + ; }; }; - PaymentCodeRoot: undefined; + PaymentCodeListRoot: { + screen: 'PaymentCodeList'; + params: { + paymentCode: string; + walletID: string; + }; + }; ReorderWallets: undefined; }; diff --git a/navigation/LazyLoadPaymentCodeStack.tsx b/navigation/LazyLoadPaymentCodeStack.tsx new file mode 100644 index 000000000..ddd7bef2f --- /dev/null +++ b/navigation/LazyLoadPaymentCodeStack.tsx @@ -0,0 +1,11 @@ +import React, { lazy, Suspense } from 'react'; + +import { LazyLoadingIndicator } from './LazyLoadingIndicator'; + +const PaymentCodesList = lazy(() => import('../screen/wallets/PaymentCodesList')); + +export const PaymentCodesListComponent = () => ( + }> + + +); diff --git a/navigation/PaymentCodeStack.tsx b/navigation/PaymentCodeStack.tsx new file mode 100644 index 000000000..a0b2f14dd --- /dev/null +++ b/navigation/PaymentCodeStack.tsx @@ -0,0 +1,25 @@ +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +import React from 'react'; +import navigationStyle from '../components/navigationStyle'; +import { useTheme } from '../components/themes'; +import loc from '../loc'; // Assuming 'loc' is used for localization +import { PaymentCodesListComponent } from './LazyLoadPaymentCodeStack'; +import { PaymentCodeStackParamList } from './PaymentCodeStackParamList'; + +const Stack = createNativeStackNavigator(); + +const PaymentCodeStackRoot = () => { + const theme = useTheme(); + + return ( + + + + ); +}; + +export default PaymentCodeStackRoot; diff --git a/navigation/PaymentCodeStackParamList.ts b/navigation/PaymentCodeStackParamList.ts new file mode 100644 index 000000000..e7d5281a8 --- /dev/null +++ b/navigation/PaymentCodeStackParamList.ts @@ -0,0 +1,17 @@ +import { BitcoinUnit } from '../models/bitcoinUnits'; + +export type PaymentCodeStackParamList = { + PaymentCode: { paymentCode: string }; + PaymentCodesList: { + memo: string; + address: string; + walletID: string; + amount: number; + amountSats: number; + unit: BitcoinUnit; + noRbf: boolean; + launchedBy: string; + isEditable: boolean; + uri: string /* payjoin uri */; + }; +}; diff --git a/navigation/SendDetailsStack.tsx b/navigation/SendDetailsStack.tsx index 4d0598d62..1e6fabb6a 100644 --- a/navigation/SendDetailsStack.tsx +++ b/navigation/SendDetailsStack.tsx @@ -77,7 +77,7 @@ const SendDetailsStack = () => { /> diff --git a/navigation/SendDetailsStackParamList.ts b/navigation/SendDetailsStackParamList.ts index 588459479..0a6d56cda 100644 --- a/navigation/SendDetailsStackParamList.ts +++ b/navigation/SendDetailsStackParamList.ts @@ -3,27 +3,6 @@ import { CreateTransactionTarget, CreateTransactionUtxo, TWallet } from '../clas import { BitcoinUnit, Chain } from '../models/bitcoinUnits'; export type SendDetailsStackParamList = { - SendDetailsRoot: { - screen: string; - params: { - memo?: string; - address?: string; - walletID: string; - amount?: number; - amountSats?: number; - unit?: BitcoinUnit; - noRbf?: boolean; - launchedBy?: string; - isEditable?: boolean; - uri?: string; - addRecipientParams?: { - address: string; - amount?: number; - memo?: string; - }; - }; - merge: boolean; - }; SendDetails: { memo: string; address: string; @@ -96,7 +75,7 @@ export type SendDetailsStackParamList = { walletID: string; onUTXOChoose: (u: CreateTransactionUtxo[]) => void; }; - PaymentCodesList: { + PaymentCodeList: { walletID: string; }; ScanQRCodeRoot: { diff --git a/screen/send/SendDetails.tsx b/screen/send/SendDetails.tsx index c5dee92ac..374e76139 100644 --- a/screen/send/SendDetails.tsx +++ b/screen/send/SendDetails.tsx @@ -77,6 +77,7 @@ type RouteProps = RouteProp; const SendDetails = () => { const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useStorage(); const navigation = useExtendedNavigation(); + const setParams = navigation.setParams; const route = useRoute(); const name = route.name; const routeParams = route.params; @@ -171,6 +172,8 @@ const SendDetails = () => { return [...addrs]; }); } + setParams({ addRecipientParams: undefined }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [routeParams.addRecipientParams]); useEffect(() => { @@ -891,7 +894,7 @@ const SendDetails = () => { const handleInsertContact = () => { if (!wallet) return; setOptionsVisible(false); - navigation.navigate('PaymentCodesList', { walletID: wallet.getID() }); + navigation.navigate('PaymentCodeList', { walletID: wallet.getID() }); }; const handlePsbtSign = async () => { diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index b1f6960e1..41826b91d 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -4,7 +4,7 @@ import { RouteProp, useRoute } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import assert from 'assert'; import createHash from 'create-hash'; -import { SectionList, StyleSheet, Text, View } from 'react-native'; +import { SectionList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import { satoshiToLocalCurrency } from '../../blue_modules/currency'; import { BlueLoading } from '../../BlueComponents'; @@ -23,12 +23,14 @@ import { BitcoinUnit } from '../../models/bitcoinUnits'; import SafeArea from '../../components/SafeArea'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { useStorage } from '../../hooks/context/useStorage'; +import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList'; import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackParamList'; interface DataSection { title: string; data: string[]; } + enum Actions { pay, rename, @@ -66,13 +68,16 @@ function onlyUnique(value: any, index: number, self: any[]) { return self.indexOf(value) === index; } -type PaymentCodeListRouteProp = RouteProp; -type PaymentCodesListNavigationProp = NativeStackNavigationProp; +type PaymentCodeListModalProp = RouteProp; +type PaymentCodesListModalNavigationProp = NativeStackNavigationProp; + +type PaymentCodeListRouteProp = RouteProp; +type PaymentCodesListNavigationProp = NativeStackNavigationProp; export default function PaymentCodesList() { - const route = useRoute(); - const navigation = useExtendedNavigation(); - const { walletID } = route.params; + const { params } = useRoute(); + const navigation = useExtendedNavigation(); + const { walletID } = params; const { wallets, txMetadata, counterpartyMetadata, saveToDisk } = useStorage(); const [reload, setReload] = useState(0); const [data, setData] = useState([]); @@ -105,7 +110,6 @@ export default function PaymentCodesList() { const onToolTipPress = async (id: any, pc: string) => { if (String(id) === String(Actions.copyToClipboard)) { Clipboard.setString(pc); - presentAlert({ message: loc.bip47.copied }); } if (String(id) === String(Actions.rename)) { @@ -160,6 +164,22 @@ export default function PaymentCodesList() { const displayName = shortenContactName(counterpartyMetadata?.[pc]?.label ?? pc); + const isFirstRouteInStack = navigation.getState().index === 0; + + if (isFirstRouteInStack) { + return ( + _navigateToSend(pc)}> + + + + {displayName} + + + + + ); + } + return (