diff --git a/Navigation.js b/Navigation.tsx similarity index 87% rename from Navigation.js rename to Navigation.tsx index dafc09981..67aa7d835 100644 --- a/Navigation.js +++ b/Navigation.tsx @@ -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 = () => { - + - + - + { @@ -167,7 +167,11 @@ const AddWalletRoot = () => { return ( - + { options={ImportCustomDerivationPath.navigationOptions(theme)} /> - + { const theme = useTheme(); return ( - + ( @@ -338,7 +346,7 @@ const ScanQRCodeRoot = () => ( const UnlockWithScreenStack = createNativeStackNavigator(); const UnlockWithScreenRoot = () => ( - + ); @@ -348,7 +356,7 @@ const ReorderWalletsStackRoot = () => { const theme = useTheme(); return ( - + { 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 => , []); return ( - - + + ); }; @@ -386,11 +397,7 @@ const ReceiveDetailsStackRoot = () => { const theme = useTheme(); return ( - + ); @@ -398,15 +405,21 @@ const ReceiveDetailsStackRoot = () => { const WalletXpubStack = createNativeStackNavigator(); const WalletXpubStackRoot = () => { - const theme = useTheme(); - return ( - + ); }; @@ -417,7 +430,7 @@ const SignVerifyStackRoot = () => { return ( @@ -432,7 +445,7 @@ const WalletExportStackRoot = () => { return ( @@ -446,7 +459,7 @@ const LappBrowserStackRoot = () => { const theme = useTheme(); return ( - + ); @@ -459,23 +472,31 @@ const InitRoot = () => ( ); -const ViewEditMultisigCosignersStack = createNativeStackNavigator(); +export type ViewEditMultisigCosignersStackParamsList = { + ViewEditMultisigCosigners: { walletId: string }; +}; + +const ViewEditMultisigCosignersStack = createNativeStackNavigator(); const ViewEditMultisigCosignersRoot = () => { const theme = useTheme(); return ( @@ -494,7 +515,7 @@ const ExportMultisigCoordinationSetupRoot = () => { return ( @@ -507,10 +528,16 @@ const ExportMultisigCoordinationSetupRoot = () => { ); }; -const PaymentCodeStack = createNativeStackNavigator(); +export type PaymentCodeStackParamList = { + PaymentCode: { paymentCode: string }; + PaymentCodesList: { walletID: string }; +}; + +const PaymentCodeStack = createNativeStackNavigator(); + const PaymentCodeStackRoot = () => { return ( - + { }; 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 ( - + {/* stacks */} - + diff --git a/components/navigationStyle.tsx b/components/navigationStyle.tsx index a8f1f5b70..dc42307a3 100644 --- a/components/navigationStyle.tsx +++ b/components/navigationStyle.tsx @@ -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', diff --git a/screen/PlausibleDeniability.tsx b/screen/PlausibleDeniability.tsx index 5d3b7b41f..d2ed2591f 100644 --- a/screen/PlausibleDeniability.tsx +++ b/screen/PlausibleDeniability.tsx @@ -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, -}); diff --git a/screen/settings/Currency.tsx b/screen/settings/Currency.tsx index 429a66bd7..b267ebaa2 100644 --- a/screen/settings/Currency.tsx +++ b/screen/settings/Currency.tsx @@ -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(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; diff --git a/screen/settings/GeneralSettings.tsx b/screen/settings/GeneralSettings.tsx index 0679e92d7..af7b8dfde 100644 --- a/screen/settings/GeneralSettings.tsx +++ b/screen/settings/GeneralSettings.tsx @@ -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; diff --git a/screen/settings/language.tsx b/screen/settings/language.tsx index fcb31e56f..0d75ac89d 100644 --- a/screen/settings/language.tsx +++ b/screen/settings/language.tsx @@ -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(loc.getLanguage()); const { setOptions } = useNavigation(); diff --git a/screen/wallets/add.tsx b/screen/wallets/add.tsx index e88d6a8ab..f8f8fec7c 100644 --- a/screen/wallets/add.tsx +++ b/screen/wallets/add.tsx @@ -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', diff --git a/screen/wallets/paymentCode.tsx b/screen/wallets/paymentCode.tsx index 9c0c5384a..e97dc54d7 100644 --- a/screen/wallets/paymentCode.tsx +++ b/screen/wallets/paymentCode.tsx @@ -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; -export default function PaymentCode({ route }: NativeStackScreenProps) { +export default function PaymentCode({ route }: Props) { const { paymentCode } = route.params; return ( diff --git a/screen/wallets/paymentCodesList.tsx b/screen/wallets/paymentCodesList.tsx index 2e757c588..e24fbab4d 100644 --- a/screen/wallets/paymentCodesList.tsx +++ b/screen/wallets/paymentCodesList.tsx @@ -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) { +type Props = NativeStackScreenProps; + +export default function PaymentCodesList({ route }: Props) { const { walletID } = route.params; const { wallets } = useContext(BlueStorageContext); const [data, setData] = useState([]); diff --git a/screen/wallets/pleaseBackup.tsx b/screen/wallets/pleaseBackup.tsx index 7e1642be4..67eacaf95 100644 --- a/screen/wallets/pleaseBackup.tsx +++ b/screen/wallets/pleaseBackup.tsx @@ -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, diff --git a/screen/wallets/viewEditMultisigCosigners.tsx b/screen/wallets/viewEditMultisigCosigners.tsx index 861b694b4..1292398a0 100644 --- a/screen/wallets/viewEditMultisigCosigners.tsx +++ b/screen/wallets/viewEditMultisigCosigners.tsx @@ -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; -const ViewEditMultisigCosigners = ({ route }: NativeStackScreenProps) => { +const ViewEditMultisigCosigners = ({ route }: Props) => { const hasLoaded = useRef(false); const { colors } = useTheme(); const { wallets, setWalletsWithNewOrder, isElectrumDisabled, isAdvancedModeEnabled } = useContext(BlueStorageContext); diff --git a/screen/wallets/xpub.tsx b/screen/wallets/xpub.tsx index b852393e0..30f41ae54 100644 --- a/screen/wallets/xpub.tsx +++ b/screen/wallets/xpub.tsx @@ -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; diff --git a/scripts/find-unused-loc.js b/scripts/find-unused-loc.js index 2c3e4c837..abf5afcd5 100644 --- a/scripts/find-unused-loc.js +++ b/scripts/find-unused-loc.js @@ -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