mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge pull request #6323 from BlueWallet/container
REF: useExtendedNavigation
This commit is contained in:
commit
91ac12922d
59
App.js
59
App.js
@ -33,6 +33,7 @@ import HandoffComponent from './components/handoff';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from './blue_modules/hapticFeedback';
|
||||
import MenuElements from './components/MenuElements';
|
||||
import { updateExchangeRate } from './blue_modules/currency';
|
||||
import { NavigationProvider } from './components/NavigationProvider';
|
||||
const A = require('./blue_modules/analytics');
|
||||
|
||||
const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.EventEmitter) : undefined;
|
||||
@ -99,28 +100,42 @@ const App = () => {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (walletsInitialized) {
|
||||
addListeners();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [walletsInitialized]);
|
||||
|
||||
const addListeners = () => {
|
||||
Linking.addEventListener('url', handleOpenURL);
|
||||
AppState.addEventListener('change', handleAppStateChange);
|
||||
const urlSubscription = Linking.addEventListener('url', handleOpenURL);
|
||||
const appStateSubscription = AppState.addEventListener('change', handleAppStateChange);
|
||||
|
||||
// Note: `getMostRecentUserActivity` doesn't create a persistent listener, so no need to unsubscribe
|
||||
EventEmitter?.getMostRecentUserActivity()
|
||||
.then(onUserActivityOpen)
|
||||
.catch(() => console.log('No userActivity object sent'));
|
||||
handleAppStateChange(undefined);
|
||||
/*
|
||||
When a notification on iOS is shown while the app is on foreground;
|
||||
On willPresent on AppDelegate.m
|
||||
*/
|
||||
eventEmitter?.addListener('onNotificationReceived', onNotificationReceived);
|
||||
eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen);
|
||||
|
||||
const notificationSubscription = eventEmitter?.addListener('onNotificationReceived', onNotificationReceived);
|
||||
const activitySubscription = eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen);
|
||||
|
||||
// Store subscriptions in a ref or state to remove them later
|
||||
return {
|
||||
urlSubscription,
|
||||
appStateSubscription,
|
||||
notificationSubscription,
|
||||
activitySubscription,
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (walletsInitialized) {
|
||||
const subscriptions = addListeners();
|
||||
|
||||
// Cleanup function
|
||||
return () => {
|
||||
subscriptions.urlSubscription?.remove();
|
||||
subscriptions.appStateSubscription?.remove();
|
||||
subscriptions.notificationSubscription?.remove();
|
||||
subscriptions.activitySubscription?.remove();
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [walletsInitialized]); // Re-run when walletsInitialized changes
|
||||
|
||||
/**
|
||||
* Processes push notifications stored in AsyncStorage. Might navigate to some screen.
|
||||
*
|
||||
@ -285,14 +300,16 @@ const App = () => {
|
||||
<SafeAreaProvider>
|
||||
<View style={styles.root}>
|
||||
<NavigationContainer ref={navigationRef} theme={colorScheme === 'dark' ? BlueDarkTheme : BlueDefaultTheme}>
|
||||
<InitRoot />
|
||||
<Notifications onProcessNotifications={processPushNotifications} />
|
||||
<MenuElements />
|
||||
<DeviceQuickActions />
|
||||
<NavigationProvider>
|
||||
<InitRoot />
|
||||
<Notifications onProcessNotifications={processPushNotifications} />
|
||||
<MenuElements />
|
||||
<DeviceQuickActions />
|
||||
<Biometric />
|
||||
</NavigationProvider>
|
||||
</NavigationContainer>
|
||||
</View>
|
||||
<WatchConnectivity />
|
||||
<Biometric />
|
||||
<WidgetCommunication />
|
||||
</SafeAreaProvider>
|
||||
);
|
||||
|
@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
|
||||
import { Icon, Text, Header } from 'react-native-elements';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
Animated,
|
||||
Dimensions,
|
||||
Image,
|
||||
@ -18,7 +17,6 @@ import {
|
||||
View,
|
||||
I18nManager,
|
||||
ImageBackground,
|
||||
findNodeHandle,
|
||||
} from 'react-native';
|
||||
import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import NetworkTransactionFees, { NetworkTransactionFee, NetworkTransactionFeeType } from './models/networkTransactionFees';
|
||||
@ -27,8 +25,6 @@ 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;
|
||||
@ -196,39 +192,6 @@ export const BlueButtonLink = forwardRef((props, ref) => {
|
||||
);
|
||||
});
|
||||
|
||||
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 = () => {
|
||||
return (
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginTop: 13, borderRadius: 9 }}>
|
||||
|
9
components/NavigationProvider.tsx
Normal file
9
components/NavigationProvider.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
|
||||
interface NavigationProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const NavigationProvider: React.FC<NavigationProviderProps> = ({ children }) => {
|
||||
return <>{children}</>;
|
||||
};
|
16
helpers/presentWalletExportReminder.ts
Normal file
16
helpers/presentWalletExportReminder.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Alert } from 'react-native';
|
||||
import loc from '../loc';
|
||||
|
||||
export const presentWalletExportReminder = (): Promise<void> => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
Alert.alert(
|
||||
loc.wallets.details_title,
|
||||
loc.pleasebackup.ask,
|
||||
[
|
||||
{ text: loc.pleasebackup.ask_yes, onPress: () => resolve(), style: 'default' },
|
||||
{ text: loc.pleasebackup.ask_no, onPress: () => reject(new Error('User has denied saving the wallet backup.')), style: 'cancel' },
|
||||
],
|
||||
{ cancelable: false },
|
||||
);
|
||||
});
|
||||
};
|
94
hooks/useExtendedNavigation.ts
Normal file
94
hooks/useExtendedNavigation.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native';
|
||||
import Biometric from '../class/biometrics';
|
||||
import { navigationRef } from '../NavigationService';
|
||||
import { BlueStorageContext } from '../blue_modules/storage-context';
|
||||
import { useContext } from 'react';
|
||||
import { presentWalletExportReminder } from '../helpers/presentWalletExportReminder';
|
||||
|
||||
// List of screens that require biometrics
|
||||
|
||||
const requiresBiometrics = ['WalletExportRoot', 'WalletXpubRoot', 'ViewEditMultisigCosignersRoot', 'ExportMultisigCoordinationSetupRoot'];
|
||||
|
||||
// List of screens that require wallet export to be saved
|
||||
|
||||
const requiresWalletExportIsSaved = ['ReceiveDetailsRoot', 'WalletAddresses'];
|
||||
|
||||
export const useExtendedNavigation = (): NavigationProp<ParamListBase> => {
|
||||
const originalNavigation = useNavigation<NavigationProp<ParamListBase>>();
|
||||
const { wallets, saveToDisk } = useContext(BlueStorageContext);
|
||||
|
||||
const enhancedNavigate: NavigationProp<ParamListBase>['navigate'] = (screenOrOptions: any, params?: any) => {
|
||||
let screenName: string;
|
||||
if (typeof screenOrOptions === 'string') {
|
||||
screenName = screenOrOptions;
|
||||
} else if (typeof screenOrOptions === 'object' && 'name' in screenOrOptions) {
|
||||
screenName = screenOrOptions.name;
|
||||
params = screenOrOptions.params; // Assign params from object if present
|
||||
} else {
|
||||
throw new Error('Invalid navigation options');
|
||||
}
|
||||
|
||||
const isRequiresBiometrics = requiresBiometrics.includes(screenName);
|
||||
const isRequiresWalletExportIsSaved = requiresWalletExportIsSaved.includes(screenName);
|
||||
|
||||
const proceedWithNavigation = () => {
|
||||
console.log('Proceeding with navigation to', screenName);
|
||||
if (navigationRef.current?.isReady()) {
|
||||
typeof screenOrOptions === 'string'
|
||||
? originalNavigation.navigate(screenOrOptions, params)
|
||||
: originalNavigation.navigate(screenName, params); // Fixed to use screenName and params
|
||||
}
|
||||
};
|
||||
|
||||
(async () => {
|
||||
if (isRequiresBiometrics) {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseEnabled();
|
||||
if (isBiometricsEnabled) {
|
||||
const isAuthenticated = await Biometric.unlockWithBiometrics();
|
||||
if (isAuthenticated) {
|
||||
proceedWithNavigation();
|
||||
return; // Ensure the function exits if this path is taken
|
||||
} else {
|
||||
console.error('Biometric authentication failed');
|
||||
// Decide if navigation should proceed or not after failed authentication
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRequiresWalletExportIsSaved) {
|
||||
console.log('Checking if wallet export is saved');
|
||||
let walletID: string | undefined;
|
||||
if (params && params.walletID) {
|
||||
walletID = params.walletID;
|
||||
} else if (params && params.params && params.params.walletID) {
|
||||
walletID = params.params.walletID;
|
||||
}
|
||||
if (!walletID) {
|
||||
proceedWithNavigation();
|
||||
return;
|
||||
}
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
if (wallet && !wallet.getUserHasSavedExport()) {
|
||||
try {
|
||||
await presentWalletExportReminder();
|
||||
wallet.setUserHasSavedExport(true);
|
||||
await saveToDisk(); // Assuming saveToDisk() returns a Promise.
|
||||
proceedWithNavigation();
|
||||
} catch {
|
||||
originalNavigation.navigate('WalletExportRoot', {
|
||||
screen: 'WalletExport',
|
||||
params: { walletID },
|
||||
});
|
||||
}
|
||||
|
||||
return; // Prevent proceeding with the original navigation if the reminder is shown
|
||||
}
|
||||
}
|
||||
proceedWithNavigation();
|
||||
})();
|
||||
};
|
||||
|
||||
return {
|
||||
...originalNavigation,
|
||||
navigate: enhancedNavigate,
|
||||
};
|
||||
};
|
@ -511,7 +511,7 @@ PODS:
|
||||
- RNScreens (3.29.0):
|
||||
- RCT-Folly (= 2021.07.22.00)
|
||||
- React-Core
|
||||
- RNShare (10.0.2):
|
||||
- RNShare (10.1.0):
|
||||
- React-Core
|
||||
- RNSVG (13.14.0):
|
||||
- React-Core
|
||||
@ -861,7 +861,7 @@ SPEC CHECKSUMS:
|
||||
RNReactNativeHapticFeedback: ec56a5f81c3941206fd85625fa669ffc7b4545f9
|
||||
RNReanimated: fc36806836aca984b797f01432abe31689663421
|
||||
RNScreens: 8ba3eeb8f5cb9f13662df564e785d64ef7214bf2
|
||||
RNShare: 859ff710211285676b0bcedd156c12437ea1d564
|
||||
RNShare: b674d9f1cb0dc11116983bebd8712908a226a3ee
|
||||
RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396
|
||||
RNVectorIcons: 2b974a961e7ad079fafdd8af68b12210d5b4b28e
|
||||
RNWatch: fd30ca40a5b5ef58dcbc195638e68219bc455236
|
||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -92,7 +92,7 @@
|
||||
"react-native-safe-area-context": "4.9.0",
|
||||
"react-native-screens": "3.29.0",
|
||||
"react-native-secure-key-store": "https://github.com/BlueWallet/react-native-secure-key-store#2076b48",
|
||||
"react-native-share": "10.0.2",
|
||||
"react-native-share": "10.1.0",
|
||||
"react-native-svg": "13.14.0",
|
||||
"react-native-tcp-socket": "6.0.6",
|
||||
"react-native-vector-icons": "10.0.3",
|
||||
@ -19689,9 +19689,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/react-native-share": {
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react-native-share/-/react-native-share-10.0.2.tgz",
|
||||
"integrity": "sha512-EZs4MtsyauAI1zP8xXT1hIFB/pXOZJNDCKcgCpEfTZFXgCUzz8MDVbI1ocP2hA59XHRSkqAQdbJ0BFTpjxOBlg==",
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-share/-/react-native-share-10.1.0.tgz",
|
||||
"integrity": "sha512-fKKvwaZe5s3HW0tcRKyR5AWvAfXvkk0FgTw1nYWYjI4gNqntXbMjRqWZed8Hmd1MvIJS17K/ELPges0tsxbp3g==",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
@ -37265,9 +37265,9 @@
|
||||
"from": "react-native-secure-key-store@https://github.com/BlueWallet/react-native-secure-key-store#2076b48"
|
||||
},
|
||||
"react-native-share": {
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react-native-share/-/react-native-share-10.0.2.tgz",
|
||||
"integrity": "sha512-EZs4MtsyauAI1zP8xXT1hIFB/pXOZJNDCKcgCpEfTZFXgCUzz8MDVbI1ocP2hA59XHRSkqAQdbJ0BFTpjxOBlg=="
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-share/-/react-native-share-10.1.0.tgz",
|
||||
"integrity": "sha512-fKKvwaZe5s3HW0tcRKyR5AWvAfXvkk0FgTw1nYWYjI4gNqntXbMjRqWZed8Hmd1MvIJS17K/ELPges0tsxbp3g=="
|
||||
},
|
||||
"react-native-size-matters": {
|
||||
"version": "0.3.1",
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
import { Icon } from 'react-native-elements';
|
||||
import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
|
||||
|
||||
import { BlueAlertWalletExportReminder, BlueDismissKeyboardInputAccessory, BlueLoading } from '../../BlueComponents';
|
||||
import { BlueDismissKeyboardInputAccessory, BlueLoading } from '../../BlueComponents';
|
||||
import navigationStyle from '../../components/navigationStyle';
|
||||
import AmountInput from '../../components/AmountInput';
|
||||
import * as NavigationService from '../../NavigationService';
|
||||
@ -32,6 +32,7 @@ import { useTheme } from '../../components/themes';
|
||||
import Button from '../../components/Button';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { btcToSatoshi, fiatToBTC, satoshiToBTC } from '../../blue_modules/currency';
|
||||
import { presentWalletExportReminder } from '../../helpers/presentWalletExportReminder';
|
||||
|
||||
const LNDCreateInvoice = () => {
|
||||
const { wallets, saveToDisk, setSelectedWalletID } = useContext(BlueStorageContext);
|
||||
@ -117,9 +118,11 @@ const LNDCreateInvoice = () => {
|
||||
if (wallet.current.getUserHasSavedExport()) {
|
||||
renderReceiveDetails();
|
||||
} else {
|
||||
BlueAlertWalletExportReminder({
|
||||
onSuccess: () => renderReceiveDetails(),
|
||||
onFailure: () => {
|
||||
presentWalletExportReminder()
|
||||
.then(() => {
|
||||
renderReceiveDetails();
|
||||
})
|
||||
.catch(() => {
|
||||
getParent().pop();
|
||||
NavigationService.navigate('WalletExportRoot', {
|
||||
screen: 'WalletExport',
|
||||
@ -127,8 +130,7 @@ const LNDCreateInvoice = () => {
|
||||
walletID,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
TextInput,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { useNavigation, useRoute, useFocusEffect } from '@react-navigation/native';
|
||||
import { useRoute, useFocusEffect } from '@react-navigation/native';
|
||||
import Share from 'react-native-share';
|
||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||
import {
|
||||
@ -19,7 +19,6 @@ import {
|
||||
BlueButtonLink,
|
||||
BlueText,
|
||||
BlueSpacing20,
|
||||
BlueAlertWalletExportReminder,
|
||||
BlueCard,
|
||||
BlueSpacing40,
|
||||
} from '../../BlueComponents';
|
||||
@ -39,6 +38,7 @@ import { useTheme } from '../../components/themes';
|
||||
import Button from '../../components/Button';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { fiatToBTC, satoshiToBTC } from '../../blue_modules/currency';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
|
||||
const ReceiveDetails = () => {
|
||||
const { walletID, address } = useRoute().params;
|
||||
@ -53,7 +53,7 @@ const ReceiveDetails = () => {
|
||||
const [showPendingBalance, setShowPendingBalance] = useState(false);
|
||||
const [showConfirmedBalance, setShowConfirmedBalance] = useState(false);
|
||||
const [showAddress, setShowAddress] = useState(false);
|
||||
const { navigate, goBack, setParams } = useNavigation();
|
||||
const { goBack, setParams } = useExtendedNavigation();
|
||||
const { colors } = useTheme();
|
||||
const [intervalMs, setIntervalMs] = useState(5000);
|
||||
const [eta, setEta] = useState('');
|
||||
@ -341,22 +341,7 @@ const ReceiveDetails = () => {
|
||||
useCallback(() => {
|
||||
const task = InteractionManager.runAfterInteractions(async () => {
|
||||
if (wallet) {
|
||||
if (!wallet.getUserHasSavedExport()) {
|
||||
BlueAlertWalletExportReminder({
|
||||
onSuccess: obtainWalletAddress,
|
||||
onFailure: () => {
|
||||
navigate('WalletExportRoot', {
|
||||
screen: 'WalletExport',
|
||||
params: {
|
||||
walletID: wallet.getID(),
|
||||
},
|
||||
});
|
||||
},
|
||||
anchor: receiveAddressButton.current,
|
||||
});
|
||||
} else {
|
||||
obtainWalletAddress();
|
||||
}
|
||||
obtainWalletAddress();
|
||||
} else if (!wallet && address) {
|
||||
setAddressBIP21Encoded(address);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import {
|
||||
LightningLdkWallet,
|
||||
} from '../../class';
|
||||
import loc, { formatBalanceWithoutSuffix } from '../../loc';
|
||||
import { useRoute, useNavigation } from '@react-navigation/native';
|
||||
import { useRoute } from '@react-navigation/native';
|
||||
import RNFS from 'react-native-fs';
|
||||
import Share from 'react-native-share';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
@ -48,6 +48,7 @@ import ListItem from '../../components/ListItem';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import Button from '../../components/Button';
|
||||
import { SecondButton } from '../../components/SecondButton';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
|
||||
const prompt = require('../../helpers/prompt');
|
||||
|
||||
@ -134,7 +135,7 @@ const WalletDetails = () => {
|
||||
const [isAdvancedModeEnabledRender, setIsAdvancedModeEnabledRender] = useState(false);
|
||||
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
|
||||
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
|
||||
const { goBack, navigate, setOptions, popToTop } = useNavigation();
|
||||
const { goBack, setOptions, popToTop, navigate } = useExtendedNavigation();
|
||||
const { colors } = useTheme();
|
||||
const [masterFingerprint, setMasterFingerprint] = useState();
|
||||
const walletTransactionsLength = useMemo(() => wallet.getTransactions().length, [wallet]);
|
||||
|
@ -1,10 +1,8 @@
|
||||
import React, { useState, useCallback, useContext, useRef, useEffect } from 'react';
|
||||
import { InteractionManager, ScrollView, ActivityIndicator, View, StyleSheet, AppState } from 'react-native';
|
||||
import { useNavigation, useFocusEffect, useRoute } from '@react-navigation/native';
|
||||
|
||||
import { BlueSpacing20, BlueText, BlueCopyTextToClipboard, BlueCard } from '../../BlueComponents';
|
||||
import navigationStyle from '../../components/navigationStyle';
|
||||
import Biometric from '../../class/biometrics';
|
||||
import { LegacyWallet, LightningCustodianWallet, SegwitBech32Wallet, SegwitP2SHWallet, WatchOnlyWallet } from '../../class';
|
||||
import loc from '../../loc';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
@ -56,13 +54,6 @@ const WalletExport = () => {
|
||||
enableBlur();
|
||||
const task = InteractionManager.runAfterInteractions(async () => {
|
||||
if (wallet) {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
||||
|
||||
if (isBiometricsEnabled) {
|
||||
if (!(await Biometric.unlockWithBiometrics())) {
|
||||
return goBack();
|
||||
}
|
||||
}
|
||||
if (!wallet.getUserHasSavedExport()) {
|
||||
wallet.setUserHasSavedExport(true);
|
||||
saveToDisk();
|
||||
@ -75,7 +66,7 @@ const WalletExport = () => {
|
||||
disableBlur();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [goBack, saveToDisk, wallet]),
|
||||
}, [wallet]),
|
||||
);
|
||||
|
||||
if (isLoading || !wallet)
|
||||
|
@ -1,10 +1,9 @@
|
||||
import React, { useCallback, useContext, useRef, useState } from 'react';
|
||||
import { ActivityIndicator, InteractionManager, ScrollView, StyleSheet, View } from 'react-native';
|
||||
import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
|
||||
import { useFocusEffect, useRoute } from '@react-navigation/native';
|
||||
import { BlueSpacing20, BlueText } from '../../BlueComponents';
|
||||
import navigationStyle from '../../components/navigationStyle';
|
||||
import { DynamicQRCode } from '../../components/DynamicQRCode';
|
||||
import Biometric from '../../class/biometrics';
|
||||
import loc from '../../loc';
|
||||
import { SquareButton } from '../../components/SquareButton';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
@ -21,7 +20,6 @@ const ExportMultisigCoordinationSetup = () => {
|
||||
const dynamicQRCode = useRef();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [isShareButtonTapped, setIsShareButtonTapped] = useState(false);
|
||||
const { goBack } = useNavigation();
|
||||
const { colors } = useTheme();
|
||||
const { enableBlur, disableBlur } = usePrivacy();
|
||||
const stylesHook = StyleSheet.create({
|
||||
@ -54,13 +52,6 @@ const ExportMultisigCoordinationSetup = () => {
|
||||
enableBlur();
|
||||
const task = InteractionManager.runAfterInteractions(async () => {
|
||||
if (wallet) {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
||||
|
||||
if (isBiometricsEnabled) {
|
||||
if (!(await Biometric.unlockWithBiometrics())) {
|
||||
return goBack();
|
||||
}
|
||||
}
|
||||
qrCodeContents.current = Buffer.from(wallet.getXpub(), 'ascii').toString('hex');
|
||||
setIsLoading(false);
|
||||
}
|
||||
@ -69,7 +60,7 @@ const ExportMultisigCoordinationSetup = () => {
|
||||
task.cancel();
|
||||
disableBlur();
|
||||
};
|
||||
}, [disableBlur, enableBlur, goBack, wallet]),
|
||||
}, [disableBlur, enableBlur, wallet]),
|
||||
);
|
||||
|
||||
return isLoading ? (
|
||||
|
@ -20,7 +20,7 @@ import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
|
||||
import ActionSheet from '../ActionSheet';
|
||||
import loc from '../../loc';
|
||||
import { FContainer, FButton } from '../../components/FloatButtons';
|
||||
import { useFocusEffect, useIsFocused, useNavigation, useRoute } from '@react-navigation/native';
|
||||
import { useFocusEffect, useIsFocused, useRoute } from '@react-navigation/native';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
import { isDesktop, isTablet } from '../../blue_modules/environment';
|
||||
import BlueClipboard from '../../blue_modules/clipboard';
|
||||
@ -30,6 +30,7 @@ import { scanQrHelper } from '../../helpers/scan-qr';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import presentAlert from '../../components/Alert';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
|
||||
const A = require('../../blue_modules/analytics');
|
||||
const fs = require('../../blue_modules/fs');
|
||||
@ -49,7 +50,7 @@ const WalletsList = () => {
|
||||
} = useContext(BlueStorageContext);
|
||||
const { width } = useWindowDimensions();
|
||||
const { colors, scanImage } = useTheme();
|
||||
const { navigate, setOptions } = useNavigation();
|
||||
const { navigate, setOptions } = useExtendedNavigation();
|
||||
const isFocused = useIsFocused();
|
||||
const routeName = useRoute().name;
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React, { useEffect, useRef, useContext, useState } from 'react';
|
||||
import { StyleSheet, useColorScheme, Platform } from 'react-native';
|
||||
import DraggableFlatList, { ScaleDecorator } from 'react-native-draggable-flatlist';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import navigationStyle from '../../components/navigationStyle';
|
||||
import loc from '../../loc';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
@ -9,6 +8,7 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { WalletCarouselItem } from '../../components/WalletsCarousel';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
@ -24,7 +24,7 @@ const ReorderWallets = () => {
|
||||
const { colors } = useTheme();
|
||||
const { wallets, setWalletsWithNewOrder } = useContext(BlueStorageContext);
|
||||
const colorScheme = useColorScheme();
|
||||
const { navigate, setOptions } = useNavigation();
|
||||
const { navigate, setOptions } = useExtendedNavigation();
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [isSearchFocused, setIsSearchFocused] = useState(false);
|
||||
const [walletData, setWalletData] = useState([]);
|
||||
|
@ -15,9 +15,8 @@ import {
|
||||
findNodeHandle,
|
||||
} from 'react-native';
|
||||
import { Icon } from 'react-native-elements';
|
||||
import { useRoute, useNavigation, useFocusEffect } from '@react-navigation/native';
|
||||
import { useRoute, useFocusEffect } from '@react-navigation/native';
|
||||
import { Chain } from '../../models/bitcoinUnits';
|
||||
import { BlueAlertWalletExportReminder } from '../../BlueComponents';
|
||||
import WalletGradient from '../../class/wallet-gradient';
|
||||
import navigationStyle from '../../components/navigationStyle';
|
||||
import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet, WatchOnlyWallet } from '../../class';
|
||||
@ -35,6 +34,8 @@ import PropTypes from 'prop-types';
|
||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
import { presentWalletExportReminder } from '../../helpers/presentWalletExportReminder';
|
||||
|
||||
const fs = require('../../blue_modules/fs');
|
||||
const BlueElectrum = require('../../blue_modules/BlueElectrum');
|
||||
@ -63,7 +64,7 @@ const WalletTransactions = ({ navigation }) => {
|
||||
const [timeElapsed, setTimeElapsed] = useState(0);
|
||||
const [limit, setLimit] = useState(15);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const { setParams, setOptions, navigate } = useNavigation();
|
||||
const { setParams, setOptions, navigate } = useExtendedNavigation();
|
||||
const { colors } = useTheme();
|
||||
const [lnNodeInfo, setLnNodeInfo] = useState({ canReceive: 0, canSend: 0 });
|
||||
const walletActionButtonsRef = useRef();
|
||||
@ -518,20 +519,20 @@ const WalletTransactions = ({ navigation }) => {
|
||||
if (wallet.getUserHasSavedExport()) {
|
||||
onManageFundsPressed({ id });
|
||||
} else {
|
||||
BlueAlertWalletExportReminder({
|
||||
onSuccess: async () => {
|
||||
presentWalletExportReminder()
|
||||
.then(async () => {
|
||||
wallet.setUserHasSavedExport(true);
|
||||
await saveToDisk();
|
||||
onManageFundsPressed({ id });
|
||||
},
|
||||
onFailure: () =>
|
||||
})
|
||||
.catch(() => {
|
||||
navigate('WalletExportRoot', {
|
||||
screen: 'WalletExport',
|
||||
params: {
|
||||
walletID: wallet.getID(),
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useFocusEffect, useNavigation } from '@react-navigation/native';
|
||||
import { useFocusEffect } from '@react-navigation/native';
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
||||
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
@ -52,6 +52,7 @@ import usePrivacy from '../../hooks/usePrivacy';
|
||||
import loc from '../../loc';
|
||||
import { isDesktop } from '../../blue_modules/environment';
|
||||
import ActionSheet from '../ActionSheet';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
const fs = require('../../blue_modules/fs');
|
||||
const prompt = require('../../helpers/prompt');
|
||||
|
||||
@ -61,7 +62,7 @@ const ViewEditMultisigCosigners = ({ route }: Props) => {
|
||||
const hasLoaded = useRef(false);
|
||||
const { colors } = useTheme();
|
||||
const { wallets, setWalletsWithNewOrder, isElectrumDisabled, isAdvancedModeEnabled } = useContext(BlueStorageContext);
|
||||
const { navigate, goBack, dispatch, addListener } = useNavigation();
|
||||
const { navigate, dispatch, addListener } = useExtendedNavigation();
|
||||
const openScannerButtonRef = useRef();
|
||||
const { walletId } = route.params;
|
||||
const w = useRef(wallets.find(wallet => wallet.getID() === walletId));
|
||||
@ -214,13 +215,6 @@ const ViewEditMultisigCosigners = ({ route }: Props) => {
|
||||
enableBlur();
|
||||
|
||||
const task = InteractionManager.runAfterInteractions(async () => {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
||||
|
||||
if (isBiometricsEnabled) {
|
||||
if (!(await Biometric.unlockWithBiometrics())) {
|
||||
return goBack();
|
||||
}
|
||||
}
|
||||
if (!w.current) {
|
||||
// lets create fake wallet so renderer wont throw any errors
|
||||
w.current = new MultisigHDWallet();
|
||||
|
@ -4,7 +4,6 @@ import { ActivityIndicator, InteractionManager, View } from 'react-native';
|
||||
import Share from 'react-native-share';
|
||||
import { BlueCopyTextToClipboard, BlueSpacing20, BlueText } from '../../BlueComponents';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
import Biometric from '../../class/biometrics';
|
||||
import Button from '../../components/Button';
|
||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||
import SafeArea from '../../components/SafeArea';
|
||||
@ -43,13 +42,6 @@ const WalletXpub: React.FC = () => {
|
||||
enableBlur();
|
||||
const task = InteractionManager.runAfterInteractions(async () => {
|
||||
if (wallet) {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
||||
|
||||
if (isBiometricsEnabled) {
|
||||
if (!(await Biometric.unlockWithBiometrics())) {
|
||||
return navigation.goBack();
|
||||
}
|
||||
}
|
||||
const walletXpub = wallet.getXpub();
|
||||
if (xpub !== walletXpub) {
|
||||
navigation.setParams({ xpub: walletXpub || undefined });
|
||||
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const mainLocFile = './loc/en.json';
|
||||
const dirsToInterate = ['components', 'screen', 'blue_modules', 'class'];
|
||||
const dirsToInterate = ['components', 'screen', 'blue_modules', 'class', 'hooks', 'helpers'];
|
||||
const addFiles = ['BlueComponents.js', 'App.js', 'BlueApp.ts', 'Navigation.tsx'];
|
||||
const allowedLocPrefixes = ['loc.lnurl_auth', 'loc.units'];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user