BlueWallet/navigation/DetailViewScreensStack.tsx

397 lines
16 KiB
TypeScript
Raw Normal View History

2024-06-13 00:12:37 +02:00
import React, { useCallback, useMemo } from 'react';
import { NativeStackNavigationOptions } from '@react-navigation/native-stack';
2024-06-13 19:26:05 +02:00
import { I18nManager, View } from 'react-native';
2024-05-12 22:37:30 +02:00
import { isDesktop } from '../blue_modules/environment';
2024-05-20 11:54:13 +02:00
import HeaderRightButton from '../components/HeaderRightButton';
import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle';
2024-05-12 22:37:30 +02:00
import { useTheme } from '../components/themes';
2024-05-20 11:54:13 +02:00
import { useExtendedNavigation } from '../hooks/useExtendedNavigation';
2024-05-12 22:37:30 +02:00
import loc from '../loc';
import LdkInfo from '../screen/lnd/ldkInfo';
import LNDViewAdditionalInvoiceInformation from '../screen/lnd/lndViewAdditionalInvoiceInformation';
import LNDViewAdditionalInvoicePreImage from '../screen/lnd/lndViewAdditionalInvoicePreImage';
import LNDViewInvoice from '../screen/lnd/lndViewInvoice';
import LnurlAuth from '../screen/lnd/lnurlAuth';
import LnurlPay from '../screen/lnd/lnurlPay';
import LnurlPaySuccess from '../screen/lnd/lnurlPaySuccess';
2024-05-20 11:54:13 +02:00
import Broadcast from '../screen/send/Broadcast';
import IsItMyAddress from '../screen/send/isItMyAddress';
import Success from '../screen/send/success';
import CPFP from '../screen/transactions/CPFP';
2024-05-27 00:10:38 +02:00
import TransactionDetails from '../screen/transactions/TransactionDetails';
2024-05-20 11:54:13 +02:00
import RBFBumpFee from '../screen/transactions/RBFBumpFee';
import RBFCancel from '../screen/transactions/RBFCancel';
import TransactionStatus from '../screen/transactions/TransactionStatus';
2024-06-07 05:35:24 +02:00
import WalletAddresses from '../screen/wallets/WalletAddresses';
2024-05-20 11:54:13 +02:00
import WalletDetails from '../screen/wallets/details';
import GenerateWord from '../screen/wallets/generateWord';
2024-05-12 22:37:30 +02:00
import LdkViewLogs from '../screen/wallets/ldkViewLogs';
2024-06-08 18:01:56 +02:00
import SelectWallet from '../screen/wallets/SelectWallet';
2024-05-20 11:54:13 +02:00
import WalletTransactions from '../screen/wallets/transactions';
import WalletsList from '../screen/wallets/WalletsList';
import { NavigationDefaultOptions, NavigationFormModalOptions, StatusBarLightOptions, DetailViewStack } from './index'; // Importing the navigator
2024-05-20 11:54:13 +02:00
import AddWalletStack from './AddWalletStack';
2024-05-12 22:37:30 +02:00
import AztecoRedeemStackRoot from './AztecoRedeemStack';
2024-05-20 11:54:13 +02:00
import ExportMultisigCoordinationSetupStackRoot from './ExportMultisigCoordinationSetupStack';
2024-05-12 22:37:30 +02:00
import {
AboutComponent,
CurrencyComponent,
DefaultViewComponent,
ElectrumSettingsComponent,
EncryptStorageComponent,
GeneralSettingsComponent,
LanguageComponent,
LicensingComponent,
LightningSettingsComponent,
NetworkSettingsComponent,
NotificationSettingsComponent,
PlausibleDeniabilityComponent,
ReleaseNotesComponent,
2024-05-25 13:44:43 +02:00
SelfTestComponent,
2024-05-12 22:37:30 +02:00
SettingsComponent,
SettingsPrivacyComponent,
ToolsComponent,
} from './LazyLoadSettingsStack';
2024-06-11 02:44:05 +02:00
import PaymentCodesListComponent from './LazyLoadPaymentCodeStack';
2024-05-20 11:54:13 +02:00
import LDKOpenChannelRoot from './LDKOpenChannelStack';
import LNDCreateInvoiceRoot from './LNDCreateInvoiceStack';
import ReceiveDetailsStackRoot from './ReceiveDetailsStack';
import ReorderWalletsStackRoot from './ReorderWalletsStack';
import ScanLndInvoiceRoot from './ScanLndInvoiceStack';
import ScanQRCodeStackRoot from './ScanQRCodeStack';
import SendDetailsStack from './SendDetailsStack';
import SignVerifyStackRoot from './SignVerifyStack';
import ViewEditMultisigCosignersStackRoot from './ViewEditMultisigCosignersStack';
import WalletExportStack from './WalletExportStack';
import WalletXpubStackRoot from './WalletXpubStack';
import PlusIcon from '../components/icons/PlusIcon';
2024-06-13 19:26:05 +02:00
import SettingsButton from '../components/icons/SettingsButton';
2024-05-12 22:37:30 +02:00
const DetailViewStackScreensStack = () => {
const theme = useTheme();
const navigation = useExtendedNavigation();
2024-06-02 21:40:34 +02:00
const SaveButton = useMemo(() => <HeaderRightButton testID="SaveButton" disabled={true} title={loc.wallets.details_save} />, []);
2024-06-02 04:57:19 +02:00
const DetailButton = useMemo(() => <HeaderRightButton testID="DetailButton" disabled={true} title={loc.send.create_details} />, []);
2024-05-12 22:37:30 +02:00
const navigateToAddWallet = useCallback(() => {
navigation.navigate('AddWalletRoot');
}, [navigation]);
2024-05-22 21:35:36 +02:00
const useWalletListScreenOptions = useMemo<NativeStackNavigationOptions>(() => {
2024-06-13 19:26:05 +02:00
const RightBarButtons = (
<>
<PlusIcon accessibilityRole="button" accessibilityLabel={loc.wallets.add_title} onPress={navigateToAddWallet} />
2024-06-13 19:39:32 +02:00
<View style={styles.width24} />
2024-06-13 19:26:05 +02:00
<SettingsButton />
</>
2024-05-12 22:37:30 +02:00
);
return {
title: loc.wallets.wallets,
2024-05-12 22:37:30 +02:00
navigationBarColor: theme.colors.navigationBarColor,
2024-05-13 19:12:37 +02:00
headerShown: !isDesktop,
headerLargeTitle: true,
2024-05-12 22:37:30 +02:00
headerStyle: {
backgroundColor: theme.colors.customHeader,
},
2024-06-13 19:26:05 +02:00
headerRight: I18nManager.isRTL ? undefined : () => RightBarButtons,
headerLeft: I18nManager.isRTL ? () => RightBarButtons : undefined,
2024-05-12 22:37:30 +02:00
};
2024-06-13 19:26:05 +02:00
}, [navigateToAddWallet, theme.colors.customHeader, theme.colors.navigationBarColor]);
2024-05-12 22:37:30 +02:00
const walletListScreenOptions = useWalletListScreenOptions;
return (
<DetailViewStack.Navigator
2024-05-12 22:37:30 +02:00
initialRouteName="WalletsList"
screenOptions={{ headerShadowVisible: false, animationTypeForReplace: 'push' }}
>
<DetailViewStack.Screen name="WalletsList" component={WalletsList} options={navigationStyle(walletListScreenOptions)(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="WalletTransactions"
component={WalletTransactions}
options={WalletTransactions.navigationOptions(theme)}
/>
<DetailViewStack.Screen
2024-05-22 21:35:36 +02:00
name="LDKOpenChannelRoot"
2024-05-12 22:37:30 +02:00
component={LDKOpenChannelRoot}
options={navigationStyle({
title: loc.lnd.new_channel,
headerLargeTitle: true,
statusBarStyle: 'auto',
closeButtonPosition: CloseButtonPosition.Right,
2024-05-12 22:37:30 +02:00
headerBackVisible: false,
gestureEnabled: false,
})(theme)}
/>
<DetailViewStack.Screen name="LdkInfo" component={LdkInfo} options={LdkInfo.navigationOptions(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="WalletDetails"
component={WalletDetails}
options={navigationStyle({
headerTitle: loc.wallets.details_title,
statusBarStyle: 'auto',
headerRight: () => SaveButton,
})(theme)}
/>
<DetailViewStack.Screen name="LdkViewLogs" component={LdkViewLogs} options={LdkViewLogs.navigationOptions(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="TransactionDetails"
component={TransactionDetails}
2024-06-02 04:57:19 +02:00
options={navigationStyle({
statusBarStyle: 'auto',
headerStyle: {
backgroundColor: theme.colors.customHeader,
},
headerTitle: loc.transactions.details_title,
headerRight: () => DetailButton,
})(theme)}
2024-05-12 22:37:30 +02:00
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="TransactionStatus"
component={TransactionStatus}
initialParams={{
hash: undefined,
walletID: undefined,
}}
options={navigationStyle({
title: '',
statusBarStyle: 'auto',
headerStyle: {
backgroundColor: theme.colors.customHeader,
},
2024-06-02 04:57:19 +02:00
headerRight: () => DetailButton,
2024-06-15 03:12:40 +02:00
headerBackTitleStyle: { fontSize: 0 },
headerBackTitleVisible: true,
2024-05-12 22:37:30 +02:00
})(theme)}
/>
<DetailViewStack.Screen name="CPFP" component={CPFP} options={CPFP.navigationOptions(theme)} />
<DetailViewStack.Screen name="RBFBumpFee" component={RBFBumpFee} options={RBFBumpFee.navigationOptions(theme)} />
<DetailViewStack.Screen name="RBFCancel" component={RBFCancel} options={RBFCancel.navigationOptions(theme)} />
2024-05-12 22:37:30 +02:00
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="SelectWallet"
component={SelectWallet}
options={navigationStyle({ title: loc.wallets.select_wallet })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LNDViewInvoice"
component={LNDViewInvoice}
options={navigationStyle({
statusBarStyle: 'auto',
headerTitle: loc.lndViewInvoice.lightning_invoice,
headerStyle: {
backgroundColor: theme.colors.customHeader,
},
})(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LNDViewAdditionalInvoiceInformation"
component={LNDViewAdditionalInvoiceInformation}
options={navigationStyle({ title: loc.lndViewInvoice.additional_info })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LNDViewAdditionalInvoicePreImage"
component={LNDViewAdditionalInvoicePreImage}
options={navigationStyle({ title: loc.lndViewInvoice.additional_info })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Broadcast"
component={Broadcast}
options={navigationStyle({ title: loc.send.create_broadcast })(theme)}
/>
<DetailViewStack.Screen name="IsItMyAddress" component={IsItMyAddress} options={IsItMyAddress.navigationOptions(theme)} />
<DetailViewStack.Screen name="GenerateWord" component={GenerateWord} options={GenerateWord.navigationOptions(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LnurlPay"
component={LnurlPay}
options={navigationStyle({
title: '',
closeButtonPosition: CloseButtonPosition.Right,
2024-05-12 22:37:30 +02:00
})(theme)}
/>
2024-06-11 02:44:05 +02:00
<DetailViewStack.Screen
name="PaymentCodeList"
component={PaymentCodesListComponent}
options={navigationStyle({ title: loc.bip47.contacts })(theme)}
/>
2024-06-07 20:50:50 +02:00
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LnurlPaySuccess"
component={LnurlPaySuccess}
options={navigationStyle({
title: '',
closeButtonPosition: CloseButtonPosition.Right,
2024-05-12 22:37:30 +02:00
headerBackVisible: false,
gestureEnabled: false,
})(theme)}
/>
<DetailViewStack.Screen name="LnurlAuth" component={LnurlAuth} options={LnurlAuth.navigationOptions(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Success"
component={Success}
options={{
headerShown: false,
gestureEnabled: false,
}}
/>
2024-06-07 05:35:24 +02:00
<DetailViewStack.Screen
name="WalletAddresses"
component={WalletAddresses}
options={navigationStyle({ title: loc.addresses.addresses_title, statusBarStyle: 'auto' })(theme)}
/>
2024-05-12 22:37:30 +02:00
<DetailViewStack.Screen name="AddWalletRoot" component={AddWalletStack} options={NavigationFormModalOptions} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="SendDetailsRoot"
component={SendDetailsStack}
options={navigationStyle({ headerShown: false, presentation: isDesktop ? 'fullScreenModal' : 'modal' })(theme)}
2024-05-12 22:37:30 +02:00
/>
<DetailViewStack.Screen name="LNDCreateInvoiceRoot" component={LNDCreateInvoiceRoot} options={NavigationDefaultOptions} />
<DetailViewStack.Screen name="ScanLndInvoiceRoot" component={ScanLndInvoiceRoot} options={NavigationDefaultOptions} />
<DetailViewStack.Screen name="AztecoRedeemRoot" component={AztecoRedeemStackRoot} options={NavigationDefaultOptions} />
2024-05-12 22:37:30 +02:00
{/* screens */}
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="WalletExportRoot"
component={WalletExportStack}
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions }}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ExportMultisigCoordinationSetupRoot"
component={ExportMultisigCoordinationSetupStackRoot}
options={NavigationDefaultOptions}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Settings"
component={SettingsComponent}
options={navigationStyle({
headerTransparent: true,
title: loc.settings.header,
// workaround to deal with the flicker when headerBackTitleVisible is false
headerBackTitleStyle: { fontSize: 0 },
headerBackTitleVisible: true,
2024-05-12 22:37:30 +02:00
headerShadowVisible: false,
2024-06-15 03:13:54 +02:00
headerLargeTitle: true,
2024-05-12 22:37:30 +02:00
animationTypeForReplace: 'push',
})(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Currency"
component={CurrencyComponent}
options={navigationStyle({ title: loc.settings.currency })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="GeneralSettings"
component={GeneralSettingsComponent}
options={navigationStyle({ title: loc.settings.general })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="PlausibleDeniability"
component={PlausibleDeniabilityComponent}
options={navigationStyle({ title: loc.plausibledeniability.title })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Licensing"
component={LicensingComponent}
options={navigationStyle({ title: loc.settings.license })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="NetworkSettings"
component={NetworkSettingsComponent}
options={navigationStyle({ title: loc.settings.network })(theme)}
/>
<DetailViewStack.Screen name="About" component={AboutComponent} options={navigationStyle({ title: loc.settings.about })(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="DefaultView"
component={DefaultViewComponent}
options={navigationStyle({ title: loc.settings.default_title })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ElectrumSettings"
component={ElectrumSettingsComponent}
options={navigationStyle({ title: loc.settings.electrum_settings_server })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="EncryptStorage"
component={EncryptStorageComponent}
options={navigationStyle({ title: loc.settings.encrypt_title })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="Language"
component={LanguageComponent}
options={navigationStyle({ title: loc.settings.language })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="LightningSettings"
component={LightningSettingsComponent}
options={navigationStyle({ title: loc.settings.lightning_settings })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="NotificationSettings"
component={NotificationSettingsComponent}
options={navigationStyle({ title: loc.settings.notifications })(theme)}
/>
<DetailViewStack.Screen
2024-05-25 13:44:43 +02:00
name="SelfTest"
component={SelfTestComponent}
2024-05-12 22:37:30 +02:00
options={navigationStyle({ title: loc.settings.selfTest })(theme)}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ReleaseNotes"
component={ReleaseNotesComponent}
options={navigationStyle({ title: loc.settings.about_release_notes })(theme)}
/>
<DetailViewStack.Screen name="Tools" component={ToolsComponent} options={navigationStyle({ title: loc.settings.tools })(theme)} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="SettingsPrivacy"
component={SettingsPrivacyComponent}
2024-06-15 03:13:54 +02:00
options={navigationStyle({ title: loc.settings.privacy })(theme)}
2024-05-12 22:37:30 +02:00
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ViewEditMultisigCosignersRoot"
component={ViewEditMultisigCosignersStackRoot}
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions, gestureEnabled: false, fullScreenGestureEnabled: false }}
initialParams={{ walletID: undefined, cosigners: undefined }}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="WalletXpubRoot"
component={WalletXpubStackRoot}
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions }}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="SignVerifyRoot"
component={SignVerifyStackRoot}
options={{ ...NavigationDefaultOptions, ...StatusBarLightOptions }}
/>
<DetailViewStack.Screen name="ReceiveDetailsRoot" component={ReceiveDetailsStackRoot} options={NavigationDefaultOptions} />
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ScanQRCodeRoot"
component={ScanQRCodeStackRoot}
options={{
headerShown: false,
presentation: 'fullScreenModal',
statusBarHidden: true,
}}
/>
<DetailViewStack.Screen
2024-05-12 22:37:30 +02:00
name="ReorderWallets"
component={ReorderWalletsStackRoot}
options={{
headerShown: false,
gestureEnabled: false,
presentation: 'modal',
}}
/>
</DetailViewStack.Navigator>
2024-05-12 22:37:30 +02:00
);
};
export default DetailViewStackScreensStack;
const styles = {
2024-06-13 19:39:32 +02:00
width24: {
width: 24,
},
};