From af92f5b76d56e494cc16c1d2780c91f01441c5a1 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Tue, 3 Dec 2024 14:03:15 +0100 Subject: [PATCH] wip --- .../src/features/Swap/SwapNavigator.tsx | 6 +- .../src/features/Swap/common/SwapProvider.tsx | 37 +++- .../Swap/useCases/ListOrders/ListOrders.tsx | 98 ++++++++++ .../Swap/useCases/ListOrders/ListOrders.tsx_ | 76 -------- .../Transactions/TxHistoryNavigator.tsx | 2 - .../Transactions/TxHistoryNavigator.json | 184 +++++++++--------- 6 files changed, 227 insertions(+), 176 deletions(-) create mode 100644 apps/wallet-mobile/src/features/Swap/useCases/ListOrders/ListOrders.tsx delete mode 100644 apps/wallet-mobile/src/features/Swap/useCases/ListOrders/ListOrders.tsx_ diff --git a/apps/wallet-mobile/src/features/Swap/SwapNavigator.tsx b/apps/wallet-mobile/src/features/Swap/SwapNavigator.tsx index 048093172f..b81f06009c 100644 --- a/apps/wallet-mobile/src/features/Swap/SwapNavigator.tsx +++ b/apps/wallet-mobile/src/features/Swap/SwapNavigator.tsx @@ -1,7 +1,7 @@ import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs' import {useTheme} from '@yoroi/theme' import React from 'react' -import {Keyboard, StyleSheet, View} from 'react-native' +import {Keyboard, StyleSheet} from 'react-native' import {SafeAreaView} from 'react-native-safe-area-context' import {KeyboardAvoidingView} from '../../components/KeyboardAvoidingView/KeyboardAvoidingView' @@ -10,7 +10,7 @@ import {defaultMaterialTopTabNavigationOptions, SwapTabRoutes} from '../../kerne import {useSearch} from '../Search/SearchContext' import {useStrings} from './common/strings' import {StartSwapOrderScreen} from './useCases/CreateOrder/StartSwapOrderScreen' -// import {ListOrders} from './useCases/StartOrderSwapScreen/ListOrders/ListOrders' +import {ListOrders} from './useCases/ListOrders/ListOrders' const Tab = createMaterialTopTabNavigator() export const SwapTabNavigator = () => { @@ -61,7 +61,7 @@ export const SwapTabNavigator = () => { }, }} name="orders" - getComponent={() => View} + getComponent={() => ListOrders} /> diff --git a/apps/wallet-mobile/src/features/Swap/common/SwapProvider.tsx b/apps/wallet-mobile/src/features/Swap/common/SwapProvider.tsx index b39162364d..0087509aba 100644 --- a/apps/wallet-mobile/src/features/Swap/common/SwapProvider.tsx +++ b/apps/wallet-mobile/src/features/Swap/common/SwapProvider.tsx @@ -93,30 +93,61 @@ const swapReducer = (state: SwapState, action: SwapAction) => { break case SwapAction.TokenInIdChanged: - draft.tokenInInput.displayValue = action.value ?? '' + draft.tokenInInput.tokenId = action.value break case SwapAction.TokenOutIdChanged: + draft.tokenInInput.tokenId = action.value + break case SwapAction.TokenInAmountChanged: + draft.tokenInInput.displayValue = action.value + break case SwapAction.TokenOutAmountChanged: + draft.tokenOutInput.displayValue = action.value + break case SwapAction.TokenInErrorChanged: + draft.tokenInInput.error = action.value + break case SwapAction.TokenOutErrorChanged: + draft.tokenOutInput.error = action.value + break case SwapAction.SlippageInputChanged: + draft.slippageInput.displayValue = String(action.value) + break case SwapAction.WantedPriceInputChanged: + draft.wantedPrice.displayValue = action.value + break case SwapAction.SwitchTouched: + draft.tokenOutInput.isTouched = state.tokenInInput.isTouched + draft.tokenOutInput.tokenId = state.tokenInInput.tokenId + draft.tokenOutInput.displayValue = '' + draft.tokenOutInput.error = undefined + + draft.tokenInInput.isTouched = state.tokenOutInput.isTouched + draft.tokenInInput.tokenId = state.tokenOutInput.tokenId + draft.tokenInInput.displayValue = '' + draft.tokenInInput.error = undefined + break case SwapAction.DexSelectorTouched: break case SwapAction.ResetAmounts: + draft.tokenInInput.displayValue = '' + draft.tokenOutInput.displayValue = '' + + draft.tokenInInput.error = undefined + draft.tokenOutInput.error = undefined + break case SwapAction.ResetForm: + draft = defaultState break default: throw new Error(`swapReducer invalid action`) @@ -146,8 +177,8 @@ type SwapActionValueMap = { ChangeOrderType: 'limit' | 'market' TokenInInputTouched: undefined TokenOutInputTouched: undefined - TokenInIdChanged: string - TokenOutIdChanged: string + TokenInIdChanged: Portfolio.Token.Id + TokenOutIdChanged: Portfolio.Token.Id TokenInAmountChanged: string TokenOutAmountChanged: string TokenInErrorChanged: string diff --git a/apps/wallet-mobile/src/features/Swap/useCases/ListOrders/ListOrders.tsx b/apps/wallet-mobile/src/features/Swap/useCases/ListOrders/ListOrders.tsx new file mode 100644 index 0000000000..4ceffc86eb --- /dev/null +++ b/apps/wallet-mobile/src/features/Swap/useCases/ListOrders/ListOrders.tsx @@ -0,0 +1,98 @@ +import {useTheme} from '@yoroi/theme' +import React from 'react' +import {ErrorBoundary} from 'react-error-boundary' +import {StyleSheet, View} from 'react-native' + +import {Boundary} from '../../../../components/Boundary/Boundary' +import {Button, ButtonType} from '../../../../components/Button/Button' +import {useWalletNavigation} from '../../../../kernel/navigation' +import {useSearchOnNavBar} from '../../../Search/SearchContext' +import {ServiceUnavailable} from '../../common/ServiceUnavailable/ServiceUnavailable' +import {useStrings} from '../../common/strings' +// import {CompletedOrders, CompletedOrdersSkeleton} from './CompletedOrders' +// import {OpenOrders, OpenOrdersSkeleton} from './OpenOrders' +// TODO +const CompletedOrders = () => null +const CompletedOrdersSkeleton = () => null +const OpenOrders = () => null +const OpenOrdersSkeleton = () => null + +export const ListOrders = () => { + const {navigateToTxHistory} = useWalletNavigation() + const [filter, setFilter] = React.useState<'open' | 'completed'>('open') + + const strings = useStrings() + const styles = useStyles() + + useSearchOnNavBar({ + placeholder: strings.searchTokens, + title: strings.swapTitle, + isChild: true, + onBack: navigateToTxHistory, + }) + + return ( + + + +