Merge branch 'master' into bip47togglr

This commit is contained in:
Marcos Rodriguez Vélez 2024-12-31 09:35:40 -04:00 committed by GitHub
commit 86662cad0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 25 deletions

View file

@ -3,7 +3,7 @@ import dayjs from 'dayjs';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Image, LayoutAnimation, Pressable, StyleSheet, TextInput, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
import { Image, LayoutAnimation, Pressable, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
import { Badge, Icon, Text } from '@rneui/themed';
import {
@ -254,7 +254,7 @@ class AmountInput extends Component {
});
return (
<TouchableWithoutFeedback
<Pressable
accessibilityRole="button"
accessibilityLabel={loc._.enter_amount}
disabled={this.props.pointerEvents === 'none'}
@ -340,7 +340,7 @@ class AmountInput extends Component {
</View>
)}
</>
</TouchableWithoutFeedback>
</Pressable>
);
}
}

View file

@ -64,6 +64,7 @@ interface IPaymentDestinations {
amountSats?: number | string;
amount?: string | number | 'MAX';
key: string; // random id to look up this record
unit: BitcoinUnit;
}
interface IFee {
@ -100,8 +101,9 @@ const SendDetails = () => {
const [wallet, setWallet] = useState<TWallet | null>(null);
const feeModalRef = useRef<BottomModalHandle>(null);
const { isVisible } = useKeyboard();
const [addresses, setAddresses] = useState<IPaymentDestinations[]>([]);
const [units, setUnits] = useState<BitcoinUnit[]>([]);
const [addresses, setAddresses] = useState<IPaymentDestinations[]>([
{ address: '', key: String(Math.random()), unit: amountUnit } as IPaymentDestinations,
]);
const [networkTransactionFees, setNetworkTransactionFees] = useState(new NetworkTransactionFee(3, 2, 1));
const [networkTransactionFeesIsLoading, setNetworkTransactionFeesIsLoading] = useState(false);
const [customFee, setCustomFee] = useState<string | null>(null);
@ -144,9 +146,9 @@ const SendDetails = () => {
try {
const { address, amount, memo, payjoinUrl: pjUrl } = DeeplinkSchemaMatch.decodeBitcoinUri(routeParams.uri);
setUnits(u => {
u[scrollIndex.current] = BitcoinUnit.BTC; // also resetting current unit to BTC
return [...u];
setAddresses(addrs => {
addrs[scrollIndex.current].unit = BitcoinUnit.BTC;
return [...addrs];
});
setAddresses(addrs => {
@ -178,15 +180,12 @@ const SendDetails = () => {
if (currentAddress && currentAddress.address && routeParams.address) {
currentAddress.address = routeParams.address;
value[scrollIndex.current] = currentAddress;
value[scrollIndex.current].unit = unit;
return [...value];
} else {
return [...value, { address: routeParams.address, key: String(Math.random()), amount, amountSats }];
}
});
setUnits(u => {
u[scrollIndex.current] = unit;
return [...u];
});
} else if (routeParams.addRecipientParams) {
const index = addresses.length === 0 ? 0 : scrollIndex.current;
const { address, amount } = routeParams.addRecipientParams;
@ -451,9 +450,9 @@ const SendDetails = () => {
addrs[scrollIndex.current].amountSats = new BigNumber(options?.amount ?? 0).multipliedBy(100000000).toNumber();
return [...addrs];
});
setUnits(u => {
u[scrollIndex.current] = BitcoinUnit.BTC; // also resetting current unit to BTC
return [...u];
setAddresses(addrs => {
addrs[scrollIndex.current].unit = BitcoinUnit.BTC;
return [...addrs];
});
setParams({ transactionMemo: options.label || '', amountUnit: BitcoinUnit.BTC, payjoinUrl: options.pj || '' }); // there used to be `options.message` here as well. bug?
// RN Bug: contentOffset gets reset to 0 when state changes. Remove code once this bug is resolved.
@ -971,7 +970,10 @@ const SendDetails = () => {
const recipientActions: Action[] = [
CommonToolTipActions.AddRecipient,
CommonToolTipActions.RemoveRecipient,
{
...CommonToolTipActions.RemoveRecipient,
hidden: addresses.length <= 1,
},
{
...CommonToolTipActions.RemoveAllRecipients,
hidden: !(addresses.length > 1),
@ -1073,9 +1075,9 @@ const SendDetails = () => {
addrs[scrollIndex.current].amountSats = BitcoinUnit.MAX;
return [...addrs];
});
setUnits(u => {
u[scrollIndex.current] = BitcoinUnit.BTC;
return [...u];
setAddresses(addrs => {
addrs[scrollIndex.current].unit = BitcoinUnit.BTC;
return [...addrs];
});
}
});
@ -1206,15 +1208,15 @@ const SendDetails = () => {
addrs[index] = addr;
return [...addrs];
});
setUnits(u => {
u[index] = unit;
return [...u];
setAddresses(addrs => {
addrs[index].unit = unit;
return [...addrs];
});
}}
onChangeText={(text: string) => {
setAddresses(addrs => {
item.amount = text;
switch (units[index] || amountUnit) {
switch (item.unit || amountUnit) {
case BitcoinUnit.BTC:
item.amountSats = btcToSatoshi(item.amount);
break;
@ -1230,7 +1232,7 @@ const SendDetails = () => {
return [...addrs];
});
}}
unit={units[index] || amountUnit}
unit={item.unit || amountUnit}
editable={isEditable}
disabled={!isEditable}
inputAccessoryViewID={InputAccessoryAllFundsAccessoryViewID}
@ -1341,7 +1343,7 @@ const SendDetails = () => {
feeRate={feeRate}
setCustomFee={setCustomFee}
setFeePrecalc={setFeePrecalc}
feeUnit={units[scrollIndex.current]}
feeUnit={addresses[scrollIndex.current]?.unit ?? BitcoinUnit.BTC}
/>
</View>
<DismissKeyboardInputAccessory />