mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
REF: Multisig stacks lazy
This commit is contained in:
parent
ffff3c9fd3
commit
fbfd9ed8de
@ -23,13 +23,11 @@ import ReleaseNotes from './screen/settings/releasenotes';
|
|||||||
import Tools from './screen/settings/tools';
|
import Tools from './screen/settings/tools';
|
||||||
import WalletAddresses from './screen/wallets/addresses';
|
import WalletAddresses from './screen/wallets/addresses';
|
||||||
import WalletDetails from './screen/wallets/details';
|
import WalletDetails from './screen/wallets/details';
|
||||||
import ExportMultisigCoordinationSetup from './screen/wallets/ExportMultisigCoordinationSetup';
|
|
||||||
import GenerateWord from './screen/wallets/generateWord';
|
import GenerateWord from './screen/wallets/generateWord';
|
||||||
import WalletsList from './screen/wallets/WalletsList';
|
import WalletsList from './screen/wallets/WalletsList';
|
||||||
import SelectWallet from './screen/wallets/selectWallet';
|
import SelectWallet from './screen/wallets/selectWallet';
|
||||||
import SignVerify from './screen/wallets/signVerify';
|
import SignVerify from './screen/wallets/signVerify';
|
||||||
import WalletTransactions from './screen/wallets/transactions';
|
import WalletTransactions from './screen/wallets/transactions';
|
||||||
import ViewEditMultisigCosigners from './screen/wallets/ViewEditMultisigCosigners';
|
|
||||||
|
|
||||||
import CPFP from './screen/transactions/CPFP';
|
import CPFP from './screen/transactions/CPFP';
|
||||||
import RBFBumpFee from './screen/transactions/RBFBumpFee';
|
import RBFBumpFee from './screen/transactions/RBFBumpFee';
|
||||||
@ -73,6 +71,8 @@ import { useExtendedNavigation } from './hooks/useExtendedNavigation';
|
|||||||
import ReorderWalletsStackRoot from './navigation/ReorderWalletsStack';
|
import ReorderWalletsStackRoot from './navigation/ReorderWalletsStack';
|
||||||
import WalletXpubStackRoot from './navigation/WalletXpubStack';
|
import WalletXpubStackRoot from './navigation/WalletXpubStack';
|
||||||
import ScanQRCodeStackRoot from './navigation/ScanQRCodeStack';
|
import ScanQRCodeStackRoot from './navigation/ScanQRCodeStack';
|
||||||
|
import ExportMultisigCoordinationSetupStackRoot from './navigation/ExportMultisigCoordinationSetupStack';
|
||||||
|
import ViewEditMultisigCosignersStackRoot from './navigation/ViewEditMultisigCosignersStack';
|
||||||
|
|
||||||
const LDKOpenChannelStack = createNativeStackNavigator();
|
const LDKOpenChannelStack = createNativeStackNavigator();
|
||||||
const LDKOpenChannelRoot = () => {
|
const LDKOpenChannelRoot = () => {
|
||||||
@ -361,13 +361,14 @@ const DetailViewStackScreensStack = () => {
|
|||||||
/>
|
/>
|
||||||
<DetailViewRoot.Screen
|
<DetailViewRoot.Screen
|
||||||
name="ExportMultisigCoordinationSetupRoot"
|
name="ExportMultisigCoordinationSetupRoot"
|
||||||
component={ExportMultisigCoordinationSetupRoot}
|
component={ExportMultisigCoordinationSetupStackRoot}
|
||||||
options={NavigationDefaultOptions}
|
options={NavigationDefaultOptions}
|
||||||
/>
|
/>
|
||||||
<DetailViewRoot.Screen
|
<DetailViewRoot.Screen
|
||||||
name="ViewEditMultisigCosignersRoot"
|
name="ViewEditMultisigCosignersRoot"
|
||||||
component={ViewEditMultisigCosignersRoot}
|
component={ViewEditMultisigCosignersStackRoot}
|
||||||
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions, gestureEnabled: false, fullScreenGestureEnabled: false }}
|
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions, gestureEnabled: false, fullScreenGestureEnabled: false }}
|
||||||
|
initialParams={{ walletID: undefined, cosigners: undefined }}
|
||||||
/>
|
/>
|
||||||
<DetailViewRoot.Screen
|
<DetailViewRoot.Screen
|
||||||
name="WalletXpubRoot"
|
name="WalletXpubRoot"
|
||||||
@ -421,53 +422,6 @@ const DetailViewStackScreensStack = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ViewEditMultisigCosignersStackParamsList = {
|
|
||||||
ViewEditMultisigCosigners: { walletID: string };
|
|
||||||
};
|
|
||||||
|
|
||||||
const ViewEditMultisigCosignersStack = createNativeStackNavigator<ViewEditMultisigCosignersStackParamsList>();
|
|
||||||
const ViewEditMultisigCosignersRoot = () => {
|
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ViewEditMultisigCosignersStack.Navigator
|
|
||||||
id="ViewEditMultisigCosignersRoot"
|
|
||||||
initialRouteName="ViewEditMultisigCosigners"
|
|
||||||
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
|
|
||||||
>
|
|
||||||
<ViewEditMultisigCosignersStack.Screen
|
|
||||||
name="ViewEditMultisigCosigners"
|
|
||||||
component={ViewEditMultisigCosigners}
|
|
||||||
options={ViewEditMultisigCosigners.navigationOptions(theme)}
|
|
||||||
/>
|
|
||||||
</ViewEditMultisigCosignersStack.Navigator>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ExportMultisigCoordinationSetupStack = createNativeStackNavigator();
|
|
||||||
const ExportMultisigCoordinationSetupRoot = () => {
|
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ExportMultisigCoordinationSetupStack.Navigator
|
|
||||||
id="ExportMultisigCoordinationSetupRoot"
|
|
||||||
initialRouteName="ExportMultisigCoordinationSetup"
|
|
||||||
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
|
|
||||||
>
|
|
||||||
<ExportMultisigCoordinationSetupStack.Screen
|
|
||||||
name="ExportMultisigCoordinationSetup"
|
|
||||||
component={ExportMultisigCoordinationSetup}
|
|
||||||
options={navigationStyle({
|
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
|
||||||
statusBarStyle: 'light',
|
|
||||||
title: loc.multisig.export_coordination_setup,
|
|
||||||
})(theme)}
|
|
||||||
/>
|
|
||||||
</ExportMultisigCoordinationSetupStack.Navigator>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PaymentCodeStackParamList = {
|
export type PaymentCodeStackParamList = {
|
||||||
PaymentCode: { paymentCode: string };
|
PaymentCode: { paymentCode: string };
|
||||||
PaymentCodesList: { walletID: string };
|
PaymentCodesList: { walletID: string };
|
||||||
|
@ -277,7 +277,7 @@ const ListHeaderComponent = () => <View style={cStyles.separatorStyle} />;
|
|||||||
|
|
||||||
const WalletsCarousel = forwardRef((props, ref) => {
|
const WalletsCarousel = forwardRef((props, ref) => {
|
||||||
const { preferredFiatCurrency, language } = useSettings();
|
const { preferredFiatCurrency, language } = useSettings();
|
||||||
const { horizontal, data, handleLongPress, onPress, selectedWallet } = props;
|
const { horizontal, data, handleLongPress, onPress, selectedWallet, scrollEnabled } = props;
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
({ item, index }) =>
|
({ item, index }) =>
|
||||||
item ? (
|
item ? (
|
||||||
@ -338,6 +338,7 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
|||||||
directionalLockEnabled
|
directionalLockEnabled
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
initialNumToRender={10}
|
initialNumToRender={10}
|
||||||
|
scrollEnabled={scrollEnabled}
|
||||||
ListHeaderComponent={ListHeaderComponent}
|
ListHeaderComponent={ListHeaderComponent}
|
||||||
style={{ minHeight: sliderHeight + 12 }}
|
style={{ minHeight: sliderHeight + 12 }}
|
||||||
onScrollToIndexFailed={onScrollToIndexFailed}
|
onScrollToIndexFailed={onScrollToIndexFailed}
|
||||||
|
29
navigation/ExportMultisigCoordinationSetupStack.tsx
Normal file
29
navigation/ExportMultisigCoordinationSetupStack.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
|
import { ExportMultisigCoordinationSetupComponent } from './LazyLoadExportMultisigCoordinationSetupStack';
|
||||||
|
import { useTheme } from '../components/themes';
|
||||||
|
import navigationStyle from '../components/navigationStyle';
|
||||||
|
import loc from '../loc';
|
||||||
|
|
||||||
|
const Stack = createNativeStackNavigator();
|
||||||
|
|
||||||
|
const ExportMultisigCoordinationSetupStackRoot = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
||||||
|
<Stack.Screen
|
||||||
|
name="ExportMultisigCoordinationSetup"
|
||||||
|
component={ExportMultisigCoordinationSetupComponent}
|
||||||
|
options={navigationStyle({
|
||||||
|
closeButton: true,
|
||||||
|
headerBackVisible: false,
|
||||||
|
statusBarStyle: 'light',
|
||||||
|
title: loc.multisig.export_coordination_setup,
|
||||||
|
})(theme)}
|
||||||
|
/>
|
||||||
|
</Stack.Navigator>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ExportMultisigCoordinationSetupStackRoot;
|
10
navigation/LazyLoadExportMultisigCoordinationSetupStack.tsx
Normal file
10
navigation/LazyLoadExportMultisigCoordinationSetupStack.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React, { lazy, Suspense } from 'react';
|
||||||
|
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
|
||||||
|
|
||||||
|
const ExportMultisigCoordinationSetup = lazy(() => import('../screen/wallets/ExportMultisigCoordinationSetup'));
|
||||||
|
|
||||||
|
export const ExportMultisigCoordinationSetupComponent = () => (
|
||||||
|
<Suspense fallback={<LazyLoadingIndicator />}>
|
||||||
|
<ExportMultisigCoordinationSetup />
|
||||||
|
</Suspense>
|
||||||
|
);
|
10
navigation/LazyLoadViewEditMultisigCosignersStack.tsx
Normal file
10
navigation/LazyLoadViewEditMultisigCosignersStack.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React, { lazy, Suspense } from 'react';
|
||||||
|
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
|
||||||
|
|
||||||
|
const ViewEditMultisigCosigners = lazy(() => import('../screen/wallets/ViewEditMultisigCosigners'));
|
||||||
|
|
||||||
|
export const ViewEditMultisigCosignersComponent = () => (
|
||||||
|
<Suspense fallback={<LazyLoadingIndicator />}>
|
||||||
|
<ViewEditMultisigCosigners />
|
||||||
|
</Suspense>
|
||||||
|
);
|
34
navigation/ViewEditMultisigCosignersStack.tsx
Normal file
34
navigation/ViewEditMultisigCosignersStack.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
|
import { ViewEditMultisigCosignersComponent } from './LazyLoadViewEditMultisigCosignersStack';
|
||||||
|
import { useTheme } from '../components/themes';
|
||||||
|
import navigationStyle from '../components/navigationStyle';
|
||||||
|
import loc from '../loc';
|
||||||
|
|
||||||
|
export type ViewEditMultisigCosignersStackParamList = {
|
||||||
|
ViewEditMultisigCosigners: {
|
||||||
|
walletID: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const Stack = createNativeStackNavigator<ViewEditMultisigCosignersStackParamList>();
|
||||||
|
|
||||||
|
const ViewEditMultisigCosignersStackRoot = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
||||||
|
<Stack.Screen
|
||||||
|
name="ViewEditMultisigCosigners"
|
||||||
|
component={ViewEditMultisigCosignersComponent}
|
||||||
|
options={navigationStyle({
|
||||||
|
closeButton: true,
|
||||||
|
headerBackVisible: false,
|
||||||
|
title: loc.multisig.manage_keys,
|
||||||
|
})(theme)}
|
||||||
|
/>
|
||||||
|
</Stack.Navigator>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ViewEditMultisigCosignersStackRoot;
|
@ -115,7 +115,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => {
|
|||||||
disableBlur();
|
disableBlur();
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [wallet]),
|
}, [walletID]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const exportTxtFileBeforeOnPress = async () => {
|
const exportTxtFileBeforeOnPress = async () => {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { useFocusEffect } from '@react-navigation/native';
|
import React, { useCallback, useRef, useState } from 'react';
|
||||||
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
|
||||||
import React, { useCallback, useContext, useRef, useState } from 'react';
|
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
@ -17,8 +15,8 @@ import {
|
|||||||
View,
|
View,
|
||||||
findNodeHandle,
|
findNodeHandle,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
import { useFocusEffect, useRoute } from '@react-navigation/native';
|
||||||
import { Badge, Icon } from 'react-native-elements';
|
import { Badge, Icon } from 'react-native-elements';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BlueButtonLink,
|
BlueButtonLink,
|
||||||
BlueFormMultiInput,
|
BlueFormMultiInput,
|
||||||
@ -29,9 +27,8 @@ import {
|
|||||||
BlueText,
|
BlueText,
|
||||||
BlueTextCentered,
|
BlueTextCentered,
|
||||||
} from '../../BlueComponents';
|
} from '../../BlueComponents';
|
||||||
import { ViewEditMultisigCosignersStackParamsList } from '../../Navigation';
|
|
||||||
import * as NavigationService from '../../NavigationService';
|
import * as NavigationService from '../../NavigationService';
|
||||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
import { useStorage } from '../../blue_modules/storage-context';
|
||||||
import { encodeUR } from '../../blue_modules/ur';
|
import { encodeUR } from '../../blue_modules/ur';
|
||||||
import { HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../class';
|
import { HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../class';
|
||||||
import Biometric from '../../class/biometrics';
|
import Biometric from '../../class/biometrics';
|
||||||
@ -45,7 +42,6 @@ import MultipleStepsListItem, {
|
|||||||
import QRCodeComponent from '../../components/QRCodeComponent';
|
import QRCodeComponent from '../../components/QRCodeComponent';
|
||||||
import { SquareButton } from '../../components/SquareButton';
|
import { SquareButton } from '../../components/SquareButton';
|
||||||
import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../components/SquareEnumeratedWords';
|
import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../components/SquareEnumeratedWords';
|
||||||
import navigationStyle from '../../components/navigationStyle';
|
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
import { scanQrHelper } from '../../helpers/scan-qr';
|
import { scanQrHelper } from '../../helpers/scan-qr';
|
||||||
import usePrivacy from '../../hooks/usePrivacy';
|
import usePrivacy from '../../hooks/usePrivacy';
|
||||||
@ -57,16 +53,15 @@ import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
|||||||
import prompt from '../../helpers/prompt';
|
import prompt from '../../helpers/prompt';
|
||||||
import { useSettings } from '../../components/Context/SettingsContext';
|
import { useSettings } from '../../components/Context/SettingsContext';
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<ViewEditMultisigCosignersStackParamsList, 'ViewEditMultisigCosigners'>;
|
const ViewEditMultisigCosigners: React.FC = () => {
|
||||||
|
|
||||||
const ViewEditMultisigCosigners = ({ route }: Props) => {
|
|
||||||
const hasLoaded = useRef(false);
|
const hasLoaded = useRef(false);
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { wallets, setWalletsWithNewOrder, isElectrumDisabled } = useContext(BlueStorageContext);
|
const { wallets, setWalletsWithNewOrder, isElectrumDisabled } = useStorage();
|
||||||
const { isAdvancedModeEnabled } = useSettings();
|
const { isAdvancedModeEnabled } = useSettings();
|
||||||
const { navigate, dispatch, addListener } = useExtendedNavigation();
|
const { navigate, dispatch, addListener } = useExtendedNavigation();
|
||||||
const openScannerButtonRef = useRef();
|
const openScannerButtonRef = useRef();
|
||||||
const { walletID } = route.params;
|
const route = useRoute();
|
||||||
|
const { walletID } = route.params as { walletID: string };
|
||||||
const w = useRef(wallets.find(wallet => wallet.getID() === walletID));
|
const w = useRef(wallets.find(wallet => wallet.getID() === walletID));
|
||||||
const tempWallet = useRef(new MultisigHDWallet());
|
const tempWallet = useRef(new MultisigHDWallet());
|
||||||
const [wallet, setWallet] = useState<MultisigHDWallet>();
|
const [wallet, setWallet] = useState<MultisigHDWallet>();
|
||||||
@ -122,7 +117,7 @@ const ViewEditMultisigCosigners = ({ route }: Props) => {
|
|||||||
});
|
});
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
const unsubscribe = addListener('beforeRemove', e => {
|
const unsubscribe = addListener('beforeRemove', (e: { preventDefault: () => void; data: { action: any } }) => {
|
||||||
// Check if there are unsaved changes
|
// Check if there are unsaved changes
|
||||||
if (isSaveButtonDisabled) {
|
if (isSaveButtonDisabled) {
|
||||||
// If there are no unsaved changes, let the user leave the screen
|
// If there are no unsaved changes, let the user leave the screen
|
||||||
@ -729,12 +724,4 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ViewEditMultisigCosigners.navigationOptions = navigationStyle(
|
|
||||||
{
|
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
|
||||||
},
|
|
||||||
opts => ({ ...opts, headerTitle: loc.multisig.manage_keys }),
|
|
||||||
);
|
|
||||||
|
|
||||||
export default ViewEditMultisigCosigners;
|
export default ViewEditMultisigCosigners;
|
||||||
|
Loading…
Reference in New Issue
Block a user