mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
FIX: Deepscan
This commit is contained in:
parent
bd8b374ad0
commit
3bb42f6893
2 changed files with 62 additions and 56 deletions
|
@ -1,13 +1,13 @@
|
|||
import React from 'react';
|
||||
import React, { useCallback } from 'react';
|
||||
import { Image, Keyboard, StyleSheet, Text, TextInput, View } from 'react-native';
|
||||
|
||||
import { scanQrHelper } from '../helpers/scan-qr';
|
||||
import loc from '../loc';
|
||||
import { useTheme } from './themes';
|
||||
import ToolTipMenu from './TooltipMenu';
|
||||
import { showFilePickerAndReadFile, showImagePickerAndReadImage } from '../blue_modules/fs';
|
||||
import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import presentAlert from './Alert';
|
||||
import ToolTipMenu from './TooltipMenu';
|
||||
|
||||
interface AddressInputProps {
|
||||
isLoading?: boolean;
|
||||
|
@ -69,52 +69,55 @@ const AddressInput = ({
|
|||
Keyboard.dismiss();
|
||||
};
|
||||
|
||||
const onMenuItemPressed = (action: string) => {
|
||||
if (onBarScanned === undefined) throw new Error('onBarScanned is required');
|
||||
switch (action) {
|
||||
case actionKeys.ScanQR:
|
||||
scanButtonTapped();
|
||||
if (launchedBy) {
|
||||
scanQrHelper(launchedBy)
|
||||
.then(value => onBarScanned({ data: value }))
|
||||
const onMenuItemPressed = useCallback(
|
||||
(action: string) => {
|
||||
if (onBarScanned === undefined) throw new Error('onBarScanned is required');
|
||||
switch (action) {
|
||||
case actionKeys.ScanQR:
|
||||
scanButtonTapped();
|
||||
if (launchedBy) {
|
||||
scanQrHelper(launchedBy)
|
||||
.then(value => onBarScanned({ data: value }))
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case actionKeys.CopyFromClipboard:
|
||||
Clipboard.getString()
|
||||
.then(onChangeText)
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case actionKeys.CopyFromClipboard:
|
||||
Clipboard.getString()
|
||||
.then(onChangeText)
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
break;
|
||||
case actionKeys.ChoosePhoto:
|
||||
showImagePickerAndReadImage()
|
||||
.then(value => {
|
||||
if (value) {
|
||||
onChangeText(value);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
break;
|
||||
case actionKeys.ImportFile:
|
||||
showFilePickerAndReadFile()
|
||||
.then(value => {
|
||||
if (value.data) {
|
||||
onChangeText(value.data);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
break;
|
||||
}
|
||||
Keyboard.dismiss();
|
||||
};
|
||||
break;
|
||||
case actionKeys.ChoosePhoto:
|
||||
showImagePickerAndReadImage()
|
||||
.then(value => {
|
||||
if (value) {
|
||||
onChangeText(value);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
break;
|
||||
case actionKeys.ImportFile:
|
||||
showFilePickerAndReadFile()
|
||||
.then(value => {
|
||||
if (value.data) {
|
||||
onChangeText(value.data);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
presentAlert({ message: error.message });
|
||||
});
|
||||
break;
|
||||
}
|
||||
Keyboard.dismiss();
|
||||
},
|
||||
[launchedBy, onBarScanned, onChangeText, scanButtonTapped],
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={[styles.root, stylesHook.root]}>
|
||||
|
|
|
@ -63,16 +63,16 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
|
|||
verifyIfWalletAllowsOnchainAddress();
|
||||
}, [wallet, verifyIfWalletAllowsOnchainAddress]);
|
||||
|
||||
const handleCopyPress = () => {
|
||||
const handleCopyPress = useCallback(() => {
|
||||
const value = formatBalance(wallet.getBalance(), wallet.getPreferredBalanceUnit());
|
||||
if (value) {
|
||||
Clipboard.setString(value);
|
||||
}
|
||||
};
|
||||
}, [wallet]);
|
||||
|
||||
const handleBalanceVisibility = () => {
|
||||
const handleBalanceVisibility = useCallback(() => {
|
||||
onWalletBalanceVisibilityChange?.(!wallet.hideBalance);
|
||||
};
|
||||
}, [onWalletBalanceVisibilityChange, wallet.hideBalance]);
|
||||
|
||||
const updateWalletWithNewUnit = (w: TWallet, newPreferredUnit: BitcoinUnit) => {
|
||||
w.preferredBalanceUnit = newPreferredUnit;
|
||||
|
@ -106,13 +106,16 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
|
|||
}
|
||||
};
|
||||
|
||||
const onPressMenuItem = (id: string) => {
|
||||
if (id === 'walletBalanceVisibility') {
|
||||
handleBalanceVisibility();
|
||||
} else if (id === 'copyToClipboard') {
|
||||
handleCopyPress();
|
||||
}
|
||||
};
|
||||
const onPressMenuItem = useCallback(
|
||||
(id: string) => {
|
||||
if (id === 'walletBalanceVisibility') {
|
||||
handleBalanceVisibility();
|
||||
} else if (id === 'copyToClipboard') {
|
||||
handleCopyPress();
|
||||
}
|
||||
},
|
||||
[handleBalanceVisibility, handleCopyPress],
|
||||
);
|
||||
|
||||
const balance = useMemo(() => {
|
||||
const hideBalance = wallet.hideBalance;
|
||||
|
|
Loading…
Add table
Reference in a new issue