mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
REF: SendDetails actions
This commit is contained in:
parent
bca35c0598
commit
11cf6ad6b8
@ -7,7 +7,7 @@ import { Action } from './types';
|
||||
|
||||
interface HeaderMenuButtonProps {
|
||||
onPressMenuItem: (id: string) => void;
|
||||
actions: Action[];
|
||||
actions: Action[] | Action[][];
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ const TotalWalletsBalance: React.FC = () => {
|
||||
<ToolTipMenu actions={toolTipActions} onPressMenuItem={onPressMenuItem}>
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.label}>{loc.wallets.total_balance}</Text>
|
||||
<TouchableOpacity onPress={() => onPressMenuItem(CommonToolTipActions.ViewInBitcoin.id)}>
|
||||
<TouchableOpacity onPress={() => onPressMenuItem(CommonToolTipActions.ViewInBitcoin.id.toString())}>
|
||||
<Text style={[styles.balance, styleHooks.balance]}>
|
||||
{formattedBalance}{' '}
|
||||
{totalBalancePreferredUnit !== BitcoinUnit.LOCAL_CURRENCY && (
|
||||
|
@ -19,7 +19,7 @@ export interface Action {
|
||||
}
|
||||
|
||||
export interface ToolTipMenuProps {
|
||||
actions: Action[];
|
||||
actions: Action[] | Action[][];
|
||||
children: React.ReactNode;
|
||||
enableAndroidRipple?: boolean;
|
||||
dismissMenu?: () => void;
|
||||
|
@ -51,7 +51,6 @@ import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackPara
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
import { ContactList } from '../../class/contact-list';
|
||||
import { useStorage } from '../../hooks/context/useStorage';
|
||||
import { Action } from '../../components/types';
|
||||
import SelectFeeModal from '../../components/SelectFeeModal';
|
||||
import { useKeyboard } from '../../hooks/useKeyboard';
|
||||
import { DismissKeyboardInputAccessory, DismissKeyboardInputAccessoryViewID } from '../../components/DismissKeyboardInputAccessory';
|
||||
@ -980,66 +979,57 @@ const SendDetails = () => {
|
||||
};
|
||||
|
||||
const headerRightActions = () => {
|
||||
const actions: Action[] & Action[][] = [];
|
||||
if (isEditable) {
|
||||
if (wallet?.allowBIP47() && wallet?.isBIP47Enabled()) {
|
||||
actions.push([
|
||||
{ id: SendDetails.actionKeys.InsertContact, text: loc.send.details_insert_contact, icon: SendDetails.actionIcons.InsertContact },
|
||||
]);
|
||||
}
|
||||
const transactionActions = [
|
||||
{
|
||||
...CommonToolTipActions.SendMax,
|
||||
hidden: !(isEditable && Number(wallet?.getBalance()) > 0),
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.AllowRBF,
|
||||
hidden: !(wallet?.type === HDSegwitBech32Wallet.type && isTransactionReplaceable !== undefined),
|
||||
menuState: isTransactionReplaceable,
|
||||
},
|
||||
];
|
||||
|
||||
if (Number(wallet?.getBalance()) > 0) {
|
||||
const isSendMaxUsed = addresses.some(element => element.amount === BitcoinUnit.MAX);
|
||||
const importActions = [
|
||||
{
|
||||
...CommonToolTipActions.ImportTransaction,
|
||||
hidden: !(wallet?.type === WatchOnlyWallet.type && wallet.isHd()),
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.ImportTransactionQR,
|
||||
hidden: !(wallet?.type === WatchOnlyWallet.type && wallet.isHd()),
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.ImportTransactionMultsig,
|
||||
hidden: !(wallet?.type === MultisigHDWallet.type && wallet.howManySignaturesCanWeMake() > 0),
|
||||
},
|
||||
{
|
||||
...CommonToolTipActions.CoSignTransaction,
|
||||
hidden: !(wallet?.type === MultisigHDWallet.type && wallet.howManySignaturesCanWeMake() > 0),
|
||||
},
|
||||
];
|
||||
|
||||
actions.push([{ id: SendDetails.actionKeys.SendMax, text: loc.send.details_adv_full, disabled: balance === 0 || isSendMaxUsed }]);
|
||||
}
|
||||
if (wallet?.type === HDSegwitBech32Wallet.type && isTransactionReplaceable !== undefined) {
|
||||
actions.push([{ id: SendDetails.actionKeys.AllowRBF, text: loc.send.details_adv_fee_bump, menuState: !!isTransactionReplaceable }]);
|
||||
}
|
||||
const transactionActions = [];
|
||||
if (wallet?.type === WatchOnlyWallet.type && wallet.isHd()) {
|
||||
transactionActions.push(
|
||||
{
|
||||
id: SendDetails.actionKeys.ImportTransaction,
|
||||
text: loc.send.details_adv_import,
|
||||
icon: SendDetails.actionIcons.ImportTransaction,
|
||||
},
|
||||
{
|
||||
id: SendDetails.actionKeys.ImportTransactionQR,
|
||||
text: loc.send.details_adv_import_qr,
|
||||
icon: SendDetails.actionIcons.ImportTransactionQR,
|
||||
},
|
||||
);
|
||||
}
|
||||
if (wallet?.type === MultisigHDWallet.type) {
|
||||
transactionActions.push({
|
||||
id: SendDetails.actionKeys.ImportTransactionMultsig,
|
||||
text: loc.send.details_adv_import,
|
||||
icon: SendDetails.actionIcons.ImportTransactionMultsig,
|
||||
});
|
||||
}
|
||||
if (wallet?.type === MultisigHDWallet.type && wallet.howManySignaturesCanWeMake() > 0) {
|
||||
transactionActions.push({
|
||||
id: SendDetails.actionKeys.CoSignTransaction,
|
||||
text: loc.multisig.co_sign_transaction,
|
||||
icon: SendDetails.actionIcons.SignPSBT,
|
||||
});
|
||||
}
|
||||
if ((wallet as MultisigHDWallet)?.allowCosignPsbt()) {
|
||||
transactionActions.push({ id: SendDetails.actionKeys.SignPSBT, text: loc.send.psbt_sign, icon: SendDetails.actionIcons.SignPSBT });
|
||||
}
|
||||
actions.push(transactionActions);
|
||||
const recipientActions = [
|
||||
CommonToolTipActions.AddRecipient,
|
||||
CommonToolTipActions.RemoveRecipient,
|
||||
{
|
||||
...CommonToolTipActions.RemoveAllRecipients,
|
||||
hidden: addresses.length <= 1,
|
||||
},
|
||||
];
|
||||
|
||||
const recipientActions: Action[] = [CommonToolTipActions.AddRecipient, CommonToolTipActions.RemoveRecipient];
|
||||
if (addresses.length > 1) {
|
||||
recipientActions.push(CommonToolTipActions.RemoveAllRecipients);
|
||||
}
|
||||
actions.push(recipientActions);
|
||||
}
|
||||
const walletActions = [
|
||||
{
|
||||
...CommonToolTipActions.InsertContact,
|
||||
hidden: !(isEditable && wallet?.allowBIP47() && wallet?.isBIP47Enabled()),
|
||||
},
|
||||
CommonToolTipActions.CoinControl,
|
||||
];
|
||||
|
||||
actions.push({ id: SendDetails.actionKeys.CoinControl, text: loc.cc.header, icon: SendDetails.actionIcons.CoinControl });
|
||||
const availableActions = [walletActions, transactionActions, importActions, recipientActions];
|
||||
|
||||
return actions;
|
||||
return availableActions;
|
||||
};
|
||||
|
||||
const setHeaderRightOptions = () => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Platform } from 'react-native';
|
||||
import loc from '../loc';
|
||||
import { Action } from '../components/types';
|
||||
|
||||
const keys = {
|
||||
CopyTXID: 'copyTX_ID',
|
||||
@ -27,69 +28,51 @@ const keys = {
|
||||
CopyFromClipboard: 'copy_from_clipboard',
|
||||
ChoosePhoto: 'choose_photo',
|
||||
ImportFile: 'import_file',
|
||||
InsertContact: 'InsertContact',
|
||||
SignPSBT: 'SignPSBT',
|
||||
SendMax: 'SendMax',
|
||||
AllowRBF: 'AllowRBF',
|
||||
ImportTransaction: 'ImportTransaction',
|
||||
ImportTransactionMultsig: 'ImportTransactionMultsig',
|
||||
ImportTransactionQR: 'ImportTransactionQR',
|
||||
CoinControl: 'CoinControl',
|
||||
CoSignTransaction: 'CoSignTransaction',
|
||||
};
|
||||
|
||||
const icons = {
|
||||
Eye: {
|
||||
iconValue: 'eye',
|
||||
},
|
||||
EyeSlash: {
|
||||
iconValue: 'eye.slash',
|
||||
},
|
||||
Link: {
|
||||
iconValue: 'link',
|
||||
},
|
||||
Note: {
|
||||
iconValue: 'note.text',
|
||||
},
|
||||
ManageWallets: {
|
||||
iconValue: 'slider.horizontal.3',
|
||||
},
|
||||
ImportWallet: {
|
||||
iconValue: 'square.and.arrow.down.on.square',
|
||||
},
|
||||
ViewInBitcoin: {
|
||||
iconValue: 'bitcoinsign.circle',
|
||||
},
|
||||
ViewInFiat: {
|
||||
iconValue: 'coloncurrencysign.circle',
|
||||
},
|
||||
Entropy: {
|
||||
iconValue: 'dice',
|
||||
},
|
||||
SearchAccount: {
|
||||
iconValue: 'magnifyingglass',
|
||||
},
|
||||
Passphrase: {
|
||||
iconValue: 'rectangle.and.pencil.and.ellipsis',
|
||||
},
|
||||
MoreInfo: {
|
||||
iconValue: 'info.circle',
|
||||
},
|
||||
SaveChanges: {
|
||||
iconValue: 'checkmark',
|
||||
},
|
||||
PaymentsCode: {
|
||||
iconValue: 'qrcode',
|
||||
},
|
||||
const icons: { [key: string]: { iconValue: string } } = {
|
||||
Eye: { iconValue: 'eye' },
|
||||
EyeSlash: { iconValue: 'eye.slash' },
|
||||
Link: { iconValue: 'link' },
|
||||
Note: { iconValue: 'note.text' },
|
||||
ManageWallets: { iconValue: 'slider.horizontal.3' },
|
||||
ImportWallet: { iconValue: 'square.and.arrow.down.on.square' },
|
||||
ViewInBitcoin: { iconValue: 'bitcoinsign.circle' },
|
||||
ViewInFiat: { iconValue: 'coloncurrencysign.circle' },
|
||||
Entropy: { iconValue: 'dice' },
|
||||
SearchAccount: { iconValue: 'magnifyingglass' },
|
||||
Passphrase: { iconValue: 'rectangle.and.pencil.and.ellipsis' },
|
||||
MoreInfo: { iconValue: 'info.circle' },
|
||||
SaveChanges: { iconValue: 'checkmark' },
|
||||
InsertContact: { iconValue: 'at.badge.plus' },
|
||||
SignPSBT: { iconValue: 'signature' },
|
||||
SendMax: { iconValue: 'dial.high' },
|
||||
AllowRBF: { iconValue: 'arrowshape.up.circle' },
|
||||
ImportTransaction: { iconValue: 'square.and.arrow.down' },
|
||||
ImportTransactionMultsig: { iconValue: 'square.and.arrow.down.on.square' },
|
||||
ImportTransactionQR: { iconValue: 'qrcode.viewfinder' },
|
||||
CoinControl: { iconValue: 'switch.2' },
|
||||
CoSignTransaction: { iconValue: 'signature' },
|
||||
PaymentsCode: { iconValue: 'qrcode' },
|
||||
RemoveAllRecipients: { iconValue: 'person.2.slash' },
|
||||
AddRecipient: { iconValue: 'person.badge.plus' },
|
||||
RemoveRecipient: { iconValue: 'person.badge.minus' },
|
||||
ScanQR: {
|
||||
iconValue: Platform.OS === 'ios' ? 'qrcode' : 'ic_menu_camera',
|
||||
},
|
||||
ImportFile: {
|
||||
iconValue: 'doc',
|
||||
},
|
||||
ChoosePhoto: {
|
||||
iconValue: Platform.OS === 'ios' ? 'photo' : 'ic_menu_gallery',
|
||||
},
|
||||
Clipboard: {
|
||||
iconValue: Platform.OS === 'ios' ? 'doc.on.doc' : 'ic_menu_file',
|
||||
},
|
||||
ScanQR: { iconValue: Platform.OS === 'ios' ? 'qrcode' : 'ic_menu_camera' },
|
||||
ImportFile: { iconValue: 'doc' },
|
||||
ChoosePhoto: { iconValue: Platform.OS === 'ios' ? 'photo' : 'ic_menu_gallery' },
|
||||
Clipboard: { iconValue: Platform.OS === 'ios' ? 'doc.on.doc' : 'ic_menu_file' },
|
||||
};
|
||||
|
||||
export const CommonToolTipActions = {
|
||||
export const CommonToolTipActions: { [key: string]: Action } = {
|
||||
CopyTXID: {
|
||||
id: keys.CopyTXID,
|
||||
text: loc.transactions.details_copy_txid,
|
||||
@ -221,4 +204,59 @@ export const CommonToolTipActions = {
|
||||
text: loc.wallets.import_file,
|
||||
icon: icons.ImportFile,
|
||||
},
|
||||
InsertContact: {
|
||||
id: keys.InsertContact,
|
||||
text: loc.send.details_insert_contact,
|
||||
icon: icons.InsertContact,
|
||||
hidden: true,
|
||||
},
|
||||
SignPSBT: {
|
||||
id: keys.SignPSBT,
|
||||
text: loc.send.psbt_sign,
|
||||
icon: icons.SignPSBT,
|
||||
hidden: true,
|
||||
},
|
||||
SendMax: {
|
||||
id: keys.SendMax,
|
||||
text: loc.send.details_adv_full,
|
||||
icon: icons.SendMax,
|
||||
hidden: true,
|
||||
},
|
||||
AllowRBF: {
|
||||
id: keys.AllowRBF,
|
||||
text: loc.send.details_adv_fee_bump,
|
||||
icon: icons.AllowRBF,
|
||||
hidden: true,
|
||||
menuState: false,
|
||||
},
|
||||
ImportTransaction: {
|
||||
id: keys.ImportTransaction,
|
||||
text: loc.send.details_adv_import,
|
||||
icon: icons.ImportTransaction,
|
||||
hidden: true,
|
||||
},
|
||||
ImportTransactionQR: {
|
||||
id: keys.ImportTransactionQR,
|
||||
text: loc.send.details_adv_import_qr,
|
||||
icon: icons.ImportTransactionQR,
|
||||
hidden: true,
|
||||
},
|
||||
ImportTransactionMultsig: {
|
||||
id: keys.ImportTransactionMultsig,
|
||||
text: loc.send.details_adv_import,
|
||||
icon: icons.ImportTransactionMultsig,
|
||||
hidden: true,
|
||||
},
|
||||
CoSignTransaction: {
|
||||
id: keys.CoSignTransaction,
|
||||
text: loc.multisig.co_sign_transaction,
|
||||
icon: icons.CoSignTransaction,
|
||||
hidden: true,
|
||||
},
|
||||
CoinControl: {
|
||||
id: keys.CoinControl,
|
||||
text: loc.cc.header,
|
||||
icon: icons.CoinControl,
|
||||
hidden: false,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user