Skip to content

Commit c1cda22

Browse files
committed
fix(MUSD-744): rewire tab nav inside MainNavigator to avoid DS files
Reverts all changes to app/component-library/components/Navigation/TabBar/* and to useCashNavigation so this PR no longer triggers @MetaMask/design-system-engineers CODEOWNERS review, and so the CashSection.test.tsx test that asserts the original navigate signature passes again. The tab bar stays visible on Money Home because the Money Tab.Screen is now registered as Routes.MONEY.ROOT (instead of Routes.MONEY.HOME), and the outer Stack.Screen for Routes.MONEY.ROOT is removed. The original TabBar handler navigate(Routes.MONEY.ROOT, { screen: Routes.MONEY.HOME }) resolves to the tab itself with the inner stack's initial screen, so the global tab bar stays mounted. Side effect: the Money tab icon reverts to IconName.Bank. The IconName.Coin swap will land in a separate small DS-owned PR.
1 parent 421d667 commit c1cda22

6 files changed

Lines changed: 18 additions & 45 deletions

File tree

app/component-library/components/Navigation/TabBar/TabBar.constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const ICON_BY_TAB_BAR_ICON_KEY: IconByTabBarIconKey = {
1414
[TabBarIconKey.Setting]: IconName.Setting,
1515
[TabBarIconKey.Rewards]: IconName.MetamaskFoxOutline,
1616
[TabBarIconKey.Trending]: IconName.Search,
17-
[TabBarIconKey.Money]: IconName.Coin,
17+
[TabBarIconKey.Money]: IconName.Bank,
1818
};
1919

2020
export const LABEL_BY_TAB_BAR_ICON_KEY = {

app/component-library/components/Navigation/TabBar/TabBar.test.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -220,36 +220,6 @@ describe('TabBar', () => {
220220
expect(navigation.navigate).toHaveBeenCalledWith(Routes.TRENDING_VIEW);
221221
});
222222

223-
it('navigates to money home when money tab is pressed', () => {
224-
const moneyState = {
225-
index: 0,
226-
routes: [{ key: '1', name: 'Tab 1' }],
227-
};
228-
const moneyDescriptors: TestDescriptors = {
229-
'1': {
230-
options: {
231-
tabBarIconKey: TabBarIconKey.Money,
232-
rootScreenName: Routes.MONEY.HOME,
233-
},
234-
},
235-
};
236-
237-
const { getByTestId } = renderWithProvider(
238-
<TabBar
239-
state={moneyState as TabNavigationState<ParamListBase>}
240-
descriptors={
241-
moneyDescriptors as Record<string, ExtendedBottomTabDescriptor>
242-
}
243-
navigation={navigation}
244-
/>,
245-
{ state: mockInitialState },
246-
);
247-
248-
fireEvent.press(getByTestId(`tab-bar-item-${TabBarIconKey.Money}`));
249-
expect(navigation.navigate).toHaveBeenCalledWith(Routes.MONEY.HOME);
250-
expect(navigation.navigate).toHaveBeenCalledTimes(1);
251-
});
252-
253223
it('does not render hidden tabs', () => {
254224
const stateWithHidden = {
255225
index: 0,

app/component-library/components/Navigation/TabBar/TabBar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const FILLED_ICONS: Partial<Record<TabBarIconKey, IconName>> = {
3434
[TabBarIconKey.Activity]: IconName.ClockFilled,
3535
[TabBarIconKey.Trending]: IconName.Search,
3636
[TabBarIconKey.Rewards]: IconName.MetamaskFoxFilled,
37-
[TabBarIconKey.Money]: IconName.Coin,
37+
[TabBarIconKey.Money]: IconName.Bank,
3838
};
3939

4040
const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
@@ -112,7 +112,9 @@ const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
112112
navigation.navigate(Routes.TRENDING_VIEW);
113113
break;
114114
case Routes.MONEY.HOME:
115-
navigation.navigate(Routes.MONEY.HOME);
115+
navigation.navigate(Routes.MONEY.ROOT, {
116+
screen: Routes.MONEY.HOME,
117+
});
116118
break;
117119
}
118120
};

app/components/Nav/Main/MainNavigator.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ const HomeTabs = () => {
866866
{/* Activity Tab (replaced by Money when feature flag is on) */}
867867
{isMoneyHomeScreenEnabled ? (
868868
<Tab.Screen
869-
name={Routes.MONEY.HOME}
869+
name={Routes.MONEY.ROOT}
870870
options={options.money}
871871
component={MoneyScreenStack}
872872
/>
@@ -1222,11 +1222,6 @@ const MainNavigator = () => {
12221222
/>
12231223
{isMoneyHomeScreenEnabled && (
12241224
<>
1225-
<Stack.Screen
1226-
name={Routes.MONEY.ROOT}
1227-
component={MoneyScreenStack}
1228-
options={{ headerShown: false, ...slideFromRightAnimation }}
1229-
/>
12301225
<Stack.Screen
12311226
name={Routes.MONEY.MODALS.ROOT}
12321227
component={MoneyModalStack}

app/components/Views/Homepage/Sections/Cash/useCashNavigation.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ describe('useCashNavigation', () => {
7777
expect(mockNavigate).toHaveBeenCalledTimes(1);
7878
expect(mockNavigate).toHaveBeenCalledWith(
7979
Routes.WALLET.CASH_TOKENS_FULL_VIEW,
80+
undefined,
8081
);
8182
});
8283

83-
it('navigates to Money Home tab when isMoneyHomeEnabled and education already seen', () => {
84+
it('navigates to Money Home when isMoneyHomeEnabled and education already seen', () => {
8485
setupSelectors({
8586
isMoneyHomeEnabled: true,
8687
hasSeenEducation: true,
@@ -90,10 +91,12 @@ describe('useCashNavigation', () => {
9091
result.current.navigateToCash();
9192

9293
expect(mockNavigate).toHaveBeenCalledTimes(1);
93-
expect(mockNavigate).toHaveBeenCalledWith(Routes.MONEY.HOME);
94+
expect(mockNavigate).toHaveBeenCalledWith(Routes.MONEY.ROOT, {
95+
screen: Routes.MONEY.HOME,
96+
});
9497
});
9598

96-
it('navigates to education screen with Money Home tab returnTo when isMoneyHomeEnabled and education not seen', () => {
99+
it('navigates to education screen with Money Home returnTo when isMoneyHomeEnabled and education not seen', () => {
97100
setupSelectors({
98101
isMoneyHomeEnabled: true,
99102
hasSeenEducation: false,
@@ -106,7 +109,10 @@ describe('useCashNavigation', () => {
106109
expect(mockNavigate).toHaveBeenCalledWith(Routes.EARN.ROOT, {
107110
screen: Routes.EARN.MUSD.CONVERSION_EDUCATION,
108111
params: {
109-
returnTo: { screen: Routes.MONEY.HOME },
112+
returnTo: {
113+
screen: Routes.MONEY.ROOT,
114+
params: { screen: Routes.MONEY.HOME },
115+
},
110116
},
111117
});
112118
});

app/components/Views/Homepage/Sections/Cash/useCashNavigation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const useCashNavigation = () => {
1616

1717
const navigateToCash = useCallback(() => {
1818
const destination: MusdNavigationTarget = isMoneyHomeEnabled
19-
? { screen: Routes.MONEY.HOME }
19+
? { screen: Routes.MONEY.ROOT, params: { screen: Routes.MONEY.HOME } }
2020
: { screen: Routes.WALLET.CASH_TOKENS_FULL_VIEW };
2121

2222
if (!hasSeenEducation) {
@@ -27,7 +27,7 @@ export const useCashNavigation = () => {
2727
return;
2828
}
2929

30-
navigation.navigate(destination.screen);
30+
navigation.navigate(destination.screen, destination.params);
3131
}, [isMoneyHomeEnabled, hasSeenEducation, navigation]);
3232

3333
return { navigateToCash, isMoneyHomeEnabled, hasSeenEducation };

0 commit comments

Comments
 (0)