From b4e28f89ec36362691d1be7bfaf1c76b3435e0b4 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Thu, 28 Nov 2024 20:38:07 -0500 Subject: [PATCH] FIX: Can't enter settings on mac version #7368 --- blue_modules/hapticFeedback.ts | 2 ++ hooks/useMenuElements.ios.ts | 20 ++++++++++++-------- ios/BlueWallet/AppDelegate.mm | 1 + screen/wallets/ImportWallet.tsx | 24 ++++++++++++++++++++---- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/blue_modules/hapticFeedback.ts b/blue_modules/hapticFeedback.ts index 69cf98be6..4d9bfd280 100644 --- a/blue_modules/hapticFeedback.ts +++ b/blue_modules/hapticFeedback.ts @@ -1,5 +1,6 @@ import DeviceInfo, { PowerState } from 'react-native-device-info'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; +import { isDesktop } from './environment'; // Define a const enum for HapticFeedbackTypes export const enum HapticFeedbackTypes { @@ -13,6 +14,7 @@ export const enum HapticFeedbackTypes { } const triggerHapticFeedback = (type: HapticFeedbackTypes) => { + if (isDesktop) return; DeviceInfo.getPowerState().then((state: Partial) => { if (!state.lowPowerMode) { ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true }); diff --git a/hooks/useMenuElements.ios.ts b/hooks/useMenuElements.ios.ts index b7b10244c..d28df2924 100644 --- a/hooks/useMenuElements.ios.ts +++ b/hooks/useMenuElements.ios.ts @@ -44,16 +44,20 @@ const useMenuElements = () => { console.debug('Setting up menu event listeners'); - const listeners = [ - eventEmitter.addListener('openSettings', eventActions.openSettings), - eventEmitter.addListener('addWalletMenuAction', eventActions.addWallet), - eventEmitter.addListener('importWalletMenuAction', eventActions.importWallet), - eventEmitter.addListener('reloadTransactionsMenuAction', eventActions.reloadTransactions), - ]; + // Add permanent listeners only once + eventEmitter.removeAllListeners('openSettings'); + eventEmitter.removeAllListeners('addWalletMenuAction'); + eventEmitter.removeAllListeners('importWalletMenuAction'); + + eventEmitter.addListener('openSettings', eventActions.openSettings); + eventEmitter.addListener('addWalletMenuAction', eventActions.addWallet); + eventEmitter.addListener('importWalletMenuAction', eventActions.importWallet); + + const reloadTransactionsListener = eventEmitter.addListener('reloadTransactionsMenuAction', eventActions.reloadTransactions); return () => { - console.debug('Removing menu event listeners'); - listeners.forEach(listener => listener.remove()); + console.debug('Removing reloadTransactionsMenuAction listener'); + reloadTransactionsListener.remove(); }; }, [walletsInitialized, eventActions]); diff --git a/ios/BlueWallet/AppDelegate.mm b/ios/BlueWallet/AppDelegate.mm index 80906294d..692eb6b99 100644 --- a/ios/BlueWallet/AppDelegate.mm +++ b/ios/BlueWallet/AppDelegate.mm @@ -23,6 +23,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [MenuElementsEmitter sharedInstance]; [CustomSegmentedControlManager registerIfNecessary]; [self clearFilesIfNeeded]; self.userDefaultsGroup = [[NSUserDefaults alloc] initWithSuiteName:@"group.io.bluewallet.bluewallet"]; diff --git a/screen/wallets/ImportWallet.tsx b/screen/wallets/ImportWallet.tsx index 4d3a1a6b8..2710c6650 100644 --- a/screen/wallets/ImportWallet.tsx +++ b/screen/wallets/ImportWallet.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { RouteProp, useRoute } from '@react-navigation/native'; import Clipboard from '@react-native-clipboard/clipboard'; -import { Keyboard, Platform, ScrollView, StyleSheet, TouchableWithoutFeedback, View } from 'react-native'; +import { Keyboard, Platform, ScrollView, StyleSheet, TouchableWithoutFeedback, View, TouchableOpacity, Image } from 'react-native'; import { disallowScreenshot } from 'react-native-screen-capture'; import { BlueButtonLink, BlueFormLabel, BlueFormMultiInput, BlueSpacing20 } from '../../BlueComponents'; import Button from '../../components/Button'; @@ -25,7 +25,7 @@ type NavigationProps = NativeStackNavigationProp { const navigation = useExtendedNavigation(); - const { colors } = useTheme(); + const { colors, closeImage } = useTheme(); const route = useRoute(); const label = route?.params?.label ?? ''; const triggerImport = route?.params?.triggerImport ?? false; @@ -37,7 +37,6 @@ const ImportWallet = () => { const [askPassphraseMenuState, setAskPassphraseMenuState] = useState(false); const [clearClipboardMenuState, setClearClipboardMenuState] = useState(true); const { isPrivacyBlurEnabled } = useSettings(); - // Styles const styles = StyleSheet.create({ root: { paddingTop: 10, @@ -49,6 +48,9 @@ const ImportWallet = () => { marginHorizontal: 16, backgroundColor: colors.elevated, }, + button: { + padding: 10, + }, }); const onBlur = useCallback(() => { @@ -169,8 +171,22 @@ const ImportWallet = () => { useEffect(() => { navigation.setOptions({ headerRight: () => HeaderRight, + headerLeft: + navigation.getState().index === 0 + ? () => ( + navigation.goBack()} + testID="NavigationCloseButton" + > + + + ) + : undefined, }); - }, [colors.foregroundColor, navigation, toolTipActions, HeaderRight]); + }, [colors, navigation, toolTipActions, HeaderRight, styles.button, closeImage]); const renderOptionsAndImportButton = ( <>