From 52c3aa4ccac5e8c0f193d10721b271b81f07349f Mon Sep 17 00:00:00 2001
From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com>
Date: Fri, 4 Oct 2024 08:48:42 +0100
Subject: [PATCH 01/14] fix(wallet-mobile): flickering when nav back to
portfolio
---
.../Portfolio/common/hooks/useNavigateTo.tsx | 12 ++-
.../PortfolioTokenDetails/Actions.tsx | 8 +-
.../messages/src/WalletNavigator.json | 96 +++++++++----------
3 files changed, 62 insertions(+), 54 deletions(-)
diff --git a/apps/wallet-mobile/src/features/Portfolio/common/hooks/useNavigateTo.tsx b/apps/wallet-mobile/src/features/Portfolio/common/hooks/useNavigateTo.tsx
index 3b0e41d5b8..d64e0eb909 100644
--- a/apps/wallet-mobile/src/features/Portfolio/common/hooks/useNavigateTo.tsx
+++ b/apps/wallet-mobile/src/features/Portfolio/common/hooks/useNavigateTo.tsx
@@ -15,7 +15,17 @@ export const useNavigateTo = () => {
nftsList: () => navigation.navigate('portfolio-nfts', {screen: 'nft-gallery'}),
nftDetails: (id: Portfolio.Token.Id) =>
navigation.navigate('portfolio-nfts', {screen: 'nft-details', params: {id}, initial: false}),
- send: () => navigation.navigate('history', {screen: 'send-start-tx'}),
+ resetTabAndSend: () => {
+ navigation.reset({index: 0, routes: [{name: 'dashboard-portfolio'}]})
+ navigation.navigate('history', {screen: 'send-start-tx'})
+ },
+ resetTabAndSwap: () => {
+ navigation.reset({index: 0, routes: [{name: 'dashboard-portfolio'}]})
+ navigation.navigate('history', {
+ screen: 'swap-start-swap',
+ params: {screen: 'token-swap'},
+ })
+ },
swap: () =>
navigation.navigate('history', {
screen: 'swap-start-swap',
diff --git a/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/Actions.tsx b/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/Actions.tsx
index bba9c7d567..97a7e0e032 100644
--- a/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/Actions.tsx
+++ b/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/Actions.tsx
@@ -45,14 +45,12 @@ export const Actions = ({tokenInfo}: Props) => {
from_asset: [
{asset_name: portfolioPrimaryTokenInfo.name, asset_ticker: portfolioPrimaryTokenInfo.ticker, policy_id: ''},
],
- to_asset: [
- {asset_name: tokenInfo.name ?? '', asset_ticker: tokenInfo.ticker ?? '', policy_id: tokenInfo.id ?? ''},
- ],
+ to_asset: [{asset_name: tokenInfo.name, asset_ticker: tokenInfo.ticker, policy_id: tokenInfo.id}],
order_type: swap.orderData.type,
slippage_tolerance: swap.orderData.slippage,
})
- navigateTo.swap()
+ navigateTo.resetTabAndSwap()
}
return (
@@ -64,7 +62,7 @@ export const Actions = ({tokenInfo}: Props) => {
outlineOnLight
title={strings.send.toLocaleUpperCase()}
startContent={}
- onPress={navigateTo.send}
+ onPress={navigateTo.resetTabAndSend}
/>