From cfc012e246adce1528174e3096bddf3c7b0b32e4 Mon Sep 17 00:00:00 2001 From: shubham Date: Mon, 20 May 2024 15:55:37 +0530 Subject: [PATCH] LSPS1: Using new navigation --- App.tsx | 22 ++++++++++++++++++++++ views/Channels/ChannelsPane.tsx | 12 +++++++----- views/Settings/LSPS1/OrdersPane.tsx | 5 +++-- views/Settings/LSPS1/index.tsx | 3 ++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/App.tsx b/App.tsx index 0706f852bb..c59127da5e 100644 --- a/App.tsx +++ b/App.tsx @@ -138,6 +138,12 @@ import LspExplanationWrappedInvoices from './views/Explanations/LspExplanationWr import LspExplanationOverview from './views/Explanations/LspExplanationOverview'; import RestoreChannelBackups from './views/Settings/EmbeddedNode/RestoreChannelBackups'; +// LSPS1 +import LSPS1 from './views/Settings/LSPS1/index'; +import LSPS1Settings from './views/Settings/LSPS1/Settings'; +import OrdersPane from './views/Settings/LSPS1/OrdersPane'; +import Orders from './views/Settings/LSPS1/Order'; + import RawTxHex from './views/RawTxHex'; import CustodialWalletWarning from './views/Settings/CustodialWalletWarning'; @@ -732,6 +738,22 @@ export default class App extends React.PureComponent { name="TxHex" component={TxHex} /> + + + + )} diff --git a/views/Channels/ChannelsPane.tsx b/views/Channels/ChannelsPane.tsx index 5464c8683e..5d3a5ffc16 100644 --- a/views/Channels/ChannelsPane.tsx +++ b/views/Channels/ChannelsPane.tsx @@ -28,8 +28,6 @@ import { localeString } from '../../utils/LocaleUtils'; import Channel from '../../models/Channel'; -import NavigationService from '../../NavigationService'; - // TODO: does this belong in the model? Or can it be computed from the model? export enum Status { Good = 'Good', @@ -46,7 +44,7 @@ interface ChannelsProps { SettingsStore?: SettingsStore; } -const ColorChangingButton = () => { +const ColorChangingButton = ({ onPress }) => { const [forward, setForward] = useState(true); const animation = useRef(new Animated.Value(0)).current; @@ -75,7 +73,7 @@ const ColorChangingButton = () => { return ( NavigationService.navigate('LSPS1')} + onPress={onPress} style={[styles.button, { backgroundColor }]} > @@ -237,7 +235,11 @@ export default class ChannelsPane extends React.PureComponent { {settings?.lsps1ShowPurchaseButton && (BackendUtils.supportsLSPS1customMessage() || BackendUtils.supportsLSPS1rest()) && ( - + { + navigation.navigate('LSPS1'); + }} + /> )} {showSearch && } {loading ? ( diff --git a/views/Settings/LSPS1/OrdersPane.tsx b/views/Settings/LSPS1/OrdersPane.tsx index e4df113d7c..bb67f3e758 100644 --- a/views/Settings/LSPS1/OrdersPane.tsx +++ b/views/Settings/LSPS1/OrdersPane.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import EncryptedStorage from 'react-native-encrypted-storage'; import moment from 'moment'; import { inject, observer } from 'mobx-react'; +import { StackNavigationProp } from '@react-navigation/stack'; import { View, FlatList, TouchableOpacity, Text } from 'react-native'; import Header from '../../../components/Header'; @@ -16,7 +17,7 @@ import LSPStore from '../../../stores/LSPStore'; import { WarningMessage } from '../../../components/SuccessErrorMessage'; interface OrdersPaneProps { - navigation: any; + navigation: StackNavigationProp; LSPStore: LSPStore; } @@ -41,7 +42,7 @@ export default class OrdersPane extends React.Component< async componentDidMount() { const { navigation, LSPStore } = this.props; - navigation.addListener('didFocus', async () => { + navigation.addListener('focus', async () => { try { // Retrieve saved responses from encrypted storage const responseArrayString = await EncryptedStorage.getItem( diff --git a/views/Settings/LSPS1/index.tsx b/views/Settings/LSPS1/index.tsx index 7675fd9347..b913eb4af7 100644 --- a/views/Settings/LSPS1/index.tsx +++ b/views/Settings/LSPS1/index.tsx @@ -11,6 +11,7 @@ import { } from 'react-native'; import EncryptedStorage from 'react-native-encrypted-storage'; import Slider from '@react-native-community/slider'; +import { StackNavigationProp } from '@react-navigation/stack'; import { v4 as uuidv4 } from 'uuid'; import CaretDown from '../../../assets/images/SVG/Caret Down.svg'; @@ -45,7 +46,7 @@ interface LSPS1Props { ChannelsStore: ChannelsStore; SettingsStore: SettingsStore; FiatStore: FiatStore; - navigation: any; + navigation: StackNavigationProp; } interface LSPS1State {