mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-15 11:59:21 +01:00
Update TransactionListItem.tsx
This commit is contained in:
parent
1b328cd130
commit
d610063809
1 changed files with 45 additions and 20 deletions
|
@ -246,7 +246,19 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||||
setSubtitleNumberOfLines(0);
|
setSubtitleNumberOfLines(0);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
|
const handleOnDetailsPress = useCallback(() => {
|
||||||
|
if (walletID && item && item.hash) {
|
||||||
|
navigate('TransactionDetails', { tx: item, hash: item.hash, walletID });
|
||||||
|
} else {
|
||||||
|
const lightningWallet = wallets.find(wallet => wallet?.getID() === item.walletID);
|
||||||
|
if (lightningWallet) {
|
||||||
|
navigate('LNDViewInvoice', {
|
||||||
|
invoice: item,
|
||||||
|
walletID: lightningWallet.getID(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [item, navigate, walletID, wallets]);
|
||||||
|
|
||||||
const handleOnCopyAmountTap = useCallback(() => Clipboard.setString(rowTitle.replace(/[\s\\-]/g, '')), [rowTitle]);
|
const handleOnCopyAmountTap = useCallback(() => Clipboard.setString(rowTitle.replace(/[\s\\-]/g, '')), [rowTitle]);
|
||||||
const handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]);
|
const handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]);
|
||||||
|
@ -277,6 +289,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||||
handleCopyOpenInBlockExplorerPress();
|
handleCopyOpenInBlockExplorerPress();
|
||||||
} else if (id === CommonToolTipActions.CopyTXID.id) {
|
} else if (id === CommonToolTipActions.CopyTXID.id) {
|
||||||
handleOnCopyTransactionID();
|
handleOnCopyTransactionID();
|
||||||
|
} else if (id === CommonToolTipActions.Details.id) {
|
||||||
|
handleOnDetailsPress();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
@ -284,31 +298,40 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||||
handleOnCopyAmountTap,
|
handleOnCopyAmountTap,
|
||||||
handleOnCopyNote,
|
handleOnCopyNote,
|
||||||
handleOnCopyTransactionID,
|
handleOnCopyTransactionID,
|
||||||
|
handleOnDetailsPress,
|
||||||
handleOnExpandNote,
|
handleOnExpandNote,
|
||||||
handleOnViewOnBlockExplorer,
|
handleOnViewOnBlockExplorer,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
const toolTipActions = useMemo((): Action[] => {
|
const toolTipActions = useMemo((): Action[] => {
|
||||||
const actions: (Action | Action[])[] = [];
|
const actions: (Action | Action[])[] = [
|
||||||
|
{
|
||||||
if (rowTitle !== loc.lnd.expired) {
|
...CommonToolTipActions.CopyAmount,
|
||||||
actions.push(CommonToolTipActions.CopyAmount);
|
hidden: rowTitle === loc.lnd.expired,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (subtitle) {
|
...CommonToolTipActions.CopyNote,
|
||||||
actions.push(CommonToolTipActions.CopyNote);
|
hidden: !subtitle,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (item.hash) {
|
...CommonToolTipActions.CopyTXID,
|
||||||
actions.push(CommonToolTipActions.CopyTXID, CommonToolTipActions.CopyBlockExplorerLink, [CommonToolTipActions.OpenInBlockExplorer]);
|
hidden: !item.hash,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (subtitle && subtitleNumberOfLines === 1) {
|
...CommonToolTipActions.CopyBlockExplorerLink,
|
||||||
actions.push([CommonToolTipActions.ExpandNote]);
|
hidden: !item.hash,
|
||||||
}
|
},
|
||||||
|
[{ ...CommonToolTipActions.OpenInBlockExplorer, hidden: !item.hash }, CommonToolTipActions.Details],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
...CommonToolTipActions.ExpandNote,
|
||||||
|
hidden: subtitleNumberOfLines !== 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
return actions as Action[];
|
return actions as Action[];
|
||||||
}, [item.hash, subtitle, rowTitle, subtitleNumberOfLines]);
|
}, [rowTitle, subtitle, item.hash, subtitleNumberOfLines]);
|
||||||
|
|
||||||
const accessibilityState = useMemo(() => {
|
const accessibilityState = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -316,6 +339,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||||
};
|
};
|
||||||
}, [subtitleNumberOfLines]);
|
}, [subtitleNumberOfLines]);
|
||||||
|
|
||||||
|
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolTipMenu
|
<ToolTipMenu
|
||||||
isButton
|
isButton
|
||||||
|
@ -341,4 +366,4 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||||
</ToolTipMenu>
|
</ToolTipMenu>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
Loading…
Add table
Reference in a new issue