From 3b6e1e44616ce5d1894d8be0f0c03279774d2ddc Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Thu, 3 Jul 2025 13:46:02 +0200 Subject: [PATCH] Fixes: Pay button not shown when donating for custom address, amount input unintentionally selected while typing. --- package.json | 2 +- src/components/AmountInput.tsx | 92 ++++++++++++++++++++++++++++++++ src/components/index.ts | 1 + src/screens/Contacts/OwnName.tsx | 20 +++---- src/screens/ReceiveScreen.tsx | 7 +-- src/screens/SendScreen.tsx | 42 +++++++-------- src/screens/TopupScreen.tsx | 84 ++++++++++++----------------- src/screens/TransferScreen.tsx | 30 ++++------- src/services/wallet/topupTask.ts | 3 +- 9 files changed, 172 insertions(+), 109 deletions(-) create mode 100644 src/components/AmountInput.tsx diff --git a/package.json b/package.json index e27a633f..9a9e61ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minibits_wallet", - "version": "0.2.2-beta.25", + "version": "0.2.2-beta.26", "private": true, "scripts": { "android:clean": "cd android && ./gradlew clean", diff --git a/src/components/AmountInput.tsx b/src/components/AmountInput.tsx new file mode 100644 index 00000000..c4addeb6 --- /dev/null +++ b/src/components/AmountInput.tsx @@ -0,0 +1,92 @@ +import React, { forwardRef, useState } from 'react' +import { TextInput, TextStyle } from 'react-native' +import { spacing, useThemeColor, typography } from '../theme' +import { verticalScale } from '@gocodingnow/rn-size-matters' +import { MintUnit, getCurrency } from '../services/wallet/currency' +import numbro from 'numbro' + +interface AmountInputProps { + value: string + onChangeText: (text: string) => void + unit?: MintUnit + onEndEditing?: () => void + editable?: boolean + selectTextOnFocus?: boolean + onFocus?: () => void + onBlur?: () => void + style?: TextStyle +} + +export const AmountInput = forwardRef( + ( + { + value, + onChangeText, + unit = 'sat', + onEndEditing, + editable = true, + selectTextOnFocus, + onFocus, + onBlur, + style, + ...rest + }, + ref + ) => { + const [hasAmountFocusedOnce, setHasAmountFocusedOnce] = useState(false) + const amountInputColor = useThemeColor('amountInput') + + const handleFocus = () => { + setHasAmountFocusedOnce(true) + onFocus?.() + } + + const handleBlur = () => { + setHasAmountFocusedOnce(false) + onBlur?.() + } + + const handleEndEditing = () => { + if (onEndEditing) { + onEndEditing() + } + // Default formatting behavior + const formattedValue = numbro(value).format({ + thousandSeparated: true, + mantissa: getCurrency(unit).mantissa + }) + onChangeText(formattedValue) + + } + + const defaultStyle: TextStyle = { + borderRadius: spacing.small, + margin: 0, + padding: 0, + fontSize: verticalScale(48), + fontFamily: typography.primary?.medium, + textAlign: 'center', + color: amountInputColor, + } + + return ( + + ) + } +) + +AmountInput.displayName = 'AmountInput' \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index ac69e4fd..06c0da7a 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,3 +1,4 @@ +export * from "./AmountInput" export * from "./AutoImage" export * from "./Button" export * from "./Card" diff --git a/src/screens/Contacts/OwnName.tsx b/src/screens/Contacts/OwnName.tsx index 405fbdb5..a2ab0e5d 100644 --- a/src/screens/Contacts/OwnName.tsx +++ b/src/screens/Contacts/OwnName.tsx @@ -22,7 +22,7 @@ import { LNURLPayParams, LnurlClient } from '../../services/lnurlService' import { useNavigation } from '@react-navigation/native' import { TransferOption } from '../TransferScreen' -const DEFAULT_DONATION_AMOUNT = 500 +const DEFAULT_DONATION_AMOUNT = 10 const DONATION_LNURL_ADDRESS = 'minibits@minibits.cash' export const OwnName = observer(function (props: {pubkey: string}) { @@ -273,9 +273,9 @@ export const OwnName = observer(function (props: {pubkey: string}) { const currentNameColor = colors.palette.primary200 const inputBg = useThemeColor('background') const inputText = useThemeColor('text') - const small = 1000 - const medium = 1500 - const large = 2000 + const small = DEFAULT_DONATION_AMOUNT * 2 + const medium = DEFAULT_DONATION_AMOUNT * 3 + const large = DEFAULT_DONATION_AMOUNT * 4 const invoiceBg = useThemeColor('background') const invoiceTextColor = useThemeColor('textDim') const domainText = useThemeColor('textDim') @@ -366,28 +366,28 @@ export const OwnName = observer(function (props: {pubkey: string}) { preset="secondary" style={{marginRight: spacing.small}} text={`${small.toLocaleString()}`} - onPress={() => setDonationAmount(1000)} + onPress={() => setDonationAmount(DEFAULT_DONATION_AMOUNT * 2)} />