From 234321ef37628f9fe600d7c2b5efc6120ab483f3 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Wed, 20 Mar 2024 19:16:12 -0400 Subject: [PATCH] FIX: Wallet export reminder was not visible on macOS --- BlueComponents.js | 44 ++++++++++++++++++++++++++++++--------- screen/receive/details.js | 5 +++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 259dd661a..d9edb8cb8 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -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 = () => { diff --git a/screen/receive/details.js b/screen/receive/details.js index cb7c1d216..284a8031e 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -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 = () => { )} - + @@ -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();