mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-13 19:16:52 +01:00
Merge pull request #7566 from BlueWallet/detailsitem
ADD: TX Details action action
This commit is contained in:
commit
e5ab5f6565
2 changed files with 52 additions and 20 deletions
|
@ -246,7 +246,19 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
|||
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 handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]);
|
||||
|
@ -277,6 +289,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
|||
handleCopyOpenInBlockExplorerPress();
|
||||
} else if (id === CommonToolTipActions.CopyTXID.id) {
|
||||
handleOnCopyTransactionID();
|
||||
} else if (id === CommonToolTipActions.Details.id) {
|
||||
handleOnDetailsPress();
|
||||
}
|
||||
},
|
||||
[
|
||||
|
@ -284,31 +298,40 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
|||
handleOnCopyAmountTap,
|
||||
handleOnCopyNote,
|
||||
handleOnCopyTransactionID,
|
||||
handleOnDetailsPress,
|
||||
handleOnExpandNote,
|
||||
handleOnViewOnBlockExplorer,
|
||||
],
|
||||
);
|
||||
const toolTipActions = useMemo((): Action[] => {
|
||||
const actions: (Action | Action[])[] = [];
|
||||
|
||||
if (rowTitle !== loc.lnd.expired) {
|
||||
actions.push(CommonToolTipActions.CopyAmount);
|
||||
}
|
||||
|
||||
if (subtitle) {
|
||||
actions.push(CommonToolTipActions.CopyNote);
|
||||
}
|
||||
|
||||
if (item.hash) {
|
||||
actions.push(CommonToolTipActions.CopyTXID, CommonToolTipActions.CopyBlockExplorerLink, [CommonToolTipActions.OpenInBlockExplorer]);
|
||||
}
|
||||
|
||||
if (subtitle && subtitleNumberOfLines === 1) {
|
||||
actions.push([CommonToolTipActions.ExpandNote]);
|
||||
}
|
||||
const actions: (Action | Action[])[] = [
|
||||
{
|
||||
...CommonToolTipActions.CopyAmount,
|
||||
hidden: rowTitle === loc.lnd.expired,
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.CopyNote,
|
||||
hidden: !subtitle,
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.CopyTXID,
|
||||
hidden: !item.hash,
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.CopyBlockExplorerLink,
|
||||
hidden: !item.hash,
|
||||
},
|
||||
[{ ...CommonToolTipActions.OpenInBlockExplorer, hidden: !item.hash }, CommonToolTipActions.Details],
|
||||
[
|
||||
{
|
||||
...CommonToolTipActions.ExpandNote,
|
||||
hidden: subtitleNumberOfLines !== 1,
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
return actions as Action[];
|
||||
}, [item.hash, subtitle, rowTitle, subtitleNumberOfLines]);
|
||||
}, [rowTitle, subtitle, item.hash, subtitleNumberOfLines]);
|
||||
|
||||
const accessibilityState = useMemo(() => {
|
||||
return {
|
||||
|
@ -316,6 +339,8 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
|||
};
|
||||
}, [subtitleNumberOfLines]);
|
||||
|
||||
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
|
||||
|
||||
return (
|
||||
<ToolTipMenu
|
||||
isButton
|
||||
|
@ -341,4 +366,4 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
|||
</ToolTipMenu>
|
||||
);
|
||||
},
|
||||
);
|
||||
);
|
|
@ -51,6 +51,7 @@ const keys = {
|
|||
SortLabel: 'sortLabel',
|
||||
SortStatus: 'sortStatus',
|
||||
Delete: 'delete',
|
||||
Details: 'details',
|
||||
} as const;
|
||||
|
||||
const icons = {
|
||||
|
@ -94,6 +95,7 @@ const icons = {
|
|||
SortDESC: { iconValue: Platform.OS === 'ios' ? 'arrow.up.to.line' : 'ic_menu_sort_by_size' },
|
||||
SaveFile: { iconValue: Platform.OS === 'ios' ? 'square.and.arrow.down' : 'ic_menu_save' },
|
||||
Delete: { iconValue: Platform.OS === 'ios' ? 'trash' : 'ic_menu_delete' },
|
||||
Details: { iconValue: Platform.OS === 'ios' ? 'info.circle' : 'ic_menu_info_details' },
|
||||
} as const;
|
||||
|
||||
export type ToolTipAction = {
|
||||
|
@ -371,4 +373,9 @@ export const CommonToolTipActions: Record<string, ToolTipAction> = {
|
|||
icon: icons.Delete,
|
||||
destructive: true,
|
||||
},
|
||||
Details: {
|
||||
id: keys.Details,
|
||||
text: loc.send.create_details,
|
||||
icon: icons.Details,
|
||||
},
|
||||
} as const;
|
||||
|
|
Loading…
Add table
Reference in a new issue