From 307e3b93c8721e132b3d8b7b3124b14083bfa827 Mon Sep 17 00:00:00 2001 From: KraXen72 Date: Fri, 28 Jun 2024 09:25:03 +0200 Subject: [PATCH] Lightning: Support for payment comments, Tor mint support (#83) Co-authored-by: minibits-cash --- .gitignore | 4 +- minibits.inlang/.gitignore | 1 + minibits.inlang/settings.json | 7 +- src/components/AvatarHeader.tsx | 2 +- src/components/BottomModal.tsx | 26 +- src/components/Loading.tsx | 37 +- src/components/MemoInputCard.tsx | 77 +++ src/i18n_messages/en.json | 11 +- src/i18n_messages/sk.json | 3 +- src/screens/BackupScreen.tsx | 1 - src/screens/Contacts/OwnName.tsx | 2 +- src/screens/LightningPayScreen.tsx | 13 +- src/screens/MintInfoScreen.tsx | 23 +- src/screens/MintsScreen.tsx | 7 - .../PaymentRequests/IncomingRequests.tsx | 2 +- src/screens/PictureScreen.tsx | 2 +- src/screens/SendScreen.tsx | 48 +- src/screens/TranHistoryScreen.tsx | 4 +- .../Transactions/TransactionListItem.tsx | 14 +- src/screens/TransferScreen.tsx | 602 ++++++++++-------- src/screens/WalletScreen.tsx | 12 +- src/services/cashuMintClient.ts | 109 ++-- src/services/lnurlService.ts | 22 +- src/services/wallet/transferTask.ts | 3 +- 24 files changed, 607 insertions(+), 425 deletions(-) create mode 100644 minibits.inlang/.gitignore create mode 100644 src/components/MemoInputCard.tsx diff --git a/.gitignore b/.gitignore index fb8dcc84..bc52320a 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,6 @@ yarn-error.log .metro-health-check* # testing -/coverage \ No newline at end of file +/coverage + +minibits.inlang/cache \ No newline at end of file diff --git a/minibits.inlang/.gitignore b/minibits.inlang/.gitignore new file mode 100644 index 00000000..5e465967 --- /dev/null +++ b/minibits.inlang/.gitignore @@ -0,0 +1 @@ +cache \ No newline at end of file diff --git a/minibits.inlang/settings.json b/minibits.inlang/settings.json index 2e7f4338..18ab7a59 100644 --- a/minibits.inlang/settings.json +++ b/minibits.inlang/settings.json @@ -8,7 +8,7 @@ "modules": [ "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js", "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js", - "https://cdn.jsdelivr.net/gh/KraXen72/inlang-t-function-jsx-hybrid-matcher/dist/index.js", + "https://cdn.jsdelivr.net/gh/KraXen72/inlang-t-function-jsx-hybrid-matcher/dist/index.js", "https://cdn.jsdelivr.net/npm/@inlang/plugin-json@latest/dist/index.js" ], "plugin.inlang.json": { @@ -22,6 +22,11 @@ "preferredTfuncName": "translate", "recognizedTfuncNames": [ "translate" + ], + "recognizedJSXAttributes": [ + "tx", + "subTx", + "contentTx" ] } } \ No newline at end of file diff --git a/src/components/AvatarHeader.tsx b/src/components/AvatarHeader.tsx index bdc705f2..a3d747b9 100644 --- a/src/components/AvatarHeader.tsx +++ b/src/components/AvatarHeader.tsx @@ -58,7 +58,7 @@ export const AvatarHeader = observer(function (props: AvatarHeaderProps) { )} {props.heading && } - {props.text && } + {props.text && } {props.children} ) diff --git a/src/components/BottomModal.tsx b/src/components/BottomModal.tsx index 8871e37e..7ed66993 100644 --- a/src/components/BottomModal.tsx +++ b/src/components/BottomModal.tsx @@ -110,7 +110,7 @@ export function BottomModal(props: ModalProps) { isVisible = true, onBackdropPress, onBackButtonPress, - backdropOpacity = 0.45, + backdropOpacity = 0.25, content, contentTx, contentTxOptions, @@ -216,19 +216,17 @@ export function BottomModal(props: ModalProps) { } const $outerContainerBase: ViewStyle = { - flex: 1, - justifyContent: 'flex-end', - alignItems: 'center', - width: '100%', - margin: 0, + flex: 1, + justifyContent: 'flex-end', + alignItems: 'center', + width: '100%', + margin: 0 } const $innerContainerBase: ViewStyle = { - width: '100%', - alignItems: 'center', - borderTopLeftRadius: spacing.small, - borderTopRightRadius: spacing.small, - padding: spacing.small -} - - + width: '100%', + alignItems: 'center', + borderTopLeftRadius: spacing.small, + borderTopRightRadius: spacing.small, + padding: spacing.small +} \ No newline at end of file diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx index b67e8f0d..4c62dd5a 100644 --- a/src/components/Loading.tsx +++ b/src/components/Loading.tsx @@ -1,20 +1,25 @@ import * as React from 'react' -import { StyleSheet, View, ActivityIndicator, ViewProps, TextStyle } from 'react-native' +import { StyleSheet, View, ActivityIndicator, ViewProps, TextStyle, ColorValue, ViewStyle } from 'react-native' import { useThemeColor } from '../theme' import { Text } from './Text' +import { spacing } from '../theme' -export function Loading(props: ViewProps & {statusMessage?: string, textStyle?: TextStyle}) { - return ( - - - {props.statusMessage && ()} - - ) -} \ No newline at end of file +export function Loading(props: ViewProps & { statusMessage?: string, textStyle?: TextStyle, shiftedUp?: boolean }) { + return ( + + + {props.statusMessage && ()} + + ) +} + +const $loading = (bg: ColorValue, shiftedUp = false) => ({ + flex: 1, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: bg, + opacity: 0.5, + zIndex: 9999, + // for cards that go up in the header, the loading should cover them + marginTop: shiftedUp ? -(spacing.extraLarge * 2 + spacing.small) : 0, +} satisfies ViewStyle) \ No newline at end of file diff --git a/src/components/MemoInputCard.tsx b/src/components/MemoInputCard.tsx new file mode 100644 index 00000000..4a8b565b --- /dev/null +++ b/src/components/MemoInputCard.tsx @@ -0,0 +1,77 @@ +import React, {forwardRef} from 'react' +import {View, ViewStyle, TextInput, TextStyle} from 'react-native' +import {spacing} from '../theme' +import {Button} from './Button' +import {Card} from './Card' +import {translate} from '../i18n' + +interface MemoInputProps { + memo: string + setMemo: (memo: string) => void + disabled?: boolean + onMemoDone: () => void + onMemoEndEditing?: () => void + maxLength?: number +} + +export const MemoInputCard = forwardRef((props, memoInputRef) => { + const { + memo, + setMemo, + disabled = true, + onMemoDone, + onMemoEndEditing = () => {}, + maxLength = 200, + } = props + return ( + + setMemo(memo)} + onEndEditing={onMemoEndEditing} + value={`${memo}`} + style={$memoInput} + maxLength={maxLength} + keyboardType="default" + selectTextOnFocus={true} + placeholder={translate('sendScreen.memo')} + editable={!disabled} + /> +