diff --git a/App.tsx b/App.tsx index f01bf8f77..0706f852b 100644 --- a/App.tsx +++ b/App.tsx @@ -1,18 +1,177 @@ import * as React from 'react'; -import { Provider } from 'mobx-react'; +import { Observer, Provider } from 'mobx-react'; +import { GestureHandlerRootView } from 'react-native-gesture-handler'; +import { NavigationContainer } from '@react-navigation/native'; +import { createStackNavigator } from '@react-navigation/stack'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { BackHandler, NativeEventSubscription } from 'react-native'; import Stores from './stores/Stores'; -import Navigation from './Navigation'; import NavigationService from './NavigationService'; import PushNotificationManager from './PushNotificationManager'; import { AppContainer } from './components/layout/AppContainer'; import ExternalLinkModal from './components/Modals/ExternalLinkModal'; import AndroidNfcModal from './components/Modals/AndroidNfcModal'; import InfoModal from './components/Modals/InfoModal'; -import { GestureHandlerRootView } from 'react-native-gesture-handler'; + +// Views +import Transaction from './views/Transaction'; +import Wallet from './views/Wallet/Wallet'; +import Send from './views/Send'; +import LnurlPay from './views/LnurlPay/LnurlPay'; +import LnurlChannel from './views/LnurlChannel'; +import LnurlAuth from './views/LnurlAuth'; +import Receive from './views/Receive'; +import PaymentRequest from './views/PaymentRequest'; +import HandleAnythingQRScanner from './views/HandleAnythingQRScanner'; +import NodeQRScanner from './views/NodeQRScanner'; +import OpenChannel from './views/OpenChannel'; +import SendingOnChain from './views/SendingOnChain'; +import SendingLightning from './views/SendingLightning'; +import Channel from './views/Channels/Channel'; +import Payment from './views/Payment'; +import PaymentPaths from './views/PaymentPaths'; +import Invoice from './views/Invoice'; +import Sweep from './views/Sweep'; + +import SparkQRScanner from './views/SparkQRScanner'; +import NodeInfo from './views/NodeInfo'; +import NetworkInfo from './views/NetworkInfo'; +import Lockscreen from './views/Lockscreen'; +import NostrContacts from './views/NostrContacts'; +import ContactQR from './views/ContactQR'; + +// Settings views +import Settings from './views/Settings/Settings'; +import NodeConfiguration from './views/Settings/NodeConfiguration'; +import Nodes from './views/Settings/Nodes'; +import Privacy from './views/Settings/Privacy'; +import Security from './views/Settings/Security'; +import SetPassword from './views/Settings/SetPassword'; +import SetDuressPassword from './views/Settings/SetDuressPassword'; +import SetPin from './views/Settings/SetPin'; +import SetDuressPin from './views/Settings/SetDuressPin'; +import Language from './views/Settings/Language'; +import Currency from './views/Settings/Currency'; +import SelectCurrency from './views/Settings/SelectCurrency'; +import Display from './views/Settings/Display'; +import CertInstallInstructions from './views/Settings/CertInstallInstructions'; +import SignVerifyMessage from './views/Settings/SignVerifyMessage'; +import Support from './views/Settings/Support'; +import Help from './views/Settings/Help'; +import SocialMedia from './views/Settings/SocialMedia'; +import Sponsors from './views/Settings/Sponsors'; +import Olympians from './views/Settings/Olympians'; +import Gods from './views/Settings/Gods'; +import Mortals from './views/Settings/Mortals'; +import PointOfSale from './views/Settings/PointOfSale'; +import PointOfSaleRecon from './views/Settings/PointOfSaleRecon'; +import PointOfSaleReconExport from './views/Settings/PointOfSaleReconExport'; +import Categories from './views/POS/Categories'; +import ProductCategoryDetails from './views/POS/ProductCategoryDetails'; +import Products from './views/POS/Products'; +import ProductDetails from './views/POS/ProductDetails'; +import PaymentsSettings from './views/Settings/PaymentsSettings'; +import InvoicesSettings from './views/Settings/InvoicesSettings'; +import LSP from './views/Settings/LSP'; +import ChannelsSettings from './views/Settings/ChannelsSettings'; +import SetNodePicture from './views/Settings/SetNodePicture'; + +// Lightning address +import LightningAddress from './views/Settings/LightningAddress'; +import LightningAddressInfo from './views/Settings/LightningAddress/LightningAddressInfo'; +import LightningAddressSettings from './views/Settings/LightningAddress/LightningAddressSettings'; +import Attestation from './views/Settings/LightningAddress/Attestation'; +import Attestations from './views/Settings/LightningAddress/Attestations'; +import NostrKeys from './views/Settings/LightningAddress/NostrKeys'; +import NostrRelays from './views/Settings/LightningAddress/NostrRelays'; +import ChangeAddress from './views/Settings/LightningAddress/ChangeAddress'; + +//Embedded Node +import EmbeddedNode from './views/Settings/EmbeddedNode'; +import DisasterRecovery from './views/Settings/EmbeddedNode/DisasterRecovery'; +import DisasterRecoveryAdvanced from './views/Settings/EmbeddedNode/DisasterRecoveryAdvanced'; +import Pathfinding from './views/Settings/EmbeddedNode/Pathfinding'; +import ExpressGraphSync from './views/Settings/EmbeddedNode/ExpressGraphSync'; +import LNDLogs from './views/Settings/EmbeddedNode/LNDLogs'; +import Peers from './views/Settings/EmbeddedNode/Peers'; +import NeutrinoPeers from './views/Settings/EmbeddedNode/Peers/NeutrinoPeers'; +import ZeroConfPeers from './views/Settings/EmbeddedNode/Peers/ZeroConfPeers'; +import Advanced from './views/Settings/EmbeddedNode/Advanced'; + +// Routing +import Routing from './views/Routing/Routing'; +import RoutingEvent from './views/Routing/RoutingEvent'; +import SetFees from './views/Routing/SetFees'; + +// new views +import Activity from './views/Activity/Activity'; +import ActivityFilter from './views/Activity/ActivityFilter'; +import CoinControl from './views/UTXOs/CoinControl'; +import Utxo from './views/UTXOs/UTXO'; +import Accounts from './views/Accounts/Accounts'; +import ImportAccount from './views/Accounts/ImportAccount'; +import ImportingAccount from './views/Accounts/ImportingAccount'; +import BumpFee from './views/BumpFee'; +import QR from './views/QR'; +import AddNotes from './views/AddNotes'; +import Contacts from './views/Settings/Contacts'; +import AddContact from './views/Settings/AddContact'; +import ContactDetails from './views/ContactDetails'; +import CurrencyConverter from './views/Settings/CurrencyConverter'; + +// POS +import Order from './views/Order'; + +import Intro from './views/Intro'; +import IntroSplash from './views/IntroSplash'; + +import EditFee from './views/EditFee'; + +// Embedded LND +import Seed from './views/Settings/Seed'; +import SeedRecovery from './views/Settings/SeedRecovery'; +import Sync from './views/Sync'; +import LspExplanationFees from './views/Explanations/LspExplanationFees'; +import LspExplanationRouting from './views/Explanations/LspExplanationRouting'; +import LspExplanationWrappedInvoices from './views/Explanations/LspExplanationWrappedInvoices'; +import LspExplanationOverview from './views/Explanations/LspExplanationOverview'; +import RestoreChannelBackups from './views/Settings/EmbeddedNode/RestoreChannelBackups'; + +import RawTxHex from './views/RawTxHex'; + +import CustodialWalletWarning from './views/Settings/CustodialWalletWarning'; + +import PSBT from './views/PSBT'; +import TxHex from './views/TxHex'; + +import { themeColor } from './utils/ThemeUtils'; export default class App extends React.PureComponent { + private backPressListenerSubscription: NativeEventSubscription; + + private handleBackPress = (navigation: any) => { + const dialogHasBeenClosed = Stores.modalStore.closeVisibleModalDialog(); + if (dialogHasBeenClosed) { + return true; + } + + if (Stores.settingsStore.loginRequired()) { + BackHandler.exitApp(); + return true; + } + + const navigationState = navigation.getState(); + if (navigationState.routes.length > 1) { + navigation.pop(); + return true; + } + + return false; + }; + render() { + const Stack = createStackNavigator(); return ( - { - NavigationService.setTopLevelNavigator( - navigatorRef - ); - }} - /> + + + {() => ( + { + if (nav != null) { + NavigationService.setTopLevelNavigator( + nav + ); + } + }} + theme={{ + dark: true, + colors: { + background: + themeColor( + 'background' + ), + border: themeColor( + 'background' + ), + card: themeColor( + 'background' + ), + notification: + themeColor('text'), + primary: + themeColor('highlight'), + text: themeColor('text') + } + }} + > + ({ + focus: () => { + this.backPressListenerSubscription?.remove(); + this.backPressListenerSubscription = + BackHandler.addEventListener( + 'hardwareBackPress', + () => + this.handleBackPress( + navigation + ) + ); + }, + blur: () => + this.backPressListenerSubscription?.remove() + })} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )} + + diff --git a/Navigation.ts b/Navigation.ts deleted file mode 100644 index 38faa85ee..000000000 --- a/Navigation.ts +++ /dev/null @@ -1,475 +0,0 @@ -import { createAppContainer } from 'react-navigation'; -import { createStackNavigator } from 'react-navigation-stack'; - -// Views -import Transaction from './views/Transaction'; -import Wallet from './views/Wallet/Wallet'; -import Send from './views/Send'; -import LnurlPay from './views/LnurlPay/LnurlPay'; -import LnurlChannel from './views/LnurlChannel'; -import LnurlAuth from './views/LnurlAuth'; -import Receive from './views/Receive'; -import PaymentRequest from './views/PaymentRequest'; -import HandleAnythingQRScanner from './views/handleAnythingQRScanner'; -import NodeQRScanner from './views/NodeQRScanner'; -import OpenChannel from './views/OpenChannel'; -import SendingOnChain from './views/SendingOnChain'; -import SendingLightning from './views/SendingLightning'; -import Channel from './views/Channels/Channel'; -import Payment from './views/Payment'; -import PaymentPaths from './views/PaymentPaths'; -import Invoice from './views/Invoice'; -import Sweep from './views/Sweep'; - -import SparkQRScanner from './views/SparkQRScanner'; -import NodeInfo from './views/NodeInfo'; -import NetworkInfo from './views/NetworkInfo'; -import Lockscreen from './views/Lockscreen'; -import NostrContacts from './views/NostrContacts'; -import ContactQR from './views/ContactQR'; - -// Settings views -import Settings from './views/Settings/Settings'; -import NodeConfiguration from './views/Settings/NodeConfiguration'; -import Nodes from './views/Settings/Nodes'; -import Privacy from './views/Settings/Privacy'; -import Security from './views/Settings/Security'; -import SetPassword from './views/Settings/SetPassword'; -import SetDuressPassword from './views/Settings/SetDuressPassword'; -import SetPin from './views/Settings/SetPin'; -import SetDuressPin from './views/Settings/SetDuressPin'; -import Language from './views/Settings/Language'; -import Currency from './views/Settings/Currency'; -import SelectCurrency from './views/Settings/SelectCurrency'; -import Display from './views/Settings/Display'; -import CertInstallInstructions from './views/Settings/CertInstallInstructions'; -import SignVerifyMessage from './views/Settings/SignVerifyMessage'; -import Support from './views/Settings/Support'; -import Help from './views/Settings/Help'; -import SocialMedia from './views/Settings/SocialMedia'; -import Sponsors from './views/Settings/Sponsors'; -import Olympians from './views/Settings/Olympians'; -import Gods from './views/Settings/Gods'; -import Mortals from './views/Settings/Mortals'; -import PointOfSale from './views/Settings/PointOfSale'; -import PointOfSaleRecon from './views/Settings/PointOfSaleRecon'; -import PointOfSaleReconExport from './views/Settings/PointOfSaleReconExport'; -import Categories from './views/POS/Categories'; -import ProductCategoryDetails from './views/POS/ProductCategoryDetails'; -import Products from './views/POS/Products'; -import ProductDetails from './views/POS/ProductDetails'; -import PaymentsSettings from './views/Settings/PaymentsSettings'; -import InvoicesSettings from './views/Settings/InvoicesSettings'; -import LSP from './views/Settings/LSP'; -import ChannelsSettings from './views/Settings/ChannelsSettings'; -import SetNodePicture from './views/Settings/SetNodePicture'; - -// Lightning address -import LightningAddress from './views/Settings/LightningAddress'; -import LightningAddressInfo from './views/Settings/LightningAddress/LightningAddressInfo'; -import LightningAddressSettings from './views/Settings/LightningAddress/LightningAddressSettings'; -import Attestation from './views/Settings/LightningAddress/Attestation'; -import Attestations from './views/Settings/LightningAddress/Attestations'; -import NostrKeys from './views/Settings/LightningAddress/NostrKeys'; -import NostrRelays from './views/Settings/LightningAddress/NostrRelays'; -import ChangeAddress from './views/Settings/LightningAddress/ChangeAddress'; - -//Embedded Node -import EmbeddedNode from './views/Settings/EmbeddedNode'; -import DisasterRecovery from './views/Settings/EmbeddedNode/DisasterRecovery'; -import DisasterRecoveryAdvanced from './views/Settings/EmbeddedNode/DisasterRecoveryAdvanced'; -import Pathfinding from './views/Settings/EmbeddedNode/Pathfinding'; -import ExpressGraphSync from './views/Settings/EmbeddedNode/ExpressGraphSync'; -import LNDLogs from './views/Settings/EmbeddedNode/LNDLogs'; -import Peers from './views/Settings/EmbeddedNode/Peers'; -import NeutrinoPeers from './views/Settings/EmbeddedNode/Peers/NeutrinoPeers'; -import ZeroConfPeers from './views/Settings/EmbeddedNode/Peers/ZeroConfPeers'; -import Advanced from './views/Settings/EmbeddedNode/Advanced'; - -// Routing -import Routing from './views/Routing/Routing'; -import RoutingEvent from './views/Routing/RoutingEvent'; -import SetFees from './views/Routing/SetFees'; - -// new views -import Activity from './views/Activity/Activity'; -import ActivityFilter from './views/Activity/ActivityFilter'; -import CoinControl from './views/UTXOs/CoinControl'; -import Utxo from './views/UTXOs/UTXO'; -import Accounts from './views/Accounts/Accounts'; -import ImportAccount from './views/Accounts/ImportAccount'; -import ImportingAccount from './views/Accounts/ImportingAccount'; -import BumpFee from './views/BumpFee'; -import QR from './views/QR'; -import AddNotes from './views/AddNotes'; -import Contacts from './views/Settings/Contacts'; -import AddContact from './views/Settings/AddContact'; -import ContactDetails from './views/ContactDetails'; -import CurrencyConverter from './views/Settings/CurrencyConverter'; - -// POS -import Order from './views/Order'; - -import Intro from './views/Intro'; -import IntroSplash from './views/IntroSplash'; - -import EditFee from './views/EditFee'; - -// Embedded LND -import Seed from './views/Settings/Seed'; -import SeedRecovery from './views/Settings/SeedRecovery'; -import Sync from './views/Sync'; -import LspExplanationFees from './views/Explanations/LspExplanationFees'; -import LspExplanationRouting from './views/Explanations/LspExplanationRouting'; -import LspExplanationWrappedInvoices from './views/Explanations/LspExplanationWrappedInvoices'; -import LspExplanationOverview from './views/Explanations/LspExplanationOverview'; -import RestoreChannelBackups from './views/Settings/EmbeddedNode/RestoreChannelBackups'; - -import RawTxHex from './views/RawTxHex'; - -import CustodialWalletWarning from './views/Settings/CustodialWalletWarning'; - -import PSBT from './views/PSBT'; -import TxHex from './views/TxHex'; - -const AppScenes = { - Wallet: { - screen: Wallet - }, - IntroSplash: { - screen: IntroSplash - }, - Intro: { - screen: Intro - }, - Lockscreen: { - screen: Lockscreen - }, - Accounts: { - screen: Accounts - }, - Send: { - screen: Send - }, - Sweep: { - screen: Sweep - }, - EditFee: { - screen: EditFee - }, - Settings: { - screen: Settings - }, - NodeConfiguration: { - screen: NodeConfiguration - }, - Nodes: { - screen: Nodes - }, - Privacy: { - screen: Privacy - }, - Security: { - screen: Security - }, - SetPassword: { - screen: SetPassword - }, - SetDuressPassword: { - screen: SetDuressPassword - }, - SetPin: { - screen: SetPin - }, - SetDuressPin: { - screen: SetDuressPin - }, - Language: { - screen: Language - }, - Currency: { - screen: Currency - }, - SelectCurrency: { - screen: SelectCurrency - }, - Display: { - screen: Display - }, - Support: { - screen: Support - }, - Help: { - screen: Help - }, - Sponsors: { - screen: Sponsors - }, - Olympians: { - screen: Olympians - }, - Gods: { - screen: Gods - }, - Mortals: { - screen: Mortals - }, - CertInstallInstructions: { - screen: CertInstallInstructions - }, - SignVerifyMessage: { - screen: SignVerifyMessage - }, - Transaction: { - screen: Transaction - }, - Channel: { - screen: Channel - }, - Payment: { - screen: Payment - }, - PaymentPaths: { - screen: PaymentPaths - }, - Invoice: { - screen: Invoice - }, - LnurlPay: { - screen: LnurlPay - }, - Receive: { - screen: Receive - }, - LnurlChannel: { - screen: LnurlChannel - }, - LnurlAuth: { - screen: LnurlAuth - }, - PaymentRequest: { - screen: PaymentRequest - }, - OpenChannel: { - screen: OpenChannel - }, - SendingOnChain: { - screen: SendingOnChain - }, - SendingLightning: { - screen: SendingLightning - }, - NetworkInfo: { - screen: NetworkInfo - }, - NodeInfo: { - screen: NodeInfo - }, - Routing: { - screen: Routing - }, - RoutingEvent: { - screen: RoutingEvent - }, - SetFees: { - screen: SetFees - }, - Activity: { - screen: Activity - }, - ActivityFilter: { - screen: ActivityFilter - }, - CoinControl: { - screen: CoinControl - }, - Utxo: { - screen: Utxo - }, - ImportAccount: { - screen: ImportAccount - }, - ImportingAccount: { - screen: ImportingAccount - }, - HandleAnythingQRScanner: { - screen: HandleAnythingQRScanner - }, - NodeQRCodeScanner: { - screen: NodeQRScanner - }, - SparkQRScanner: { - screen: SparkQRScanner - }, - Order: { - screen: Order - }, - PointOfSaleSettings: { - screen: PointOfSale - }, - PointOfSaleRecon: { - screen: PointOfSaleRecon - }, - PointOfSaleReconExport: { - screen: PointOfSaleReconExport - }, - Categories: { - screen: Categories - }, - ProductCategoryDetails: { - screen: ProductCategoryDetails - }, - Products: { - screen: Products - }, - ProductDetails: { - screen: ProductDetails - }, - PaymentsSettings: { - screen: PaymentsSettings - }, - InvoicesSettings: { - screen: InvoicesSettings - }, - Seed: { - screen: Seed - }, - SeedRecovery: { - screen: SeedRecovery - }, - Sync: { - screen: Sync - }, - BumpFee: { - screen: BumpFee - }, - QR: { - screen: QR - }, - AddNotes: { - screen: AddNotes - }, - LspExplanationFees: { - screen: LspExplanationFees - }, - LspExplanationRouting: { - screen: LspExplanationRouting - }, - LspExplanationWrappedInvoices: { - screen: LspExplanationWrappedInvoices - }, - LspExplanationOverview: { - screen: LspExplanationOverview - }, - EmbeddedNodeSettings: { - screen: EmbeddedNode - }, - DisasterRecovery: { - screen: DisasterRecovery - }, - DisasterRecoveryAdvanced: { - screen: DisasterRecoveryAdvanced - }, - Pathfinding: { - screen: Pathfinding - }, - ExpressGraphSync: { - screen: ExpressGraphSync - }, - LNDLogs: { - screen: LNDLogs - }, - Peers: { - screen: Peers - }, - NeutrinoPeers: { - screen: NeutrinoPeers - }, - ZeroConfPeers: { - screen: ZeroConfPeers - }, - EmbeddedNodeSettingsAdvanced: { - screen: Advanced - }, - LSPSettings: { - screen: LSP - }, - LightningAddress: { - screen: LightningAddress - }, - LightningAddressInfo: { - screen: LightningAddressInfo - }, - LightningAddressSettings: { - screen: LightningAddressSettings - }, - Attestations: { - screen: Attestations - }, - Attestation: { - screen: Attestation - }, - Contacts: { - screen: Contacts - }, - AddContact: { - screen: AddContact - }, - ContactDetails: { - screen: ContactDetails - }, - NostrKeys: { - screen: NostrKeys - }, - NostrRelays: { - screen: NostrRelays - }, - ChangeAddress: { - screen: ChangeAddress - }, - SocialMedia: { - screen: SocialMedia - }, - NostrContacts: { - screen: NostrContacts - }, - ContactQR: { - screen: ContactQR - }, - CurrencyConverter: { - screen: CurrencyConverter - }, - ChannelsSettings: { - screen: ChannelsSettings - }, - RawTxHex: { - screen: RawTxHex - }, - RestoreChannelBackups: { - screen: RestoreChannelBackups - }, - SetNodePicture: { - screen: SetNodePicture - }, - CustodialWalletWarning: { - screen: CustodialWalletWarning - }, - PSBT: { - screen: PSBT - }, - TxHex: { - screen: TxHex - } -}; - -const AppNavigator = createStackNavigator(AppScenes, { - headerMode: 'none', - mode: 'modal', - defaultNavigationOptions: { - gestureEnabled: false - } -}); - -const Navigation = createAppContainer(AppNavigator); - -export default Navigation; diff --git a/NavigationService.ts b/NavigationService.ts index deba73fa6..d8c071b11 100644 --- a/NavigationService.ts +++ b/NavigationService.ts @@ -1,15 +1,18 @@ -import { NavigationActions } from 'react-navigation'; +import { + CommonActions, + NavigationContainerRef +} from '@react-navigation/native'; -let _navigator; +let _navigator: NavigationContainerRef<{}>; -function setTopLevelNavigator(navigatorRef) { +function setTopLevelNavigator(navigatorRef: NavigationContainerRef<{}>) { _navigator = navigatorRef; } function navigate(routeName: string, params?: any) { _navigator.dispatch( - NavigationActions.navigate({ - routeName, + CommonActions.navigate({ + name: routeName, params }) ); diff --git a/components/LayerBalances/LightningSwipeableRow.tsx b/components/LayerBalances/LightningSwipeableRow.tsx index de54c2a7c..cc9ad2042 100644 --- a/components/LayerBalances/LightningSwipeableRow.tsx +++ b/components/LayerBalances/LightningSwipeableRow.tsx @@ -9,6 +9,7 @@ import { TouchableOpacity } from 'react-native'; import { getParams as getlnurlParams } from 'js-lnurl'; +import { StackNavigationProp } from '@react-navigation/stack'; import { RectButton } from 'react-native-gesture-handler'; import Swipeable from 'react-native-gesture-handler/Swipeable'; @@ -24,7 +25,7 @@ import Routing from './../../assets/images/SVG/Routing.svg'; import Send from './../../assets/images/SVG/Send.svg'; interface LightningSwipeableRowProps { - navigation: any; + navigation: StackNavigationProp; lightning?: string; locked?: boolean; } diff --git a/components/LayerBalances/OnchainSwipeableRow.tsx b/components/LayerBalances/OnchainSwipeableRow.tsx index ff5bed151..f55095aa7 100644 --- a/components/LayerBalances/OnchainSwipeableRow.tsx +++ b/components/LayerBalances/OnchainSwipeableRow.tsx @@ -7,9 +7,10 @@ import { I18nManager, TouchableOpacity } from 'react-native'; - import { RectButton } from 'react-native-gesture-handler'; import Swipeable from 'react-native-gesture-handler/Swipeable'; +import { StackNavigationProp } from '@react-navigation/stack'; + import BackendUtils from './../../utils/BackendUtils'; import { localeString } from './../../utils/LocaleUtils'; import { themeColor } from './../../utils/ThemeUtils'; @@ -19,7 +20,7 @@ import Receive from './../../assets/images/SVG/Receive.svg'; import Send from './../../assets/images/SVG/Send.svg'; interface OnchainSwipeableRowProps { - navigation: any; + navigation: StackNavigationProp; value?: string; amount?: string; locked?: boolean; diff --git a/components/LayerBalances/index.tsx b/components/LayerBalances/index.tsx index 5b15a4aca..3fae7f65b 100644 --- a/components/LayerBalances/index.tsx +++ b/components/LayerBalances/index.tsx @@ -9,6 +9,7 @@ import { } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import { RectButton } from 'react-native-gesture-handler'; +import { StackNavigationProp } from '@react-navigation/stack'; import { inject, observer } from 'mobx-react'; import Amount from '../Amount'; @@ -37,7 +38,7 @@ interface LayerBalancesProps { BalanceStore: BalanceStore; UTXOsStore: UTXOsStore; UnitsStore: UnitsStore; - navigation: any; + navigation: StackNavigationProp; onRefresh?: any; value?: string; amount?: string; @@ -164,7 +165,7 @@ const SwipeableRow = ({ }: { item: DataRow; index: number; - navigation: any; + navigation: StackNavigationProp; selectMode: boolean; value?: string; amount?: string; diff --git a/components/OnchainFeeInput.tsx b/components/OnchainFeeInput.tsx index aa378678f..39f7f02c8 100644 --- a/components/OnchainFeeInput.tsx +++ b/components/OnchainFeeInput.tsx @@ -1,19 +1,21 @@ import React, { useEffect, useState } from 'react'; import { Text, TouchableWithoutFeedback, View } from 'react-native'; +import { StackNavigationProp } from '@react-navigation/native'; + import TextInput from '../components/TextInput'; import { themeColor } from '../utils/ThemeUtils'; import { localeString } from '../utils/LocaleUtils'; import stores from '../stores/Stores'; -import NavigationService from '../NavigationService'; import LoadingIndicator from './LoadingIndicator'; interface OnchainFeeInputProps { + navigation: StackNavigationProp; fee?: string; onChangeFee: (fee: string) => void; } export default function OnchainFeeInput(props: OnchainFeeInputProps) { - const { fee, onChangeFee } = props; + const { fee, onChangeFee, navigation } = props; const { settingsStore, feeStore } = stores; const { settings } = settingsStore; @@ -50,7 +52,7 @@ export default function OnchainFeeInput(props: OnchainFeeInputProps) { {enableMempoolRates ? ( - NavigationService.navigate('EditFee', { + navigation.navigate('EditFee', { onNavigateBack: (fee: string) => { if (fee) { setErrorOccurredLoadingFees(false); diff --git a/components/QRCodeScanner.tsx b/components/QRCodeScanner.tsx index ec606b0a5..64666b7a2 100644 --- a/components/QRCodeScanner.tsx +++ b/components/QRCodeScanner.tsx @@ -11,6 +11,7 @@ import { import { Camera } from 'react-native-camera-kit'; import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions'; import { launchImageLibrary } from 'react-native-image-picker'; +import { StackNavigationProp } from '@react-navigation/stack'; const LocalQRCode = require('@remobile/react-native-qrcode-local-image'); @@ -29,7 +30,7 @@ interface QRProps { text?: string; handleQRScanned: any; goBack: any; - navigation: any; + navigation: StackNavigationProp; parts?: number; totalParts?: number; mode?: string; @@ -101,11 +102,11 @@ export default class QRCodeScanner extends React.Component { } }; + handleFocus = () => (this.scannedCache = {}); + async componentDidMount() { // triggers when loaded from navigation or back action - this.props.navigation.addListener('didFocus', () => { - this.scannedCache = {}; - }); + this.props.navigation.addListener('focus', this.handleFocus); if (Platform.OS !== 'ios' && Platform.OS !== 'macos') { // For android @@ -176,7 +177,7 @@ export default class QRCodeScanner extends React.Component { componentWillUnmount() { this.props.navigation.removeListener && - this.props.navigation.removeListener('didFocus'); + this.props.navigation.removeListener('focus', this.handleFocus); } render() { diff --git a/components/WalletHeader.tsx b/components/WalletHeader.tsx index 05105b5de..576a383e1 100644 --- a/components/WalletHeader.tsx +++ b/components/WalletHeader.tsx @@ -12,6 +12,7 @@ import { } from 'react-native'; import { inject, observer } from 'mobx-react'; import Clipboard from '@react-native-clipboard/clipboard'; +import { StackNavigationProp } from '@react-navigation/stack'; import ChannelsStore from '../stores/ChannelsStore'; import LightningAddressStore from '../stores/LightningAddressStore'; @@ -35,7 +36,7 @@ import { themeColor } from '../utils/ThemeUtils'; import Add from '../assets/images/SVG/Add.svg'; import ClipboardSVG from '../assets/images/SVG/Clipboard.svg'; -import Scan from '../assets/images/SVG/Scan.svg'; +import Gear from '../assets/images/SVG/Gear.svg'; import POS from '../assets/images/SVG/POS.svg'; import Search from '../assets/images/SVG/Search.svg'; import Temple from '../assets/images/SVG/Temple.svg'; @@ -83,7 +84,11 @@ const MailboxAnimated = () => { ); }; -const ActivityButton = ({ navigation }: { navigation: any }) => ( +const ActivityButton = ({ + navigation +}: { + navigation: StackNavigationProp; +}) => (