From 2ee45fa1a49f91194134cd6f1b35c808ea2ffc7a Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Tue, 31 Oct 2023 01:20:00 +0100 Subject: [PATCH] Simplified payment navigation, fix profile sharing --- src/components/ScanIcon.ts | 1 + src/components/index.ts | 1 + src/i18n/en.ts | 16 ++-- src/screens/ProfileScreen.tsx | 17 ++-- src/screens/ReceiveOptionsScreen.tsx | 76 ++++++---------- src/screens/ScanScreen.tsx | 106 ++++++++++++++++------- src/screens/SendOptionsScreen.tsx | 103 +++++++--------------- src/screens/WalletScreen.tsx | 54 +++--------- src/services/lightning/lightningUtils.ts | 17 ++-- src/theme/colors.ts | 2 + 10 files changed, 181 insertions(+), 212 deletions(-) create mode 100644 src/components/ScanIcon.ts diff --git a/src/components/ScanIcon.ts b/src/components/ScanIcon.ts new file mode 100644 index 00000000..e88c440a --- /dev/null +++ b/src/components/ScanIcon.ts @@ -0,0 +1 @@ +export const ScanIcon = ' ' \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index be791acc..11dd5771 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -13,3 +13,4 @@ export * from "./ErrorModal" export * from "./InfoModal" export * from "./BottomModal" export * from "./Loading" +export * from "./ScanIcon" diff --git a/src/i18n/en.ts b/src/i18n/en.ts index b936cd7c..baba06a8 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -62,12 +62,12 @@ const en = { received: "Amount received:", sharePaymentRequest: "Send payment request", sharePaymentRequestDescription: "Send payment request to one of your contacts, so that the payer can pay you exact amount.", - scanToReceive: "Scan ecash token", - scanToReceiveDescription: "Scan ecash token to receive it into your wallet.", + scanToReceive: "Scan or paste to receive", + scanToReceiveDescription: "Scan or paste ecash token or lnurl withdraw link to receive into your wallet.", pasteToReceive: "Paste", pasteoReceiveDescription: "Paste ecash token to receive it into your wallet.", - showOrShareInvoice: "Create lightning invoice", - showOrShareInvoiceDescription: "Present or share the lightning invoice for an amount you want to receive." , + showOrShareInvoice: "Share lightning invoice", + showOrShareInvoiceDescription: "Present or share lightning invoice for an amount you want to receive." , scanWithdrawalLink: "Scan withdrawal link" }, transferScreen: { @@ -80,12 +80,12 @@ const en = { title: "Send", sendToContact: "Send to contact", sendToContactDescription: "Send your ecash to one of your contacts stored in your contact list.", - scanToSend: "Scan lightning invoice", - scanToSendDescription: "Scan invoice, LNURL pay code or lightning address to pay to from your wallet.", + scanToSend: "Scan or paste to send", + scanToSendDescription: "Scan or paste invoice, lnurl pay code or lightning address to pay from your wallet.", pasteToSend: "Paste", pasteToSendDescription: "Paste lightning invoice from clipboard to pay it from your wallet.", - showOrShareToken: "Share ecash token", - showOrShareTokenDescription: "Present or share ecash for an amount you want to send.", + showOrShareToken: "Share ecash", + showOrShareTokenDescription: "Present or share ecash token for an amount you want to send.", }, tranDetailScreen: { amount: "Amount (in satoshis)", diff --git a/src/screens/ProfileScreen.tsx b/src/screens/ProfileScreen.tsx index eda0a6fc..bb81a8b1 100644 --- a/src/screens/ProfileScreen.tsx +++ b/src/screens/ProfileScreen.tsx @@ -3,7 +3,7 @@ import React, {FC, useCallback, useEffect, useState} from 'react' import {ColorValue, Share, TextStyle, View, ViewStyle} from 'react-native' import {colors, spacing, useThemeColor} from '../theme' import {ContactsStackScreenProps} from '../navigation' -import {Icon, ListItem, Screen, Text, Card, BottomModal, Button, InfoModal, ErrorModal, Loading} from '../components' +import {Icon, ListItem, Screen, Text, Card, BottomModal, Button, InfoModal, ErrorModal, Loading, Header} from '../components' import {useHeader} from '../utils/useHeader' import {useStores} from '../models' import AppError from '../utils/AppError' @@ -19,13 +19,6 @@ interface ProfileScreenProps extends ContactsStackScreenProps<'Profile'> {} export const ProfileScreen: FC = observer( function ProfileScreen({navigation}) { - useHeader({ - leftIcon: 'faArrowLeft', - onLeftPress: () => navigation.goBack(), - rightIcon: 'faShareFromSquare', - onRightPress: () => onShareContact() - }) - const {walletProfileStore, userSettingsStore} = useStores() const {npub, name, picture, nip05} = walletProfileStore @@ -116,7 +109,13 @@ export const ProfileScreen: FC = observer( const iconNpub = useThemeColor('textDim') return ( - + +
{!walletProfileStore.isOwnProfile && ( diff --git a/src/screens/ReceiveOptionsScreen.tsx b/src/screens/ReceiveOptionsScreen.tsx index e0547eba..e09531b2 100644 --- a/src/screens/ReceiveOptionsScreen.tsx +++ b/src/screens/ReceiveOptionsScreen.tsx @@ -3,18 +3,17 @@ import React, {FC, useState, useCallback} from 'react' import {useFocusEffect} from '@react-navigation/native' import {Alert, TextStyle, View, ViewStyle} from 'react-native' import Clipboard from '@react-native-clipboard/clipboard' +import { SvgXml } from 'react-native-svg' import {spacing, useThemeColor, colors} from '../theme' import {WalletStackScreenProps} from '../navigation' import { - Button, - Icon, Card, Screen, InfoModal, ErrorModal, ListItem, - BottomModal, Text, + ScanIcon, } from '../components' import {useHeader} from '../utils/useHeader' import {log} from '../utils/logger' @@ -57,31 +56,8 @@ export const ReceiveOptionsScreen: FC> } - const onScanToken = async function () { - navigation.navigate('Scan', {expectedType: IncomingDataType.CASHU}) - } - - const onScanLnurl = async function () { - navigation.navigate('Scan', {expectedType: IncomingDataType.LNURL}) - } - - - const onPaste = async function () { - const clipboard = await Clipboard.getString() - if (!clipboard) { - infoMessage('Please copy the ecash token first.') - } - - try { - const incomingData = IncomingParser.findAndExtract(clipboard, IncomingDataType.CASHU) - - infoMessage('Found ecash token in the clipboard.') - setTimeout(() => navigation.navigate('Receive', {encodedToken: incomingData.encoded}), 1000) - return - - } catch (e: any) { - handleError(e) - } + const onScan = async function () { + navigation.navigate('Scan', {}) } @@ -121,39 +97,41 @@ export const ReceiveOptionsScreen: FC> tx="receiveScreen.showOrShareInvoice" subTx="receiveScreen.showOrShareInvoiceDescription" leftIcon='faBolt' - leftIconColor={colors.palette.accent300} + leftIconColor={colors.palette.orange200} leftIconInverse={true} style={$item} onPress={gotoTopup} /> -