Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

Commit 95628a5

Browse files
committed
feat(wallet): Show info toast when hiding balance on Home
1 parent c3cc276 commit 95628a5

7 files changed

Lines changed: 60 additions & 4 deletions

File tree

src/screens/Wallets/WalletsDetail/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ import {
5151
import { capitalize } from '../../../utils/helpers';
5252
import DetectSwipe from '../../../components/DetectSwipe';
5353
import type { WalletScreenProps } from '../../../navigation/types';
54+
import { showToast } from '../../../utils/notifications';
55+
import { useTranslation } from 'react-i18next';
56+
import { ignoresHideBalanceToastSelector } from '../../../store/reselect/user';
57+
import { ignoreHideBalanceToast } from '../../../store/slices/user';
5458

5559
const updateHeight = ({ height, toValue = 0, duration = 250 }): void => {
5660
try {
@@ -94,6 +98,9 @@ const WalletsDetail = ({
9498
enableSwipeToHideBalanceSelector,
9599
);
96100
const hideBalance = useAppSelector(hideBalanceSelector);
101+
const ignoresHideBalanceToast = useAppSelector(
102+
ignoresHideBalanceToastSelector,
103+
);
97104
const [_, switchUnit] = useSwitchUnit();
98105
const colors = useColors();
99106
const size = useSharedValue({ width: 0, height: 0 });
@@ -102,6 +109,7 @@ const WalletsDetail = ({
102109
const [radiusContainerHeight, setRadiusContainerHeight] = useState(400);
103110
const [headerHeight, setHeaderHeight] = useState(0);
104111
const height = useSharedValue(0);
112+
const { t } = useTranslation('wallet');
105113

106114
const activityPadding = useMemo(
107115
() => ({ paddingTop: radiusContainerHeight, paddingBottom: 230 }),
@@ -113,7 +121,16 @@ const WalletsDetail = ({
113121
}, [height, headerHeight]);
114122

115123
const toggleHideBalance = (): void => {
116-
dispatch(updateSettings({ hideBalance: !hideBalance }));
124+
const enabled = !hideBalance;
125+
dispatch(updateSettings({ hideBalance: enabled }));
126+
if (!ignoresHideBalanceToast && enabled) {
127+
showToast({
128+
type: 'info',
129+
title: t('balance_hidden_title'),
130+
description: t('balance_hidden_message'),
131+
});
132+
dispatch(ignoreHideBalanceToast());
133+
}
117134
};
118135

119136
const onScroll = useCallback(

src/screens/Wallets/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ import {
3434
hideOnboardingMessageSelector,
3535
showWidgetsSelector,
3636
} from '../../store/reselect/settings';
37+
import { showToast } from '../../utils/notifications';
38+
import { useTranslation } from 'react-i18next';
39+
import { ignoresHideBalanceToastSelector } from '../../store/reselect/user';
40+
import { ignoreHideBalanceToast } from '../../store/slices/user';
3741

3842
// Workaround for crash on Android
3943
// https://github.com/software-mansion/react-native-reanimated/issues/4306#issuecomment-1538184321
@@ -51,6 +55,9 @@ const Wallets = ({ navigation, onFocus }: Props): ReactElement => {
5155
enableSwipeToHideBalanceSelector,
5256
);
5357
const hideBalance = useAppSelector(hideBalanceSelector);
58+
const ignoresHideBalanceToast = useAppSelector(
59+
ignoresHideBalanceToastSelector,
60+
);
5461
const hideOnboardingSetting = useAppSelector(hideOnboardingMessageSelector);
5562
const showWidgets = useAppSelector(showWidgetsSelector);
5663
const widgets = useAppSelector(widgetsSelector);
@@ -59,6 +66,7 @@ const Wallets = ({ navigation, onFocus }: Props): ReactElement => {
5966
const empty = useMemo(() => {
6067
return noTransactions && Object.values(widgets).length === 0;
6168
}, [noTransactions, widgets]);
69+
const { t } = useTranslation('wallet');
6270

6371
// tell WalletNavigator that this screen is focused
6472
useFocusEffect(
@@ -69,7 +77,16 @@ const Wallets = ({ navigation, onFocus }: Props): ReactElement => {
6977
);
7078

7179
const toggleHideBalance = (): void => {
72-
dispatch(updateSettings({ hideBalance: !hideBalance }));
80+
const enabled = !hideBalance;
81+
dispatch(updateSettings({ hideBalance: enabled }));
82+
if (!ignoresHideBalanceToast && enabled) {
83+
showToast({
84+
type: 'info',
85+
title: t('balance_hidden_title'),
86+
description: t('balance_hidden_message'),
87+
});
88+
dispatch(ignoreHideBalanceToast());
89+
}
7390
};
7491

7592
const navigateToScanner = (): void => {

src/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const persistConfig = {
4040
key: 'root',
4141
storage: mmkvStorage,
4242
// increase version after store shape changes
43-
version: 31,
43+
version: 32,
4444
stateReconciler: autoMergeLevel2,
4545
blacklist: ['receive', 'ui'],
4646
migrate: createMigrate(migrations, { debug: __ENABLE_MIGRATION_DEBUG__ }),

src/store/migrations/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ const migrations = {
333333
},
334334
};
335335
},
336+
32: (state): PersistedState => {
337+
return {
338+
...state,
339+
user: {
340+
...state.user,
341+
ignoresHideBalanceToast: false,
342+
},
343+
};
344+
},
336345
};
337346

338347
export default migrations;

src/store/reselect/user.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ export const betaRiskAcceptedSelector = createSelector(
5353
[userState],
5454
(user): boolean => user.betaRiskAccepted,
5555
);
56+
57+
export const ignoresHideBalanceToastSelector = createSelector(
58+
[userState],
59+
(user): boolean => user.ignoresHideBalanceToast,
60+
);

src/store/slices/user.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type TUser = {
1313
lightningSettingUpStep: number;
1414
requiresRemoteRestore: boolean;
1515
startCoopCloseTimestamp: number;
16+
ignoresHideBalanceToast: boolean;
1617
};
1718

1819
export const initialUserState: TUser = {
@@ -26,6 +27,7 @@ export const initialUserState: TUser = {
2627
lightningSettingUpStep: 0,
2728
requiresRemoteRestore: false,
2829
startCoopCloseTimestamp: 0,
30+
ignoresHideBalanceToast: false,
2931
};
3032

3133
export const userSlice = createSlice({
@@ -61,6 +63,9 @@ export const userSlice = createSlice({
6163
acceptBetaRisk: (state) => {
6264
state.betaRiskAccepted = true;
6365
},
66+
ignoreHideBalanceToast: (state) => {
67+
state.ignoresHideBalanceToast = true;
68+
},
6469
resetUserState: () => initialUserState,
6570
},
6671
});
@@ -77,6 +82,7 @@ export const {
7782
clearCoopCloseTimer,
7883
verifyBackup,
7984
acceptBetaRisk,
85+
ignoreHideBalanceToast,
8086
resetUserState,
8187
} = actions;
8288

src/utils/i18n/locales/en/wallet.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,7 @@
191191
"lnurl_w_success_title": "Success",
192192
"lnurl_w_success_description": "Withdraw Requested Successful",
193193
"lnurl_p_title": "Send Bitcoin",
194-
"lnurl_p_max": "Maximum amount"
194+
"lnurl_p_max": "Maximum amount",
195+
"balance_hidden_title" : "Wallet Balance Hidden",
196+
"balance_hidden_message" : "Swipe your wallet balance to reveal it again."
195197
}

0 commit comments

Comments
 (0)