1
0
Fork 0
mirror of https://github.com/BlueWallet/BlueWallet.git synced 2025-03-24 07:09:14 +01:00

ref: navigation to TS ()

This commit is contained in:
abhiShandy 2024-02-24 06:27:17 -05:00 committed by GitHub
parent d8084d4b82
commit 66116fc4e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 225 additions and 267 deletions

View file

@ -1,91 +1,91 @@
import React, { useCallback, useMemo } from 'react';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { Platform, useWindowDimensions, Dimensions, I18nManager } from 'react-native';
import { DrawerNavigationOptions, createDrawerNavigator } from '@react-navigation/drawer';
import { NativeStackNavigationOptions, createNativeStackNavigator } from '@react-navigation/native-stack';
import React, { useMemo } from 'react';
import { Dimensions, I18nManager, Platform, useWindowDimensions } from 'react-native';
import PlausibleDeniability from './screen/PlausibleDeniability';
import Selftest from './screen/selftest';
import Currency from './screen/settings/Currency';
import GeneralSettings from './screen/settings/GeneralSettings';
import Licensing from './screen/settings/Licensing';
import NetworkSettings from './screen/settings/NetworkSettings';
import Settings from './screen/settings/Settings';
import About from './screen/settings/about';
import ReleaseNotes from './screen/settings/releasenotes';
import Licensing from './screen/settings/Licensing';
import Selftest from './screen/selftest';
import Language from './screen/settings/language';
import Currency from './screen/settings/Currency';
import EncryptStorage from './screen/settings/encryptStorage';
import PlausibleDeniability from './screen/PlausibleDeniability';
import LightningSettings from './screen/settings/lightningSettings';
import ElectrumSettings from './screen/settings/electrumSettings';
import Tools from './screen/settings/tools';
import GeneralSettings from './screen/settings/GeneralSettings';
import NetworkSettings from './screen/settings/NetworkSettings';
import NotificationSettings from './screen/settings/notificationSettings';
import DefaultView from './screen/settings/defaultView';
import ElectrumSettings from './screen/settings/electrumSettings';
import EncryptStorage from './screen/settings/encryptStorage';
import Language from './screen/settings/language';
import LightningSettings from './screen/settings/lightningSettings';
import NotificationSettings from './screen/settings/notificationSettings';
import ReleaseNotes from './screen/settings/releasenotes';
import Tools from './screen/settings/tools';
import WalletsList from './screen/wallets/list';
import WalletTransactions from './screen/wallets/transactions';
import AddWallet from './screen/wallets/add';
import WalletsAddMultisig from './screen/wallets/addMultisig';
import WalletsAddMultisigStep2 from './screen/wallets/addMultisigStep2';
import WalletsAddMultisigHelp, { WalletAddMultisigHelpNavigationOptions } from './screen/wallets/addMultisigHelp';
import PleaseBackup from './screen/wallets/pleaseBackup';
import PleaseBackupLNDHub from './screen/wallets/pleaseBackupLNDHub';
import PleaseBackupLdk from './screen/wallets/pleaseBackupLdk';
import ImportWallet from './screen/wallets/import';
import ImportWalletDiscovery from './screen/wallets/importDiscovery';
import ImportCustomDerivationPath from './screen/wallets/importCustomDerivationPath';
import ImportSpeed from './screen/wallets/importSpeed';
import WalletsAddMultisigStep2 from './screen/wallets/addMultisigStep2';
import WalletAddresses from './screen/wallets/addresses';
import WalletDetails from './screen/wallets/details';
import WalletExport from './screen/wallets/export';
import ExportMultisigCoordinationSetup from './screen/wallets/exportMultisigCoordinationSetup';
import ViewEditMultisigCosigners from './screen/wallets/viewEditMultisigCosigners';
import WalletXpub from './screen/wallets/xpub';
import SignVerify from './screen/wallets/signVerify';
import WalletAddresses from './screen/wallets/addresses';
import GenerateWord from './screen/wallets/generateWord';
import ImportWallet from './screen/wallets/import';
import ImportCustomDerivationPath from './screen/wallets/importCustomDerivationPath';
import ImportWalletDiscovery from './screen/wallets/importDiscovery';
import ImportSpeed from './screen/wallets/importSpeed';
import WalletsList from './screen/wallets/list';
import PleaseBackup from './screen/wallets/pleaseBackup';
import PleaseBackupLNDHub from './screen/wallets/pleaseBackupLNDHub';
import PleaseBackupLdk from './screen/wallets/pleaseBackupLdk';
import ProvideEntropy from './screen/wallets/provideEntropy';
import ReorderWallets from './screen/wallets/reorderWallets';
import SelectWallet from './screen/wallets/selectWallet';
import ProvideEntropy from './screen/wallets/provideEntropy';
import GenerateWord from './screen/wallets/generateWord';
import SignVerify from './screen/wallets/signVerify';
import WalletTransactions from './screen/wallets/transactions';
import ViewEditMultisigCosigners from './screen/wallets/viewEditMultisigCosigners';
import WalletXpub from './screen/wallets/xpub';
import TransactionDetails from './screen/transactions/details';
import TransactionStatus from './screen/transactions/transactionStatus';
import CPFP from './screen/transactions/CPFP';
import RBFBumpFee from './screen/transactions/RBFBumpFee';
import RBFCancel from './screen/transactions/RBFCancel';
import TransactionDetails from './screen/transactions/details';
import TransactionStatus from './screen/transactions/transactionStatus';
import ReceiveDetails from './screen/receive/details';
import AztecoRedeem from './screen/receive/aztecoRedeem';
import ReceiveDetails from './screen/receive/details';
import SendDetails from './screen/send/details';
import ScanQRCode from './screen/send/ScanQRCode';
import SendCreate from './screen/send/create';
import Broadcast from './screen/send/broadcast';
import CoinControl from './screen/send/coinControl';
import Confirm from './screen/send/confirm';
import PsbtWithHardwareWallet from './screen/send/psbtWithHardwareWallet';
import SendCreate from './screen/send/create';
import SendDetails from './screen/send/details';
import IsItMyAddress from './screen/send/isItMyAddress';
import PsbtMultisig from './screen/send/psbtMultisig';
import PsbtMultisigQRCode from './screen/send/psbtMultisigQRCode';
import PsbtWithHardwareWallet from './screen/send/psbtWithHardwareWallet';
import Success from './screen/send/success';
import Broadcast from './screen/send/broadcast';
import IsItMyAddress from './screen/send/isItMyAddress';
import CoinControl from './screen/send/coinControl';
import ScanLndInvoice from './screen/lnd/scanLndInvoice';
import UnlockWith from './UnlockWith';
import { isDesktop, isHandset, isTablet } from './blue_modules/environment';
import { useTheme } from './components/themes';
import loc from './loc';
import LappBrowser from './screen/lnd/browser';
import LNDCreateInvoice from './screen/lnd/lndCreateInvoice';
import LNDViewInvoice from './screen/lnd/lndViewInvoice';
import LdkOpenChannel from './screen/lnd/ldkOpenChannel';
import LdkInfo from './screen/lnd/ldkInfo';
import LdkOpenChannel from './screen/lnd/ldkOpenChannel';
import LNDCreateInvoice from './screen/lnd/lndCreateInvoice';
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';
import LnurlAuth from './screen/lnd/lnurlAuth';
import UnlockWith from './UnlockWith';
import DrawerList from './screen/wallets/drawerList';
import { isDesktop, isTablet, isHandset } from './blue_modules/environment';
import ScanLndInvoice from './screen/lnd/scanLndInvoice';
import SettingsPrivacy from './screen/settings/SettingsPrivacy';
import LNDViewAdditionalInvoicePreImage from './screen/lnd/lndViewAdditionalInvoicePreImage';
import DrawerList from './screen/wallets/drawerList';
import LdkViewLogs from './screen/wallets/ldkViewLogs';
import PaymentCode from './screen/wallets/paymentCode';
import PaymentCodesList from './screen/wallets/paymentCodesList';
import loc from './loc';
import { useTheme } from './components/themes';
const WalletsStack = createNativeStackNavigator();
@ -107,15 +107,15 @@ const WalletsRoot = () => {
<WalletsStack.Screen name="RBFCancel" component={RBFCancel} options={RBFCancel.navigationOptions(theme)} />
<WalletsStack.Screen name="Settings" component={Settings} options={Settings.navigationOptions(theme)} />
<WalletsStack.Screen name="SelectWallet" component={SelectWallet} options={SelectWallet.navigationOptions(theme)} />
<WalletsStack.Screen name="Currency" component={Currency} options={Currency.navigationOptions(theme)} />
<WalletsStack.Screen name="Currency" component={Currency} options={{ title: loc.settings.currency }} />
<WalletsStack.Screen name="About" component={About} options={About.navigationOptions(theme)} />
<WalletsStack.Screen name="ReleaseNotes" component={ReleaseNotes} options={ReleaseNotes.navigationOptions(theme)} />
<WalletsStack.Screen name="Selftest" component={Selftest} options={Selftest.navigationOptions(theme)} />
<WalletsStack.Screen name="Licensing" component={Licensing} options={Licensing.navigationOptions(theme)} />
<WalletsStack.Screen name="DefaultView" component={DefaultView} options={DefaultView.navigationOptions(theme)} />
<WalletsStack.Screen name="Language" component={Language} options={Language.navigationOptions(theme)} />
<WalletsStack.Screen name="Language" component={Language} options={{ title: loc.settings.language }} />
<WalletsStack.Screen name="EncryptStorage" component={EncryptStorage} options={EncryptStorage.navigationOptions(theme)} />
<WalletsStack.Screen name="GeneralSettings" component={GeneralSettings} options={GeneralSettings.navigationOptions(theme)} />
<WalletsStack.Screen name="GeneralSettings" component={GeneralSettings} options={{ title: loc.settings.general }} />
<WalletsStack.Screen name="NetworkSettings" component={NetworkSettings} options={NetworkSettings.navigationOptions(theme)} />
<WalletsStack.Screen
name="NotificationSettings"
@ -125,7 +125,7 @@ const WalletsRoot = () => {
<WalletsStack.Screen
name="PlausibleDeniability"
component={PlausibleDeniability}
options={PlausibleDeniability.navigationOptions(theme)}
options={{ title: loc.plausibledeniability.title }}
/>
<WalletsStack.Screen name="LightningSettings" component={LightningSettings} options={LightningSettings.navigationOptions(theme)} />
<WalletsStack.Screen name="ElectrumSettings" component={ElectrumSettings} options={ElectrumSettings.navigationOptions(theme)} />
@ -167,7 +167,11 @@ const AddWalletRoot = () => {
return (
<AddWalletStack.Navigator screenOptions={{ headerShadowVisible: false }}>
<AddWalletStack.Screen name="AddWallet" component={AddWallet} options={AddWallet.navigationOptions(theme)} />
<AddWalletStack.Screen
name="AddWallet"
component={AddWallet}
options={{ headerBackButtonMenuEnabled: true, headerBackVisible: false, title: loc.wallets.add_title }}
/>
<AddWalletStack.Screen name="ImportWallet" component={ImportWallet} options={ImportWallet.navigationOptions(theme)} />
<AddWalletStack.Screen
name="ImportWalletDiscovery"
@ -180,7 +184,11 @@ const AddWalletRoot = () => {
options={ImportCustomDerivationPath.navigationOptions(theme)}
/>
<AddWalletStack.Screen name="ImportSpeed" component={ImportSpeed} options={ImportSpeed.navigationOptions(theme)} />
<AddWalletStack.Screen name="PleaseBackup" component={PleaseBackup} options={PleaseBackup.navigationOptions(theme)} />
<AddWalletStack.Screen
name="PleaseBackup"
component={PleaseBackup}
options={{ gestureEnabled: false, headerBackVisible: false, title: loc.pleasebackup.title }}
/>
<AddWalletStack.Screen
name="PleaseBackupLNDHub"
component={PleaseBackupLNDHub}
@ -301,7 +309,7 @@ const LDKOpenChannelRoot = () => {
const theme = useTheme();
return (
<LDKOpenChannelStack.Navigator name="LDKOpenChannelRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="SelectWallet">
<LDKOpenChannelStack.Navigator id="LDKOpenChannelRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="SelectWallet">
<LDKOpenChannelStack.Screen name="SelectWallet" component={SelectWallet} options={SelectWallet.navigationOptions(theme)} />
<LDKOpenChannelStack.Screen
name="LDKOpenChannelSetAmount"
@ -329,7 +337,7 @@ const ScanQRCodeStack = createNativeStackNavigator();
const ScanQRCodeRoot = () => (
<ScanQRCodeStack.Navigator
initialRouteName="ScanQRCode"
name="ScanQRCodeRoot"
id="ScanQRCodeRoot"
screenOptions={{ headerShown: false, presentation: 'fullScreenModal' }}
>
<ScanQRCodeStack.Screen name="ScanQRCode" component={ScanQRCode} initialParams={ScanQRCode.initialParams} />
@ -338,7 +346,7 @@ const ScanQRCodeRoot = () => (
const UnlockWithScreenStack = createNativeStackNavigator();
const UnlockWithScreenRoot = () => (
<UnlockWithScreenStack.Navigator name="UnlockWithScreenRoot" screenOptions={{ headerShown: false, statusBarStyle: 'auto' }}>
<UnlockWithScreenStack.Navigator id="UnlockWithScreenRoot" screenOptions={{ headerShown: false, statusBarStyle: 'auto' }}>
<UnlockWithScreenStack.Screen name="UnlockWithScreen" component={UnlockWith} initialParams={{ unlockOnComponentMount: true }} />
</UnlockWithScreenStack.Navigator>
);
@ -348,7 +356,7 @@ const ReorderWalletsStackRoot = () => {
const theme = useTheme();
return (
<ReorderWalletsStack.Navigator name="ReorderWalletsRoot" screenOptions={{ headerShadowVisible: false }}>
<ReorderWalletsStack.Navigator id="ReorderWalletsRoot" screenOptions={{ headerShadowVisible: false }}>
<ReorderWalletsStack.Screen
name="ReorderWalletsScreen"
component={ReorderWallets}
@ -364,7 +372,7 @@ const DrawerRoot = () => {
const isLargeScreen = useMemo(() => {
return Platform.OS === 'android' ? isTablet() : (dimensions.width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop;
}, [dimensions.width]);
const drawerStyle = useMemo(
const drawerStyle: DrawerNavigationOptions = useMemo(
() => ({
drawerPosition: I18nManager.isRTL ? 'right' : 'left',
drawerStyle: { width: isLargeScreen ? 320 : '0%' },
@ -372,11 +380,14 @@ const DrawerRoot = () => {
}),
[isLargeScreen],
);
const drawerContent = useCallback(props => <DrawerList {...props} />, []);
return (
<Drawer.Navigator screenOptions={drawerStyle} drawerContent={drawerContent}>
<Drawer.Screen name="Navigation" component={Navigation} options={{ headerShown: false, gestureEnabled: false }} />
<Drawer.Navigator screenOptions={drawerStyle} drawerContent={DrawerList}>
<Drawer.Screen
name="Navigation"
component={Navigation}
options={{ headerShown: false, gestureHandlerProps: { enableTrackpadTwoFingerGesture: false } }}
/>
</Drawer.Navigator>
);
};
@ -386,11 +397,7 @@ const ReceiveDetailsStackRoot = () => {
const theme = useTheme();
return (
<ReceiveDetailsStack.Navigator
name="ReceiveDetailsRoot"
screenOptions={{ headerShadowVisible: false }}
initialRouteName="ReceiveDetails"
>
<ReceiveDetailsStack.Navigator id="ReceiveDetailsRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="ReceiveDetails">
<ReceiveDetailsStack.Screen name="ReceiveDetails" component={ReceiveDetails} options={ReceiveDetails.navigationOptions(theme)} />
</ReceiveDetailsStack.Navigator>
);
@ -398,15 +405,21 @@ const ReceiveDetailsStackRoot = () => {
const WalletXpubStack = createNativeStackNavigator();
const WalletXpubStackRoot = () => {
const theme = useTheme();
return (
<WalletXpubStack.Navigator
name="WalletXpubRoot"
id="WalletXpubRoot"
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
initialRouteName="WalletXpub"
>
<WalletXpubStack.Screen name="WalletXpub" component={WalletXpub} options={WalletXpub.navigationOptions(theme)} />
<WalletXpubStack.Screen
name="WalletXpub"
component={WalletXpub}
options={{
headerBackVisible: false,
headerBackButtonMenuEnabled: true,
headerTitle: loc.wallets.xpub_title,
}}
/>
</WalletXpubStack.Navigator>
);
};
@ -417,7 +430,7 @@ const SignVerifyStackRoot = () => {
return (
<SignVerifyStack.Navigator
name="SignVerifyRoot"
id="SignVerifyRoot"
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
initialRouteName="SignVerify"
>
@ -432,7 +445,7 @@ const WalletExportStackRoot = () => {
return (
<WalletExportStack.Navigator
name="WalletExportRoot"
id="WalletExportRoot"
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
initialRouteName="WalletExport"
>
@ -446,7 +459,7 @@ const LappBrowserStackRoot = () => {
const theme = useTheme();
return (
<LappBrowserStack.Navigator name="LappBrowserRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="LappBrowser">
<LappBrowserStack.Navigator id="LappBrowserRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="LappBrowser">
<LappBrowserStack.Screen name="LappBrowser" component={LappBrowser} options={LappBrowser.navigationOptions(theme)} />
</LappBrowserStack.Navigator>
);
@ -459,23 +472,31 @@ const InitRoot = () => (
<InitStack.Screen
name="ReorderWallets"
component={ReorderWalletsStackRoot}
options={{ headerShown: false, gestureEnabled: false, presentation: 'modal' }}
options={{
headerShown: false,
gestureEnabled: false,
presentation: 'modal',
}}
/>
<InitStack.Screen
name={isHandset ? 'Navigation' : 'DrawerRoot'}
component={isHandset ? Navigation : DrawerRoot}
options={{ headerShown: false, replaceAnimation: 'push' }}
options={{ headerShown: false, animationTypeForReplace: 'push' }}
/>
</InitStack.Navigator>
);
const ViewEditMultisigCosignersStack = createNativeStackNavigator();
export type ViewEditMultisigCosignersStackParamsList = {
ViewEditMultisigCosigners: { walletId: string };
};
const ViewEditMultisigCosignersStack = createNativeStackNavigator<ViewEditMultisigCosignersStackParamsList>();
const ViewEditMultisigCosignersRoot = () => {
const theme = useTheme();
return (
<ViewEditMultisigCosignersStack.Navigator
name="ViewEditMultisigCosignersRoot"
id="ViewEditMultisigCosignersRoot"
initialRouteName="ViewEditMultisigCosigners"
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
>
@ -494,7 +515,7 @@ const ExportMultisigCoordinationSetupRoot = () => {
return (
<ExportMultisigCoordinationSetupStack.Navigator
name="ExportMultisigCoordinationSetupRoot"
id="ExportMultisigCoordinationSetupRoot"
initialRouteName="ExportMultisigCoordinationSetup"
screenOptions={{ headerShadowVisible: false, statusBarStyle: 'light' }}
>
@ -507,10 +528,16 @@ const ExportMultisigCoordinationSetupRoot = () => {
);
};
const PaymentCodeStack = createNativeStackNavigator();
export type PaymentCodeStackParamList = {
PaymentCode: { paymentCode: string };
PaymentCodesList: { walletID: string };
};
const PaymentCodeStack = createNativeStackNavigator<PaymentCodeStackParamList>();
const PaymentCodeStackRoot = () => {
return (
<PaymentCodeStack.Navigator name="PaymentCodeRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="PaymentCode">
<PaymentCodeStack.Navigator id="PaymentCodeRoot" screenOptions={{ headerShadowVisible: false }} initialRouteName="PaymentCode">
<PaymentCodeStack.Screen name="PaymentCode" component={PaymentCode} options={{ headerTitle: loc.bip47.payment_code }} />
<PaymentCodeStack.Screen
name="PaymentCodesList"
@ -522,14 +549,17 @@ const PaymentCodeStackRoot = () => {
};
const RootStack = createNativeStackNavigator();
const NavigationDefaultOptions = { headerShown: false, presentation: 'modal' };
const NavigationFormModalOptions = { headerShown: false, presentation: 'formSheet' };
const StatusBarLightOptions = { statusBarStyle: 'light' };
const NavigationDefaultOptions: NativeStackNavigationOptions = { headerShown: false, presentation: 'modal' };
const NavigationFormModalOptions: NativeStackNavigationOptions = {
headerShown: false,
presentation: 'formSheet',
};
const StatusBarLightOptions: NativeStackNavigationOptions = { statusBarStyle: 'light' };
const Navigation = () => {
return (
<RootStack.Navigator initialRouteName="UnlockWithScreenRoot" screenOptions={{ headerHideShadow: true, statusBarStyle: 'auto' }}>
<RootStack.Navigator initialRouteName="UnlockWithScreenRoot" screenOptions={{ headerShadowVisible: false, statusBarStyle: 'auto' }}>
{/* stacks */}
<RootStack.Screen name="WalletsRoot" component={WalletsRoot} options={{ headerShown: false, translucent: false }} />
<RootStack.Screen name="WalletsRoot" component={WalletsRoot} options={{ headerShown: false, statusBarTranslucent: false }} />
<RootStack.Screen name="AddWalletRoot" component={AddWalletRoot} options={NavigationFormModalOptions} />
<RootStack.Screen name="SendDetailsRoot" component={SendDetailsRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="LNDCreateInvoiceRoot" component={LNDCreateInvoiceRoot} options={NavigationDefaultOptions} />

View file

@ -1,7 +1,8 @@
import { NativeStackNavigationOptions } from '@react-navigation/native-stack';
import React from 'react';
import { Image, Keyboard, TouchableOpacity, StyleSheet } from 'react-native';
import { Theme } from './themes';
import { Image, Keyboard, StyleSheet, TouchableOpacity } from 'react-native';
import loc from '../loc';
import { Theme } from './themes';
const styles = StyleSheet.create({
button: {
@ -12,42 +13,19 @@ const styles = StyleSheet.create({
},
});
type NavigationOptions = {
headerStyle?: {
borderBottomWidth: number;
elevation: number;
shadowOpacity?: number;
shadowOffset: { height?: number; width?: number };
};
headerTitleStyle?: {
fontWeight: string;
color: string;
};
headerLargeTitle?: boolean;
headerBackVisible?: boolean;
gestureEnabled?: boolean;
swipeEnabled?: boolean;
headerTransparent?: boolean;
headerHideBackButton?: boolean;
headerLeft?: (() => React.ReactElement) | null;
headerRight?: (() => React.ReactElement) | null;
headerBackTitleVisible?: false;
headerBackButtonMenuEnabled?: boolean;
headerShadowVisible?: boolean;
headerTintColor?: string;
title?: string;
};
type OptionsFormatter = (
options: NativeStackNavigationOptions,
deps: { theme: Theme; navigation: any; route: any },
) => NativeStackNavigationOptions;
type OptionsFormatter = (options: NavigationOptions, deps: { theme: Theme; navigation: any; route: any }) => NavigationOptions;
export type NavigationOptionsGetter = (theme: Theme) => (deps: { navigation: any; route: any }) => NavigationOptions;
export type NavigationOptionsGetter = (theme: Theme) => (deps: { navigation: any; route: any }) => NativeStackNavigationOptions;
const navigationStyle = (
{
closeButtonFunc,
headerBackVisible = true,
...opts
}: NavigationOptions & {
}: NativeStackNavigationOptions & {
closeButton?: boolean;
closeButtonFunc?: (deps: { navigation: any; route: any }) => React.ReactElement;
},
@ -89,7 +67,7 @@ const navigationStyle = (
opts.headerLeft = headerLeft;
}
let options: NavigationOptions = {
let options: NativeStackNavigationOptions = {
headerShadowVisible: false,
headerTitleStyle: {
fontWeight: '600',
@ -112,14 +90,12 @@ const navigationStyle = (
export default navigationStyle;
export const navigationStyleTx = (opts: NavigationOptions, formatter: OptionsFormatter): NavigationOptionsGetter => {
export const navigationStyleTx = (opts: NativeStackNavigationOptions, formatter: OptionsFormatter): NavigationOptionsGetter => {
return theme =>
({ navigation, route }) => {
let options: NavigationOptions = {
let options: NativeStackNavigationOptions = {
headerStyle: {
borderBottomWidth: 0,
elevation: 0,
shadowOffset: { height: 0, width: 0 },
backgroundColor: theme.colors.customHeader,
},
headerTitleStyle: {
fontWeight: '600',

View file

@ -1,15 +1,14 @@
import { useNavigation } from '@react-navigation/native';
import React, { useContext, useReducer } from 'react';
import { ScrollView } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import navigationStyle from '../components/navigationStyle';
import { BlueLoading, BlueCard, BlueText, BlueSpacing20 } from '../BlueComponents';
import loc from '../loc';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { BlueCard, BlueLoading, BlueSpacing20, BlueText } from '../BlueComponents';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
import { BlueStorageContext } from '../blue_modules/storage-context';
import presentAlert from '../components/Alert';
import Button from '../components/Button';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import loc from '../loc';
const prompt = require('../helpers/prompt');
// Action Types
@ -96,8 +95,3 @@ const PlausibleDeniability: React.FC = () => {
};
export default PlausibleDeniability;
// @ts-ignore: Fix later
PlausibleDeniability.navigationOptions = navigationStyle({
title: loc.plausibledeniability.title,
});

View file

@ -1,15 +1,8 @@
import React, { useState, useContext, useLayoutEffect } from 'react';
import { FlatList, StyleSheet, View, NativeSyntheticEvent } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import navigationStyle from '../../components/navigationStyle';
import { BlueText, BlueCard, BlueSpacing10 } from '../../BlueComponents';
import { FiatUnit, FiatUnitSource, FiatUnitType, getFiatRate } from '../../models/fiatUnit';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import dayjs from 'dayjs';
import presentAlert from '../../components/Alert';
import { useTheme } from '../../components/themes';
import ListItem from '../../components/ListItem';
import React, { useContext, useLayoutEffect, useState } from 'react';
import { FlatList, NativeSyntheticEvent, StyleSheet, View } from 'react-native';
import { BlueCard, BlueSpacing10, BlueText } from '../../BlueComponents';
import {
CurrencyRate,
getPreferredCurrency,
@ -17,11 +10,17 @@ import {
mostRecentFetchedRate,
setPreferredCurrency,
} from '../../blue_modules/currency';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import presentAlert from '../../components/Alert';
import ListItem from '../../components/ListItem';
import { useTheme } from '../../components/themes';
import loc from '../../loc';
import { FiatUnit, FiatUnitSource, FiatUnitType, getFiatRate } from '../../models/fiatUnit';
dayjs.extend(require('dayjs/plugin/calendar'));
const ITEM_HEIGHT = 50;
const Currency: React.FC = () => {
const Currency = () => {
const { setPreferredFiatCurrency } = useContext(BlueStorageContext);
const [isSavingNewPreferredCurrency, setIsSavingNewPreferredCurrency] = useState(false);
const [selectedCurrency, setSelectedCurrency] = useState<FiatUnitType>(FiatUnit.USD);
@ -126,7 +125,4 @@ const Currency: React.FC = () => {
);
};
/* @ts-ignore TODO: fix typescript error later */
Currency.navigationOptions = navigationStyle({}, (opts: any) => ({ ...opts, title: loc.settings.currency }));
export default Currency;

View file

@ -1,14 +1,13 @@
import React, { useContext, useEffect, useState } from 'react';
import { ScrollView, Platform, StyleSheet } from 'react-native';
import { Platform, ScrollView, StyleSheet } from 'react-native';
import navigationStyle from '../../components/navigationStyle';
import { BlueLoading, BlueText, BlueSpacing20, BlueCard } from '../../BlueComponents';
import { useNavigation } from '@react-navigation/native';
import loc from '../../loc';
import { BlueCard, BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isURv1Enabled, clearUseURv1, setUseURv1 } from '../../blue_modules/ur';
import { useTheme } from '../../components/themes';
import { clearUseURv1, isURv1Enabled, setUseURv1 } from '../../blue_modules/ur';
import ListItem, { PressableWrapper } from '../../components/ListItem';
import { useTheme } from '../../components/themes';
import loc from '../../loc';
const styles = StyleSheet.create({
root: {
@ -96,7 +95,4 @@ const GeneralSettings: React.FC = () => {
);
};
// @ts-ignore: Fix later
GeneralSettings.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.settings.general }));
export default GeneralSettings;

View file

@ -1,15 +1,15 @@
import React, { useState, useEffect, useContext } from 'react';
import { FlatList, StyleSheet } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import React, { useContext, useEffect, useState } from 'react';
import { FlatList, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import navigationStyle from '../../components/navigationStyle';
import loc, { saveLanguage } from '../../loc';
import { AvailableLanguages, TLanguage } from '../../loc/languages';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import presentAlert from '../../components/Alert';
import { useTheme } from '../../components/themes';
import ListItem from '../../components/ListItem';
import navigationStyle from '../../components/navigationStyle';
import { useTheme } from '../../components/themes';
import loc, { saveLanguage } from '../../loc';
import { AvailableLanguages, TLanguage } from '../../loc/languages';
const styles = StyleSheet.create({
flex: {
@ -17,7 +17,7 @@ const styles = StyleSheet.create({
},
});
const Language: React.FC = () => {
const Language = () => {
const { setLanguage, language } = useContext(BlueStorageContext);
const [selectedLanguage, setSelectedLanguage] = useState<string>(loc.getLanguage());
const { setOptions } = useNavigation();

View file

@ -1,47 +1,46 @@
import React, { useEffect, useContext, useReducer } from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useNavigation } from '@react-navigation/native';
import React, { useContext, useEffect, useReducer } from 'react';
import {
Text,
ScrollView,
ActivityIndicator,
Keyboard,
KeyboardAvoidingView,
Platform,
View,
TextInput,
ScrollView,
StyleSheet,
Text,
TextInput,
View,
useColorScheme,
} from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {
BlueText,
LightningButton,
BitcoinButton,
VaultButton,
BlueFormLabel,
BlueButtonLink,
BlueFormLabel,
BlueSpacing20,
BlueSpacing40,
BlueText,
LightningButton,
VaultButton,
} from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import {
AbstractWallet,
HDSegwitBech32Wallet,
SegwitP2SHWallet,
HDSegwitP2SHWallet,
LightningCustodianWallet,
LightningLdkWallet,
AbstractWallet,
SegwitP2SHWallet,
} from '../../class';
import { useNavigation } from '@react-navigation/native';
import { Chain } from '../../models/bitcoinUnits';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { LdkButton } from '../../components/LdkButton';
import presentAlert from '../../components/Alert';
import useAsyncPromise from '../../hooks/useAsyncPromise';
import { useTheme } from '../../components/themes';
import Button from '../../components/Button';
import { LdkButton } from '../../components/LdkButton';
import ListItem from '../../components/ListItem';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import { useTheme } from '../../components/themes';
import useAsyncPromise from '../../hooks/useAsyncPromise';
import loc from '../../loc';
import { Chain } from '../../models/bitcoinUnits';
const BlueApp = require('../../BlueApp');
const AppStorage = BlueApp.AppStorage;
const A = require('../../blue_modules/analytics');
@ -507,15 +506,6 @@ const WalletsAdd: React.FC = () => {
);
};
/* @ts-ignore: Return later to update */
WalletsAdd.navigationOptions = navigationStyle(
{
closeButton: true,
headerBackVisible: false,
},
opts => ({ ...opts, title: loc.wallets.add_title }),
);
const styles = StyleSheet.create({
label: {
flexDirection: 'row',

View file

@ -1,15 +1,14 @@
import { NativeStackScreenProps } from '@react-navigation/native-stack';
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { NativeStackScreenProps } from 'react-native-screens/lib/typescript/native-stack';
import { StyleSheet, Text, View } from 'react-native';
import { BlueCopyTextToClipboard } from '../../BlueComponents';
import { PaymentCodeStackParamList } from '../../Navigation';
import QRCodeComponent from '../../components/QRCodeComponent';
import loc from '../../loc';
type PaymentCodeStackParamList = {
PaymentCode: { paymentCode: string };
};
type Props = NativeStackScreenProps<PaymentCodeStackParamList, 'PaymentCode'>;
export default function PaymentCode({ route }: NativeStackScreenProps<PaymentCodeStackParamList, 'PaymentCode'>) {
export default function PaymentCode({ route }: Props) {
const { paymentCode } = route.params;
return (

View file

@ -1,21 +1,20 @@
import { NativeStackScreenProps } from '@react-navigation/native-stack';
import React, { useContext, useEffect, useState } from 'react';
import { SectionList, StyleSheet, Text, View } from 'react-native';
import { NativeStackScreenProps } from 'react-native-screens/lib/typescript/native-stack';
import { BlueCopyTextToClipboard } from '../../BlueComponents';
import { PaymentCodeStackParamList } from '../../Navigation';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { AbstractHDElectrumWallet } from '../../class/wallets/abstract-hd-electrum-wallet';
import { BlueCopyTextToClipboard } from '../../BlueComponents';
import loc from '../../loc';
type PaymentCodesListStackParamList = {
PaymentCodesList: { walletID: string };
};
interface DataSection {
title: string;
data: string[];
}
export default function PaymentCodesList({ route }: NativeStackScreenProps<PaymentCodesListStackParamList, 'PaymentCodesList'>) {
type Props = NativeStackScreenProps<PaymentCodeStackParamList, 'PaymentCodesList'>;
export default function PaymentCodesList({ route }: Props) {
const { walletID } = route.params;
const { wallets } = useContext(BlueStorageContext);
const [data, setData] = useState<DataSection[]>([]);

View file

@ -1,15 +1,14 @@
import React, { useEffect, useState, useCallback, useContext } from 'react';
import { ActivityIndicator, View, BackHandler, Text, ScrollView, StyleSheet, I18nManager } from 'react-native';
import { useNavigation, useRoute } from '@react-navigation/native';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { ActivityIndicator, BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native';
import navigationStyle from '../../components/navigationStyle';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { AbstractWallet } from '../../class';
import { useTheme } from '../../components/themes';
import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea';
import { useTheme } from '../../components/themes';
import usePrivacy from '../../hooks/usePrivacy';
import loc from '../../loc';
const PleaseBackup: React.FC = () => {
const { wallets } = useContext(BlueStorageContext);
@ -93,16 +92,6 @@ const PleaseBackup: React.FC = () => {
);
};
// @ts-ignore: Ignore
PleaseBackup.navigationOptions = navigationStyle(
{
gestureEnabled: false,
swipeEnabled: false,
headerBackVisible: false,
},
opts => ({ ...opts, title: loc.pleasebackup.title }),
);
const styles = StyleSheet.create({
loading: {
flex: 1,

View file

@ -1,4 +1,6 @@
import React, { useContext, useRef, useState, useCallback, useEffect } from 'react';
import { useFocusEffect, useNavigation } from '@react-navigation/native';
import { NativeStackScreenProps } from '@react-navigation/native-stack';
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
import {
ActivityIndicator,
Alert,
@ -14,8 +16,7 @@ import {
Text,
View,
} from 'react-native';
import { Icon, Badge } from 'react-native-elements';
import { useFocusEffect, useNavigation } from '@react-navigation/native';
import { Badge, Icon } from 'react-native-elements';
import {
BlueButtonLink,
BlueFormMultiInput,
@ -26,35 +27,33 @@ import {
BlueText,
BlueTextCentered,
} from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import { ViewEditMultisigCosignersStackParamsList } from '../../Navigation';
import * as NavigationService from '../../NavigationService';
import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../components/SquareEnumeratedWords';
import BottomModal from '../../components/BottomModal';
import { AbstractWallet, HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../class';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { encodeUR } from '../../blue_modules/ur';
import { AbstractWallet, HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../class';
import Biometric from '../../class/biometrics';
import presentAlert from '../../components/Alert';
import BottomModal from '../../components/BottomModal';
import Button from '../../components/Button';
import MultipleStepsListItem, {
MultipleStepsListItemButtohType,
MultipleStepsListItemDashType,
} from '../../components/MultipleStepsListItem';
import Biometric from '../../class/biometrics';
import { SquareButton } from '../../components/SquareButton';
import { encodeUR } from '../../blue_modules/ur';
import QRCodeComponent from '../../components/QRCodeComponent';
import presentAlert from '../../components/Alert';
import { scanQrHelper } from '../../helpers/scan-qr';
import { SquareButton } from '../../components/SquareButton';
import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../components/SquareEnumeratedWords';
import navigationStyle from '../../components/navigationStyle';
import { useTheme } from '../../components/themes';
import Button from '../../components/Button';
import { NativeStackScreenProps } from 'react-native-screens/native-stack';
import { scanQrHelper } from '../../helpers/scan-qr';
import usePrivacy from '../../hooks/usePrivacy';
import loc from '../../loc';
const fs = require('../../blue_modules/fs');
const prompt = require('../../helpers/prompt');
type StackParamsList = {
ViewEditMultisigCosigners: { walletId: string };
};
type Props = NativeStackScreenProps<ViewEditMultisigCosignersStackParamsList, 'ViewEditMultisigCosigners'>;
const ViewEditMultisigCosigners = ({ route }: NativeStackScreenProps<StackParamsList, 'ViewEditMultisigCosigners'>) => {
const ViewEditMultisigCosigners = ({ route }: Props) => {
const hasLoaded = useRef(false);
const { colors } = useTheme();
const { wallets, setWalletsWithNewOrder, isElectrumDisabled, isAdvancedModeEnabled } = useContext(BlueStorageContext);

View file

@ -1,19 +1,18 @@
import { NavigationProp, RouteProp, useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
import { InteractionManager, ActivityIndicator, View } from 'react-native';
import { useFocusEffect, useRoute, useNavigation, RouteProp, NavigationProp } from '@react-navigation/native';
import { ActivityIndicator, InteractionManager, View } from 'react-native';
import Share from 'react-native-share';
import { styles, useDynamicStyles } from './xpub.styles';
import navigationStyle from '../../components/navigationStyle';
import { BlueSpacing20, BlueText, BlueCopyTextToClipboard } from '../../BlueComponents';
import Biometric from '../../class/biometrics';
import loc from '../../loc';
import { BlueCopyTextToClipboard, BlueSpacing20, BlueText } from '../../BlueComponents';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import QRCodeComponent from '../../components/QRCodeComponent';
import HandoffComponent from '../../components/handoff';
import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea';
import { AbstractWallet } from '../../class';
import Biometric from '../../class/biometrics';
import Button from '../../components/Button';
import QRCodeComponent from '../../components/QRCodeComponent';
import SafeArea from '../../components/SafeArea';
import HandoffComponent from '../../components/handoff';
import usePrivacy from '../../hooks/usePrivacy';
import loc from '../../loc';
import { styles, useDynamicStyles } from './xpub.styles';
type WalletXpubRouteProp = RouteProp<{ params: { walletID: string; xpub: string } }, 'params'>;
export type RootStackParamList = {
@ -113,13 +112,4 @@ const WalletXpub: React.FC = () => {
);
};
// @ts-ignore: Deal with later
WalletXpub.navigationOptions = navigationStyle(
{
closeButton: true,
headerBackVisible: false,
},
opts => ({ ...opts, headerTitle: loc.wallets.xpub_title }),
);
export default WalletXpub;

View file

@ -3,7 +3,7 @@ const path = require('path');
const mainLocFile = './loc/en.json';
const dirsToInterate = ['components', 'screen', 'blue_modules', 'class'];
const addFiles = ['BlueComponents.js', 'App.js', 'BlueApp.js', 'Navigation.js'];
const addFiles = ['BlueComponents.js', 'App.js', 'BlueApp.js', 'Navigation.tsx'];
const allowedLocPrefixes = ['loc.lnurl_auth', 'loc.units'];
const allLocKeysHashmap = {}; // loc key -> used or not