mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
wip
This commit is contained in:
parent
d185621861
commit
802a12e24f
@ -2,9 +2,9 @@ import { createNavigationContainerRef, NavigationAction, ParamListBase, StackAct
|
||||
|
||||
export const navigationRef = createNavigationContainerRef<ParamListBase>();
|
||||
|
||||
export function navigate(name: string, params?: ParamListBase) {
|
||||
export function navigate(name: string, params?: ParamListBase, options?: { merge: boolean }) {
|
||||
if (navigationRef.isReady()) {
|
||||
navigationRef.current?.navigate(name, params);
|
||||
navigationRef.current?.navigate({ name, params, merge: options?.merge });
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,10 @@ export function dispatch(action: NavigationAction) {
|
||||
}
|
||||
}
|
||||
|
||||
export function navigateToWalletsList() {
|
||||
navigate('WalletsList');
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
if (navigationRef.isReady()) {
|
||||
navigationRef.current?.reset({
|
||||
|
@ -231,7 +231,7 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
|
||||
<TouchableOpacity style={styles.walletPreferredUnitView} onPress={changeWalletBalanceUnit}>
|
||||
<Text style={styles.walletPreferredUnitText}>
|
||||
{wallet.getPreferredBalanceUnit() === BitcoinUnit.LOCAL_CURRENCY
|
||||
? preferredFiatCurrency?.endPointKey ?? FiatUnit.USD
|
||||
? (preferredFiatCurrency?.endPointKey ?? FiatUnit.USD)
|
||||
: wallet.getPreferredBalanceUnit()}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
@ -227,7 +227,7 @@ export const WalletCarouselItem: React.FC<WalletCarouselItemProps> = React.memo(
|
||||
return (
|
||||
<Animated.View
|
||||
style={[
|
||||
isLargeScreen || !horizontal ? [iStyles.rootLargeDevice, customStyle] : customStyle ?? { ...iStyles.root, width: itemWidth },
|
||||
isLargeScreen || !horizontal ? [iStyles.rootLargeDevice, customStyle] : (customStyle ?? { ...iStyles.root, width: itemWidth }),
|
||||
{ opacity, transform: [{ scale: scaleValue }] },
|
||||
]}
|
||||
>
|
||||
@ -334,31 +334,27 @@ const WalletsCarousel = forwardRef<FlatListRefType, WalletsCarouselProps>((props
|
||||
|
||||
const flatListRef = useRef<FlatList<any>>(null);
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
(): any => {
|
||||
return {
|
||||
scrollToEnd: (params: { animated?: boolean | null | undefined } | undefined) => flatListRef.current?.scrollToEnd(params),
|
||||
scrollToIndex: (params: {
|
||||
animated?: boolean | null | undefined;
|
||||
index: number;
|
||||
viewOffset?: number | undefined;
|
||||
viewPosition?: number | undefined;
|
||||
}) => flatListRef.current?.scrollToIndex(params),
|
||||
scrollToItem: (params: {
|
||||
animated?: boolean | null | undefined;
|
||||
item: any;
|
||||
viewOffset?: number | undefined;
|
||||
viewPosition?: number | undefined;
|
||||
}) => flatListRef.current?.scrollToItem(params),
|
||||
scrollToOffset: (params: { animated?: boolean | null | undefined; offset: number }) => flatListRef.current?.scrollToOffset(params),
|
||||
recordInteraction: () => flatListRef.current?.recordInteraction(),
|
||||
flashScrollIndicators: () => flatListRef.current?.flashScrollIndicators(),
|
||||
getNativeScrollRef: () => flatListRef.current?.getNativeScrollRef(),
|
||||
};
|
||||
},
|
||||
[],
|
||||
);
|
||||
useImperativeHandle(ref, (): any => {
|
||||
return {
|
||||
scrollToEnd: (params: { animated?: boolean | null | undefined } | undefined) => flatListRef.current?.scrollToEnd(params),
|
||||
scrollToIndex: (params: {
|
||||
animated?: boolean | null | undefined;
|
||||
index: number;
|
||||
viewOffset?: number | undefined;
|
||||
viewPosition?: number | undefined;
|
||||
}) => flatListRef.current?.scrollToIndex(params),
|
||||
scrollToItem: (params: {
|
||||
animated?: boolean | null | undefined;
|
||||
item: any;
|
||||
viewOffset?: number | undefined;
|
||||
viewPosition?: number | undefined;
|
||||
}) => flatListRef.current?.scrollToItem(params),
|
||||
scrollToOffset: (params: { animated?: boolean | null | undefined; offset: number }) => flatListRef.current?.scrollToOffset(params),
|
||||
recordInteraction: () => flatListRef.current?.recordInteraction(),
|
||||
flashScrollIndicators: () => flatListRef.current?.flashScrollIndicators(),
|
||||
getNativeScrollRef: () => flatListRef.current?.getNativeScrollRef(),
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onScrollToIndexFailed = (error: { averageItemLength: number; index: number }): void => {
|
||||
console.log('onScrollToIndexFailed');
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Platform } from 'react-native';
|
||||
import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions';
|
||||
import { navigationRef } from '../NavigationService';
|
||||
import { NavigationProp } from '@react-navigation/native';
|
||||
|
||||
/**
|
||||
* Helper function that navigates to ScanQR screen, and returns promise that will resolve with the result of a scan,
|
||||
* and then navigates back. If QRCode scan was closed, promise resolves to null.
|
||||
@ -10,40 +10,57 @@ import { NavigationProp } from '@react-navigation/native';
|
||||
* @param showFileImportButton {boolean}
|
||||
*
|
||||
* @param onDismiss {function} - if camera is closed via X button it gets triggered
|
||||
* @return {Promise<string>}
|
||||
* @param options {object} - additional options to pass to navigate
|
||||
* @return {Promise<string | null>}
|
||||
*/
|
||||
function scanQrHelper(
|
||||
currentScreenName: string,
|
||||
showFileImportButton = true,
|
||||
onDismiss?: () => void,
|
||||
navigate?: NavigationProp<any>['navigate'], // pass navigate when calling from inside BottomModal
|
||||
options: { merge: boolean } = { merge: true },
|
||||
): Promise<string | null> {
|
||||
return requestCameraAuthorization().then(() => {
|
||||
return new Promise(resolve => {
|
||||
const params = {
|
||||
const params: any = {
|
||||
showFileImportButton: Boolean(showFileImportButton),
|
||||
onBarScanned: (data: any) => {},
|
||||
onDismiss,
|
||||
};
|
||||
|
||||
params.onBarScanned = function (data: any) {
|
||||
setTimeout(() => resolve(data.data || data), 1);
|
||||
(navigate || navigationRef.navigate)({
|
||||
name: currentScreenName,
|
||||
params: {},
|
||||
if (options?.merge) {
|
||||
if (onDismiss) {
|
||||
params.onDismiss = onDismiss;
|
||||
}
|
||||
params.onBarScanned = function (data: any) {
|
||||
setTimeout(() => resolve(data.data || data), 1);
|
||||
navigationRef.navigate({
|
||||
name: currentScreenName,
|
||||
params: {},
|
||||
merge: options?.merge,
|
||||
});
|
||||
};
|
||||
|
||||
navigationRef.navigate({
|
||||
name: 'ScanQRCodeRoot',
|
||||
params: {
|
||||
screen: 'ScanQRCode',
|
||||
params,
|
||||
},
|
||||
merge: true,
|
||||
});
|
||||
};
|
||||
(navigate || navigationRef.navigate)({
|
||||
name: 'ScanQRCodeRoot',
|
||||
params: {
|
||||
screen: 'ScanQRCode',
|
||||
params,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
navigationRef.navigate({
|
||||
name: 'ScanQRCodeRoot',
|
||||
params: {
|
||||
screen: 'ScanQRCode',
|
||||
params: {
|
||||
showFileImportButton: Boolean(showFileImportButton),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const isCameraAuthorizationStatusGranted = async () => {
|
||||
const status = await check(Platform.OS === 'android' ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA);
|
||||
return status === RESULTS.GRANTED;
|
||||
|
@ -15,7 +15,11 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
|
||||
const { wallets, saveToDisk } = useStorage();
|
||||
const { isBiometricUseEnabled } = useBiometrics();
|
||||
|
||||
const enhancedNavigate: NavigationProp<ParamListBase>['navigate'] = (screenOrOptions: any, params?: any) => {
|
||||
const enhancedNavigate: NavigationProp<ParamListBase>['navigate'] = (
|
||||
screenOrOptions: any,
|
||||
params?: any,
|
||||
options?: { merge?: boolean },
|
||||
) => {
|
||||
let screenName: string;
|
||||
if (typeof screenOrOptions === 'string') {
|
||||
screenName = screenOrOptions;
|
||||
@ -32,9 +36,11 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
|
||||
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
|
||||
if (typeof screenOrOptions === 'string') {
|
||||
originalNavigation.navigate({ name: screenOrOptions, params, merge: options?.merge });
|
||||
} else {
|
||||
originalNavigation.navigate({ ...screenOrOptions, params, merge: options?.merge });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -88,9 +94,14 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
|
||||
})();
|
||||
};
|
||||
|
||||
const navigateToWalletsList = () => {
|
||||
enhancedNavigate('WalletsList');
|
||||
}
|
||||
|
||||
return {
|
||||
...originalNavigation,
|
||||
navigate: enhancedNavigate,
|
||||
navigateToWalletsList,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -181,7 +181,7 @@
|
||||
B4EFF7472C3F70010095D655 /* LatestTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B44033DC2BCC36C300162242 /* LatestTransaction.swift */; };
|
||||
B4EFF7482C3F70090095D655 /* BitcoinUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B44033BE2BCC32F800162242 /* BitcoinUnit.swift */; };
|
||||
C59F90CE0D04D3E4BB39BC5D /* libPods-BlueWalletUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F02C2F7CA3591E4E0B06EBA /* libPods-BlueWalletUITests.a */; };
|
||||
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */ = {isa = PBXBuildFile; };
|
||||
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -497,7 +497,7 @@
|
||||
files = (
|
||||
782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */,
|
||||
764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */,
|
||||
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */,
|
||||
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */,
|
||||
773E382FE62E836172AAB98B /* libPods-BlueWallet.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -517,7 +517,7 @@ PODS:
|
||||
- RNWatch (1.1.0):
|
||||
- React
|
||||
- SocketRocket (0.6.1)
|
||||
- TrueSheet (0.12.2):
|
||||
- TrueSheet (0.12.4):
|
||||
- RCT-Folly (= 2021.07.22.00)
|
||||
- React-Core
|
||||
- Yoga (1.14.0)
|
||||
@ -860,7 +860,7 @@ SPEC CHECKSUMS:
|
||||
RNVectorIcons: 32462e7c7e58fe457474fc79c4d7de3f0ef08d70
|
||||
RNWatch: fd30ca40a5b5ef58dcbc195638e68219bc455236
|
||||
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
||||
TrueSheet: 8235baf14119d4f9d8a904ed1de26111f73b733c
|
||||
TrueSheet: 3ba036b4f20ea78a2953fcf7949e8a60dd63d3f6
|
||||
Yoga: c32e0be1a17f8f1f0e633a3122f7666441f52c82
|
||||
|
||||
PODFILE CHECKSUM: f19eea438501edfe85fb2fa51d40ba1b57540758
|
||||
|
21584
package-lock.json
generated
21584
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -98,7 +98,7 @@
|
||||
"@bugsnag/react-native": "7.25.0",
|
||||
"@bugsnag/source-maps": "2.3.3",
|
||||
"@keystonehq/bc-ur-registry": "0.6.4",
|
||||
"@lodev09/react-native-true-sheet": "github:BlueWallet/react-native-true-sheet#ecc83c0",
|
||||
"@lodev09/react-native-true-sheet": "github:BlueWallet/react-native-true-sheet#fbcb1af",
|
||||
"@ngraveio/bc-ur": "1.1.12",
|
||||
"@noble/secp256k1": "1.6.3",
|
||||
"@react-native-async-storage/async-storage": "1.24.0",
|
||||
|
@ -112,7 +112,7 @@ const SendDetails = () => {
|
||||
const [dumb, setDumb] = useState(false);
|
||||
const { isEditable } = routeParams;
|
||||
// if utxo is limited we use it to calculate available balance
|
||||
const balance: number = utxo ? utxo.reduce((prev, curr) => prev + curr.value, 0) : wallet?.getBalance() ?? 0;
|
||||
const balance: number = utxo ? utxo.reduce((prev, curr) => prev + curr.value, 0) : (wallet?.getBalance() ?? 0);
|
||||
const allBalance = formatBalanceWithoutSuffix(balance, BitcoinUnit.BTC, true);
|
||||
|
||||
// if cutomFee is not set, we need to choose highest possible fee for wallet balance
|
||||
@ -388,6 +388,10 @@ const SendDetails = () => {
|
||||
useCallback(() => {
|
||||
setIsLoading(false);
|
||||
setDumb(v => !v);
|
||||
return () => {
|
||||
feeModalRef.current?.dismiss();
|
||||
optionsModalRef.current?.dismiss();
|
||||
};
|
||||
}, []),
|
||||
);
|
||||
|
||||
@ -922,7 +926,7 @@ const SendDetails = () => {
|
||||
setIsLoading(true);
|
||||
await new Promise(resolve => setTimeout(resolve, 100)); // sleep for animations
|
||||
|
||||
const scannedData = await scanQrHelper(name, true, undefined, navigation.navigate);
|
||||
const scannedData = await scanQrHelper(name, true, undefined);
|
||||
if (!scannedData) return setIsLoading(false);
|
||||
|
||||
let tx;
|
||||
|
@ -60,7 +60,7 @@ const PsbtMultisigQRCode = () => {
|
||||
};
|
||||
|
||||
const openScanner = async () => {
|
||||
const scanned = await scanQrHelper(name, true, undefined, navigate);
|
||||
const scanned = await scanQrHelper(name, true, undefined);
|
||||
onBarScanned({ data: scanned });
|
||||
};
|
||||
|
||||
|
@ -143,7 +143,7 @@ const TransactionDetails = () => {
|
||||
// okay, this txid _was_ with someone using payment codes, so we show the label edit dialog
|
||||
// and load user-defined alias for the pc if any
|
||||
|
||||
setCounterpartyLabel(counterpartyMetadata ? counterpartyMetadata[foundPaymentCode]?.label ?? '' : '');
|
||||
setCounterpartyLabel(counterpartyMetadata ? (counterpartyMetadata[foundPaymentCode]?.label ?? '') : '');
|
||||
setIsCounterpartyLabelVisible(true);
|
||||
setPaymentCode(foundPaymentCode);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ const ViewEditMultisigCosigners: React.FC = () => {
|
||||
|
||||
const scanOrOpenFile = async () => {
|
||||
await provideMnemonicsModalRef.current?.dismiss();
|
||||
const scanned = await scanQrHelper(route.name, true, undefined, navigate);
|
||||
const scanned = await scanQrHelper(route.name, true, undefined);
|
||||
setImportText(String(scanned));
|
||||
provideMnemonicsModalRef.current?.present();
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
|
||||
import { useFocusEffect, useRoute } from '@react-navigation/native';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
FlatList,
|
||||
@ -37,6 +37,7 @@ import loc from '../../loc';
|
||||
import { useStorage } from '../../hooks/context/useStorage';
|
||||
import { useSettings } from '../../hooks/context/useSettings';
|
||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||
|
||||
const staticCache = {};
|
||||
|
||||
@ -45,7 +46,7 @@ const WalletsAddMultisigStep2 = () => {
|
||||
const { isAdvancedModeEnabled } = useSettings();
|
||||
const { colors } = useTheme();
|
||||
|
||||
const { navigate } = useNavigation();
|
||||
const { navigate, navigateToWalletsList } = useExtendedNavigation();
|
||||
const { m, n, format, walletLabel } = useRoute().params;
|
||||
const { name } = useRoute();
|
||||
|
||||
@ -87,15 +88,20 @@ const WalletsAddMultisigStep2 = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentSharedCosigner]);
|
||||
|
||||
const handleOnHelpPress = () => {
|
||||
dismissAllModals();
|
||||
const handleOnHelpPress = async () => {
|
||||
await dismissAllModals();
|
||||
navigate('WalletsAddMultisigHelp');
|
||||
};
|
||||
|
||||
const dismissAllModals = () => {
|
||||
mnemonicsModalRef.current?.dismiss();
|
||||
provideMnemonicsModalRef.current?.dismiss();
|
||||
renderCosignersXpubModalRef.current?.dismiss();
|
||||
const dismissAllModals = async () => {
|
||||
try {
|
||||
await mnemonicsModalRef.current?.dismiss();
|
||||
await provideMnemonicsModalRef.current?.dismiss();
|
||||
await renderCosignersXpubModalRef.current?.dismiss();
|
||||
} catch (e) {
|
||||
// in rare occasions trying to dismiss non visible modals can error out
|
||||
console.debug('dismissAllModals error', e);
|
||||
}
|
||||
};
|
||||
|
||||
const stylesHook = StyleSheet.create({
|
||||
@ -174,8 +180,8 @@ const WalletsAddMultisigStep2 = () => {
|
||||
await saveToDisk();
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
||||
dismissAllModals();
|
||||
navigate('WalletsList');
|
||||
await dismissAllModals();
|
||||
navigateToWalletsList();
|
||||
};
|
||||
|
||||
const generateNewKey = () => {
|
||||
@ -467,7 +473,7 @@ const WalletsAddMultisigStep2 = () => {
|
||||
|
||||
const scanOrOpenFile = async () => {
|
||||
await provideMnemonicsModalRef.current.dismiss();
|
||||
const scanned = await scanQrHelper(name, true, undefined, navigate);
|
||||
const scanned = await scanQrHelper(name, true, undefined);
|
||||
onBarScanned({ data: scanned });
|
||||
};
|
||||
|
||||
@ -763,12 +769,12 @@ const styles = StyleSheet.create({
|
||||
paddingHorizontal: 22,
|
||||
paddingVertical: 32,
|
||||
justifyContent: 'center',
|
||||
minHeight: 400,
|
||||
minHeight: 450,
|
||||
},
|
||||
newKeyModalContent: {
|
||||
paddingHorizontal: 22,
|
||||
justifyContent: 'center',
|
||||
minHeight: 400,
|
||||
minHeight: 450,
|
||||
},
|
||||
modalFooterBottomPadding: { paddingBottom: 26 },
|
||||
vaultKeyCircleSuccess: {
|
||||
|
Loading…
Reference in New Issue
Block a user