FIX: Wallet export reminder was not visible on macOS

This commit is contained in:
Marcos Rodriguez Velez 2024-03-20 19:16:12 -04:00
parent 9daf8921cd
commit 234321ef37
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
2 changed files with 37 additions and 12 deletions

View file

@ -18,6 +18,7 @@ import {
View,
I18nManager,
ImageBackground,
findNodeHandle,
} from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard';
import NetworkTransactionFees, { NetworkTransactionFee, NetworkTransactionFeeType } from './models/networkTransactionFees';
@ -26,6 +27,8 @@ import { BlueCurrentTheme, useTheme } from './components/themes';
import PlusIcon from './components/icons/PlusIcon';
import loc, { formatStringAddTwoWhiteSpaces } from './loc';
import SafeArea from './components/SafeArea';
import { isDesktop } from './blue_modules/environment';
import ActionSheet from './screen/ActionSheet';
const { height, width } = Dimensions.get('window');
const aspectRatio = height / width;
@ -193,16 +196,37 @@ export const BlueButtonLink = forwardRef((props, ref) => {
);
});
export const BlueAlertWalletExportReminder = ({ onSuccess = () => {}, onFailure }) => {
Alert.alert(
loc.wallets.details_title,
loc.pleasebackup.ask,
[
{ text: loc.pleasebackup.ask_yes, onPress: onSuccess, style: 'cancel' },
{ text: loc.pleasebackup.ask_no, onPress: onFailure },
],
{ cancelable: false },
);
export const BlueAlertWalletExportReminder = ({ onSuccess = () => {}, onFailure, anchor }) => {
if (isDesktop) {
ActionSheet.showActionSheetWithOptions(
{
title: loc.wallets.details_title, // Changed from loc.send.header to loc.wallets.details_title
message: loc.pleasebackup.ask,
options: [loc.pleasebackup.ask_yes, loc.pleasebackup.ask_no],
anchor: findNodeHandle(anchor), // Kept the same for context
},
buttonIndex => {
switch (buttonIndex) {
case 0:
onSuccess(); // Assuming the first button (yes) triggers onSuccess
break;
case 1:
onFailure(); // Assuming the second button (no) triggers onFailure
break;
}
},
);
} else {
Alert.alert(
loc.wallets.details_title,
loc.pleasebackup.ask,
[
{ text: loc.pleasebackup.ask_yes, onPress: onSuccess, style: 'cancel' },
{ text: loc.pleasebackup.ask_no, onPress: onFailure },
],
{ cancelable: false },
);
}
};
export const BluePrivateBalance = () => {

View file

@ -61,6 +61,7 @@ const ReceiveDetails = () => {
const [initialUnconfirmed, setInitialUnconfirmed] = useState(0);
const [displayBalance, setDisplayBalance] = useState('');
const fetchAddressInterval = useRef();
const receiveAddressButton = useRef();
const stylesHook = StyleSheet.create({
modalContent: {
backgroundColor: colors.modal,
@ -270,7 +271,7 @@ const ReceiveDetails = () => {
)}
<QRCodeComponent value={bip21encoded} />
<BlueCopyTextToClipboard text={isCustom ? bip21encoded : address} />
<BlueCopyTextToClipboard text={isCustom ? bip21encoded : address} ref={receiveAddressButton} />
</View>
<View style={styles.share}>
<BlueCard>
@ -344,7 +345,6 @@ const ReceiveDetails = () => {
BlueAlertWalletExportReminder({
onSuccess: obtainWalletAddress,
onFailure: () => {
goBack();
navigate('WalletExportRoot', {
screen: 'WalletExport',
params: {
@ -352,6 +352,7 @@ const ReceiveDetails = () => {
},
});
},
anchor: receiveAddressButton.current,
});
} else {
obtainWalletAddress();