FIX: Can't enter settings on mac version #7368

This commit is contained in:
Marcos Rodriguez Velez 2024-11-28 20:38:07 -05:00
parent 09ca2ccd6a
commit b4e28f89ec
4 changed files with 35 additions and 12 deletions

View file

@ -1,5 +1,6 @@
import DeviceInfo, { PowerState } from 'react-native-device-info'; import DeviceInfo, { PowerState } from 'react-native-device-info';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { isDesktop } from './environment';
// Define a const enum for HapticFeedbackTypes // Define a const enum for HapticFeedbackTypes
export const enum HapticFeedbackTypes { export const enum HapticFeedbackTypes {
@ -13,6 +14,7 @@ export const enum HapticFeedbackTypes {
} }
const triggerHapticFeedback = (type: HapticFeedbackTypes) => { const triggerHapticFeedback = (type: HapticFeedbackTypes) => {
if (isDesktop) return;
DeviceInfo.getPowerState().then((state: Partial<PowerState>) => { DeviceInfo.getPowerState().then((state: Partial<PowerState>) => {
if (!state.lowPowerMode) { if (!state.lowPowerMode) {
ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true }); ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true });

View file

@ -44,16 +44,20 @@ const useMenuElements = () => {
console.debug('Setting up menu event listeners'); console.debug('Setting up menu event listeners');
const listeners = [ // Add permanent listeners only once
eventEmitter.addListener('openSettings', eventActions.openSettings), eventEmitter.removeAllListeners('openSettings');
eventEmitter.addListener('addWalletMenuAction', eventActions.addWallet), eventEmitter.removeAllListeners('addWalletMenuAction');
eventEmitter.addListener('importWalletMenuAction', eventActions.importWallet), eventEmitter.removeAllListeners('importWalletMenuAction');
eventEmitter.addListener('reloadTransactionsMenuAction', eventActions.reloadTransactions),
]; eventEmitter.addListener('openSettings', eventActions.openSettings);
eventEmitter.addListener('addWalletMenuAction', eventActions.addWallet);
eventEmitter.addListener('importWalletMenuAction', eventActions.importWallet);
const reloadTransactionsListener = eventEmitter.addListener('reloadTransactionsMenuAction', eventActions.reloadTransactions);
return () => { return () => {
console.debug('Removing menu event listeners'); console.debug('Removing reloadTransactionsMenuAction listener');
listeners.forEach(listener => listener.remove()); reloadTransactionsListener.remove();
}; };
}, [walletsInitialized, eventActions]); }, [walletsInitialized, eventActions]);

View file

@ -23,6 +23,7 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
[MenuElementsEmitter sharedInstance];
[CustomSegmentedControlManager registerIfNecessary]; [CustomSegmentedControlManager registerIfNecessary];
[self clearFilesIfNeeded]; [self clearFilesIfNeeded];
self.userDefaultsGroup = [[NSUserDefaults alloc] initWithSuiteName:@"group.io.bluewallet.bluewallet"]; self.userDefaultsGroup = [[NSUserDefaults alloc] initWithSuiteName:@"group.io.bluewallet.bluewallet"];

View file

@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { RouteProp, useRoute } from '@react-navigation/native'; import { RouteProp, useRoute } from '@react-navigation/native';
import Clipboard from '@react-native-clipboard/clipboard'; 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 { disallowScreenshot } from 'react-native-screen-capture';
import { BlueButtonLink, BlueFormLabel, BlueFormMultiInput, BlueSpacing20 } from '../../BlueComponents'; import { BlueButtonLink, BlueFormLabel, BlueFormMultiInput, BlueSpacing20 } from '../../BlueComponents';
import Button from '../../components/Button'; import Button from '../../components/Button';
@ -25,7 +25,7 @@ type NavigationProps = NativeStackNavigationProp<AddWalletStackParamList, 'Impor
const ImportWallet = () => { const ImportWallet = () => {
const navigation = useExtendedNavigation<NavigationProps>(); const navigation = useExtendedNavigation<NavigationProps>();
const { colors } = useTheme(); const { colors, closeImage } = useTheme();
const route = useRoute<RouteProps>(); const route = useRoute<RouteProps>();
const label = route?.params?.label ?? ''; const label = route?.params?.label ?? '';
const triggerImport = route?.params?.triggerImport ?? false; const triggerImport = route?.params?.triggerImport ?? false;
@ -37,7 +37,6 @@ const ImportWallet = () => {
const [askPassphraseMenuState, setAskPassphraseMenuState] = useState<boolean>(false); const [askPassphraseMenuState, setAskPassphraseMenuState] = useState<boolean>(false);
const [clearClipboardMenuState, setClearClipboardMenuState] = useState<boolean>(true); const [clearClipboardMenuState, setClearClipboardMenuState] = useState<boolean>(true);
const { isPrivacyBlurEnabled } = useSettings(); const { isPrivacyBlurEnabled } = useSettings();
// Styles
const styles = StyleSheet.create({ const styles = StyleSheet.create({
root: { root: {
paddingTop: 10, paddingTop: 10,
@ -49,6 +48,9 @@ const ImportWallet = () => {
marginHorizontal: 16, marginHorizontal: 16,
backgroundColor: colors.elevated, backgroundColor: colors.elevated,
}, },
button: {
padding: 10,
},
}); });
const onBlur = useCallback(() => { const onBlur = useCallback(() => {
@ -169,8 +171,22 @@ const ImportWallet = () => {
useEffect(() => { useEffect(() => {
navigation.setOptions({ navigation.setOptions({
headerRight: () => HeaderRight, headerRight: () => HeaderRight,
headerLeft:
navigation.getState().index === 0
? () => (
<TouchableOpacity
accessibilityRole="button"
accessibilityLabel={loc._.close}
style={styles.button}
onPress={() => navigation.goBack()}
testID="NavigationCloseButton"
>
<Image source={closeImage} />
</TouchableOpacity>
)
: undefined,
}); });
}, [colors.foregroundColor, navigation, toolTipActions, HeaderRight]); }, [colors, navigation, toolTipActions, HeaderRight, styles.button, closeImage]);
const renderOptionsAndImportButton = ( const renderOptionsAndImportButton = (
<> <>