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 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<PowerState>) => {
if (!state.lowPowerMode) {
ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true });

View file

@ -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]);

View file

@ -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"];

View file

@ -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<AddWalletStackParamList, 'Impor
const ImportWallet = () => {
const navigation = useExtendedNavigation<NavigationProps>();
const { colors } = useTheme();
const { colors, closeImage } = useTheme();
const route = useRoute<RouteProps>();
const label = route?.params?.label ?? '';
const triggerImport = route?.params?.triggerImport ?? false;
@ -37,7 +37,6 @@ const ImportWallet = () => {
const [askPassphraseMenuState, setAskPassphraseMenuState] = useState<boolean>(false);
const [clearClipboardMenuState, setClearClipboardMenuState] = useState<boolean>(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
? () => (
<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 = (
<>