Skip to content

Commit b4b5013

Browse files
committed
new swap navigation
1 parent faac7b8 commit b4b5013

File tree

11 files changed

+726
-740
lines changed

11 files changed

+726
-740
lines changed

apps/wallet-mobile/src/features/Portfolio/common/hooks/useNavigateTo.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ export const useNavigateTo = () => {
2222
resetTabAndSwap: () => {
2323
navigation.reset({index: 0, routes: [{name: 'dashboard-portfolio'}]})
2424
navigation.navigate('history', {
25-
screen: 'swap-start-swap',
26-
params: {screen: 'token-swap'},
25+
screen: 'token-swap',
2726
})
2827
},
2928
swap: () =>
3029
navigation.navigate('history', {
31-
screen: 'swap-start-swap',
32-
params: {screen: 'token-swap'},
30+
screen: 'token-swap',
3331
}),
3432
swapPreprodNotice: () =>
3533
navigation.navigate('history', {

apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokensList/PortfolioWalletTokenList/TradeTokensBannerBig.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const TradeTokensBannerBig = () => {
1616

1717
const navigation = useNavigation<TxHistoryRouteNavigation>()
1818
const handleSwap = () => {
19-
navigation.navigate('swap-start-swap', {screen: 'token-swap'})
19+
navigation.navigate('token-swap')
2020
}
2121

2222
return (

apps/wallet-mobile/src/features/Swap/SwapNavigator.tsx

-77
This file was deleted.

apps/wallet-mobile/src/features/Swap/common/navigation.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const useNavigateTo = () => {
1212
editSlippage: () => swapNavigation.navigate('swap-edit-slippage'),
1313
selectBuyToken: () => swapNavigation.navigate('swap-select-buy-token'),
1414
selectSellToken: () => swapNavigation.navigate('swap-select-sell-token'),
15-
startSwap: () => swapNavigation.navigate('swap-start-swap', {screen: 'token-swap'}),
15+
startSwap: () => swapNavigation.navigate('token-swap'),
16+
orders: () => swapNavigation.navigate('orders'),
1617
reviewSwap: () => swapNavigation.navigate('swap-review'),
1718
submittedTx: () => swapNavigation.navigate('swap-submitted-tx'),
1819
failedTx: () => swapNavigation.navigate('swap-failed-tx'),
@@ -22,10 +23,7 @@ export const useNavigateTo = () => {
2223
params: {
2324
screen: 'history',
2425
params: {
25-
screen: 'swap-start-swap',
26-
params: {
27-
screen: 'orders',
28-
},
26+
screen: 'orders',
2927
},
3028
},
3129
}),
@@ -35,10 +33,7 @@ export const useNavigateTo = () => {
3533
params: {
3634
screen: 'history',
3735
params: {
38-
screen: 'swap-start-swap',
39-
params: {
40-
screen: 'token-swap',
41-
},
36+
screen: 'token-swap',
4237
},
4338
},
4439
}),

apps/wallet-mobile/src/features/Swap/common/strings.ts

+5
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export const useStrings = () => {
168168
submittedTxScreenTitle: intl.formatMessage(messages.submittedTxScreenTitle),
169169
submittedTxScreenText: intl.formatMessage(messages.submittedTxScreenText),
170170
submittedTxScreenButton: intl.formatMessage(messages.submittedTxScreenButton),
171+
settings: intl.formatMessage(messages.settings),
171172
}
172173
}
173174

@@ -730,4 +731,8 @@ const messages = defineMessages({
730731
id: 'swap.submittedTxScreen.button',
731732
defaultMessage: '!!!Close',
732733
},
734+
settings: {
735+
id: 'menu.settings',
736+
defaultMessage: '!!!Settings',
737+
},
733738
})

apps/wallet-mobile/src/features/Swap/useCases/CreateOrder/StartSwapOrderScreen.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {undefinedToken} from '../../common/constants'
1616
import {useNavigateTo} from '../../common/navigation'
1717
import {useStrings} from '../../common/strings'
1818
import {useSwap} from '../../common/SwapProvider'
19+
import {ManagerConfig} from '../Manager/ManagerConfig'
1920
import {EditPrice} from './EditPrice'
2021
import {ListSplitsByProvider} from './ListSplitsByProvider'
2122
import {WarnLimitPrice} from './WarnLimitPrice'
@@ -68,6 +69,13 @@ export const StartSwapOrderScreen = () => {
6869
}
6970
}
7071

72+
const openSettings = () => {
73+
openModal({
74+
title: strings.settings,
75+
content: <ManagerConfig />,
76+
})
77+
}
78+
7179
return (
7280
<View style={[styles.root, styles.flex]}>
7381
<ScrollView style={styles.padding}>
@@ -99,11 +107,13 @@ export const StartSwapOrderScreen = () => {
99107
/>
100108
</View>
101109

102-
<View>
110+
<View style={styles.group}>
103111
<RefreshButton
104112
onPress={() => swapForm.action({type: 'Refresh'})}
105113
disabled={!swapForm.tokenInInput.isTouched || !swapForm.tokenOutInput.isTouched}
106114
/>
115+
116+
<Button type={ButtonType.SecondaryText} icon={Icon.Gear} style={styles.gear} onPress={openSettings} />
107117
</View>
108118
</View>
109119

@@ -232,7 +242,6 @@ const useStyles = () => {
232242
},
233243
group: {
234244
...atoms.flex_row,
235-
...atoms.gap_md,
236245
...atoms.align_center,
237246
},
238247
textContent: {
@@ -251,6 +260,10 @@ const useStyles = () => {
251260
...atoms.gap_lg,
252261
...atoms.pt_lg,
253262
},
263+
gear: {
264+
...atoms.px_sm,
265+
...atoms.rounded_full,
266+
},
254267
})
255268

256269
return {styles, atoms}

apps/wallet-mobile/src/features/Transactions/TxHistoryNavigator.tsx

+30-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ import {FailedTxScreen as SendFailedTxScreen} from '../Send/useCases/ShowFailedT
3737
import {SubmittedTxScreen as SendSubmittedTxScreen} from '../Send/useCases/ShowSubmittedTxScreen/SubmittedTxScreen'
3838
import {StartMultiTokenTxScreen} from '../Send/useCases/StartMultiTokenTx/StartMultiTokenTxScreen'
3939
import {NetworkTag} from '../Settings/useCases/changeAppSettings/ChangeNetwork/NetworkTag'
40-
import {SwapTabNavigator} from '../Swap/SwapNavigator'
4140
import {EditSlippageScreen} from '../Swap/useCases/CreateOrder/EditSlippageScreen'
4241
import {SelectBuyTokenFromListScreen} from '../Swap/useCases/CreateOrder/SelectBuyTokenFromListScreen'
4342
import {SelectProtocolScreen} from '../Swap/useCases/CreateOrder/SelectProtocolScreen'
4443
import {SelectSellTokenFromListScreen} from '../Swap/useCases/CreateOrder/SelectSellTokenFromListScreen'
44+
import {StartSwapOrderScreen} from '../Swap/useCases/CreateOrder/StartSwapOrderScreen'
45+
import {ListOrders} from '../Swap/useCases/ListOrders/ListOrders'
4546
import {ReviewSwap} from '../Swap/useCases/ReviewSwap/ReviewSwap'
4647
import {FailedTxScreen as SwapFailedTxScreen} from '../Swap/useCases/ShowFailedTxScreen/FailedTxScreen'
4748
import {ShowPreprodNoticeScreen} from '../Swap/useCases/ShowPreprodNoticeScreen/ShowPreprodNoticeScreen'
@@ -212,11 +213,21 @@ export const TxHistoryNavigator = () => {
212213
/>
213214

214215
<Stack.Screen
215-
name="swap-start-swap"
216-
component={SwapTabNavigator}
216+
name="token-swap"
217+
component={StartSwapOrderScreen}
217218
options={{
218219
...sendOptions(navigationOptions, color),
219220
title: strings.swapTitle,
221+
headerRight: () => <HeaderRightSwap />,
222+
}}
223+
/>
224+
225+
<Stack.Screen
226+
name="orders"
227+
getComponent={() => ListOrders}
228+
options={{
229+
...sendOptions(navigationOptions, color),
230+
title: strings.orderSwap,
220231
}}
221232
/>
222233

@@ -411,6 +422,10 @@ const messages = defineMessages({
411422
id: 'swap.swapScreen.swapTitle',
412423
defaultMessage: '!!!Swap',
413424
},
425+
orderSwap: {
426+
id: 'swap.swapScreen.ordersSwapTab',
427+
defaultMessage: '!!!Orders',
428+
},
414429
swapFromTitle: {
415430
id: 'swap.swapScreen.swapFrom',
416431
defaultMessage: '!!!Swap from',
@@ -521,6 +536,7 @@ const useStrings = () => {
521536
specificAmount: intl.formatMessage(messages.specificAmount),
522537
swapFromTitle: intl.formatMessage(messages.swapFromTitle),
523538
swapTitle: intl.formatMessage(messages.swapTitle),
539+
orderSwap: intl.formatMessage(messages.orderSwap),
524540
swapToTitle: intl.formatMessage(messages.swapToTitle),
525541
txDetailsTitle: intl.formatMessage(messages.txDetailsTitle),
526542
}
@@ -540,6 +556,17 @@ const HeaderRightHistory = React.memo(() => {
540556
)
541557
})
542558

559+
const HeaderRightSwap = React.memo(() => {
560+
const navigation = useNavigation<TxHistoryRouteNavigation>()
561+
const {color} = useTheme()
562+
563+
return (
564+
<TouchableOpacity onPress={() => navigation.navigate('orders')} style={{paddingRight: 8}}>
565+
<Icon.TermsOfUse color={color.gray_max} size={24} />
566+
</TouchableOpacity>
567+
)
568+
})
569+
543570
const sendOptions = (navigationOptions: StackNavigationOptions, color: ThemedPalette) => ({
544571
...navigationOptions,
545572
headerStyle: {

apps/wallet-mobile/src/features/Transactions/useCases/TxHistory/ActionsBanner.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const useNavigateTo = () => {
175175
send: () => navigation.navigate('send-start-tx'),
176176
receiveSingleAddress: () => navigation.navigate('receive-single'),
177177
receiveMultipleAddresses: () => navigation.navigate('receive-multiple'),
178-
swap: () => navigation.navigate('swap-start-swap', {screen: 'token-swap'}),
178+
swap: () => navigation.navigate('token-swap'),
179179
swapPreprodNotice: () => navigation.navigate('swap-preprod-notice'),
180180
exchange: () => navigation.navigate('exchange-create-order'),
181181
}

apps/wallet-mobile/src/kernel/navigation.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ type ClaimRoutes = {
177177
}
178178

179179
type SwapTokenRoutes = {
180-
'swap-start-swap': NavigatorScreenParams<SwapTabRoutes>
180+
'token-swap': undefined
181+
orders: undefined
181182
'swap-review': undefined
182183
'swap-select-sell-token': undefined
183184
'swap-select-buy-token': undefined
@@ -193,12 +194,6 @@ export type StakingCenterRoutes = {
193194
'staking-center-main': undefined
194195
}
195196

196-
export type SwapTabRoutes = {
197-
'token-swap': undefined
198-
orders: undefined
199-
'manager-config': undefined
200-
}
201-
202197
type ExchangeRoutes = {
203198
'exchange-create-order': undefined
204199
'exchange-result': undefined

0 commit comments

Comments
 (0)