From 78e120598877ab70ea2f7ffe3d130f4744be4d6d Mon Sep 17 00:00:00 2001 From: Max Voloshinskii Date: Wed, 1 May 2024 20:20:32 +0300 Subject: [PATCH] fix button && danger banner && refactor --- .../src/core/HideableAmount/ShowBalance.tsx | 48 ++++++++++++++- .../src/screens/BackupScreen/BackupScreen.tsx | 51 +++++++++++++++- .../ImportWalletForm/ImportWalletForm.tsx | 56 +++++++++++------- .../mobile/src/tabs/Wallet/WalletScreen.tsx | 5 +- .../dependencies/inscriptions.ts | 11 +--- .../content-providers/dependencies/jettons.ts | 12 ++-- .../content-providers/dependencies/staking.ts | 11 +--- .../dependencies/stakingJettons.ts | 11 +--- .../dependencies/tokenApproval.ts | 11 +--- .../dependencies/tonBalances.ts | 11 +--- .../dependencies/tonPrice.ts | 12 ++-- .../dependencies/utils/prototype.ts | 5 +- .../Wallet/content-providers/inscriptions.ts | 1 + .../content-providers/utils/receiver.ts | 34 ++++++----- .../Wallet/content-providers/utils/types.ts | 1 + .../utils/usePreparedWalletContent.ts | 12 ++-- .../src/tabs/Wallet/hooks/useBalance.ts | 40 +++++++++---- .../mobile/src/wallet/Wallet/WalletContent.ts | 28 +++++++++ packages/shared/hooks/index.ts | 1 + packages/shared/hooks/useDangerLevel.ts | 25 ++++++++ .../shared/i18n/locales/tonkeeper/en.json | 1 + .../shared/i18n/locales/tonkeeper/ru-RU.json | 1 + .../icons/png/ic-information-circle-24@4x.png | Bin 0 -> 1681 bytes .../icons/svg/24/ic-information-circle-24.svg | 4 ++ packages/uikit/src/components/Icon/Icon.tsx | 1 + .../uikit/src/components/Icon/Icon.types.ts | 3 + .../src/components/Icon/IconList.native.ts | 1 + packages/uikit/src/components/Text/Text.tsx | 1 + packages/uikit/src/styles/themes/dark.ts | 2 +- 29 files changed, 275 insertions(+), 125 deletions(-) create mode 100644 packages/shared/hooks/useDangerLevel.ts create mode 100644 packages/uikit/assets/icons/png/ic-information-circle-24@4x.png create mode 100644 packages/uikit/assets/icons/svg/24/ic-information-circle-24.svg diff --git a/packages/mobile/src/core/HideableAmount/ShowBalance.tsx b/packages/mobile/src/core/HideableAmount/ShowBalance.tsx index b6890c3c1..aa8417ab0 100644 --- a/packages/mobile/src/core/HideableAmount/ShowBalance.tsx +++ b/packages/mobile/src/core/HideableAmount/ShowBalance.tsx @@ -5,19 +5,41 @@ import { Steezy } from '$styles'; import { Pressable, View } from '$uikit'; import { Haptics, isAndroid } from '$utils'; import { DarkTheme } from '$styled'; -import { Text } from '@tonkeeper/uikit'; +import { Icon, Text } from '@tonkeeper/uikit'; +import { DangerLevel } from '@tonkeeper/shared/hooks'; +import { useNavigation } from '@tonkeeper/router'; +import { SettingsStackRouteNames } from '$navigation'; const TouchableComponent = isAndroid ? Pressable : TouchableHighlight; -export const ShowBalance: React.FC<{ amount: string }> = ({ amount }) => { +const getColorByDangerLevel = ( + dangerLevel: DangerLevel, +): undefined | 'accentOrange' | 'accentRed' => { + switch (dangerLevel) { + case DangerLevel.Normal: + return undefined; + case DangerLevel.Medium: + return 'accentOrange'; + case DangerLevel.High: + return 'accentRed'; + } +}; + +export const ShowBalance: React.FC<{ amount: string; dangerLevel: DangerLevel }> = ({ + amount, + dangerLevel, +}) => { const hideAmounts = usePrivacyStore((state) => state.actions.toggleHiddenAmounts); const isHidden = usePrivacyStore((state) => state.hiddenAmounts); + const nav = useNavigation(); const handleToggleHideAmounts = useCallback(() => { hideAmounts(); Haptics.impactHeavy(); }, [hideAmounts]); + const handleNavigateToBackup = () => nav.navigate(SettingsStackRouteNames.Backup); + return ( {isHidden ? ( @@ -34,7 +56,22 @@ export const ShowBalance: React.FC<{ amount: string }> = ({ amount }) => { ) : ( - {amount} + + {amount} + + + )} + {dangerLevel !== DangerLevel.Normal && ( + + )} @@ -46,6 +83,7 @@ const styles = Steezy.create(({ colors }) => ({ flexDirection: 'row', height: 54, alignItems: 'center', + gap: 8, }, starsContainer: { height: 40, @@ -59,4 +97,8 @@ const styles = Steezy.create(({ colors }) => ({ stars: { paddingTop: 8, }, + dangerButton: { + paddingTop: 21, + paddingBottom: 11, + }, })); diff --git a/packages/mobile/src/screens/BackupScreen/BackupScreen.tsx b/packages/mobile/src/screens/BackupScreen/BackupScreen.tsx index d5632b91b..563c99280 100644 --- a/packages/mobile/src/screens/BackupScreen/BackupScreen.tsx +++ b/packages/mobile/src/screens/BackupScreen/BackupScreen.tsx @@ -4,16 +4,51 @@ import { memo } from 'react'; import { format } from 'date-fns'; import { getLocale } from '$utils/date'; import { i18n, t } from '@tonkeeper/shared/i18n'; -import { useWalletSetup } from '@tonkeeper/shared/hooks'; +import { + DangerLevel, + useDangerLevel, + useWalletCurrency, + useWalletSetup, +} from '@tonkeeper/shared/hooks'; +import { tk } from '$wallet'; +import { formatter } from '@tonkeeper/shared/formatter'; export const BackupScreen = memo(() => { const { lastBackupAt } = useWalletSetup(); const nav = useNavigation(); + const currency = useWalletCurrency(); + const dangerLevel = useDangerLevel(tk.wallet.totalTon); + return ( + {dangerLevel !== DangerLevel.Normal && ( + <> + + + {t('backup_screen.backup_warning', { + totalFiat: formatter.format(tk.wallet.totalFiat, { currency }), + })} + + + + + )} {t('backup_screen.manual_title')} @@ -27,7 +62,7 @@ export const BackupScreen = memo(() => {