From 7376022cfa0a3a1cad7d2b8b8b18f736b6953af9 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Fri, 11 Oct 2024 12:13:28 +0200 Subject: [PATCH 01/15] refactor(wallet-mobile): Button, IconProps, useCopy (#3658) --- apps/wallet-mobile/src/AppNavigator.tsx | 185 +++++----- .../src/components/Analytics/Analytics.tsx | 17 +- .../src/components/Boundary/Boundary.tsx | 3 - .../src/components/Button/Button.stories.tsx | 284 ++++++++++---- .../src/components/Button/Button.tsx | 348 +++++++++--------- .../Clipboard/ClipboardProvider.tsx | 97 +++++ .../ConfirmTx/ConfirmTx.stories.tsx | 1 - .../src/components/ConfirmTx/ConfirmTx.tsx | 1 - .../ConfirmTxWithSpendingPasswordModal.tsx | 1 - .../src/components/CopyButton.tsx | 100 +---- .../ErrorBoundary/ErrorBoundary.tsx | 2 +- .../src/components/ErrorModal/ErrorModal.tsx | 8 +- .../wallet-mobile/src/components/Icon/Ada.tsx | 6 +- .../src/components/Icon/Analytics.tsx | 6 +- .../src/components/Icon/AngleDown.tsx | 6 +- .../src/components/Icon/AngleUp.tsx | 6 +- .../src/components/Icon/ArrowDown.tsx | 7 +- .../src/components/Icon/ArrowRight.tsx | 7 +- .../src/components/Icon/Assets.tsx | 7 +- .../src/components/Icon/Backspace.tsx | 7 +- .../src/components/Icon/Backward.tsx | 7 +- .../wallet-mobile/src/components/Icon/Bio.tsx | 7 +- .../src/components/Icon/Bluetooth.tsx | 11 +- .../wallet-mobile/src/components/Icon/Bug.tsx | 4 +- .../src/components/Icon/Burger.tsx | 7 +- .../src/components/Icon/Cardano.tsx | 12 +- .../src/components/Icon/Catalyst.tsx | 7 +- .../src/components/Icon/Categories.tsx | 7 +- .../src/components/Icon/Change.tsx | 8 +- .../src/components/Icon/Check.tsx | 9 +- .../src/components/Icon/CheckFilled.tsx | 7 +- .../src/components/Icon/CheckFilled2.tsx | 7 +- .../src/components/Icon/CheckOutlined.tsx | 7 +- .../src/components/Icon/Checkbox.tsx | 12 +- .../src/components/Icon/Chevron.tsx | 9 +- .../src/components/Icon/Clock.tsx | 7 +- .../src/components/Icon/Close.tsx | 7 +- .../src/components/Icon/Coins.tsx | 7 +- .../src/components/Icon/Coins2.tsx | 7 +- .../src/components/Icon/Collateral.tsx | 7 +- .../src/components/Icon/Connection.tsx | 7 +- .../src/components/Icon/Copy.tsx | 7 +- .../src/components/Icon/CopySuccess.tsx | 7 +- .../src/components/Icon/Cross.tsx | 7 +- .../src/components/Icon/CrossCircle.tsx | 7 +- .../src/components/Icon/DApp.tsx | 7 +- .../src/components/Icon/Danger.tsx | 7 +- .../src/components/Icon/DappConnector.tsx | 7 +- .../src/components/Icon/Delete.tsx | 7 +- .../src/components/Icon/Device.tsx | 7 +- .../src/components/Icon/DigitalAsset.tsx | 7 +- .../src/components/Icon/Direction.tsx | 13 +- .../src/components/Icon/Disconnect.tsx | 7 +- .../src/components/Icon/Document.tsx | 10 +- .../src/components/Icon/Drag.tsx | 7 +- .../src/components/Icon/Edit.tsx | 4 +- .../src/components/Icon/EmptyCheckbox.tsx | 12 +- .../src/components/Icon/Emurgo.tsx | 9 +- .../src/components/Icon/Exchange.tsx | 4 +- .../src/components/Icon/Export.tsx | 4 +- .../src/components/Icon/ExternalLink.tsx | 7 +- .../src/components/Icon/EyeOff.tsx | 7 +- .../src/components/Icon/EyeOn.tsx | 7 +- .../src/components/Icon/Facebook.tsx | 7 +- .../src/components/Icon/Forward.tsx | 7 +- .../src/components/Icon/Gear.tsx | 7 +- .../src/components/Icon/Github.tsx | 7 +- .../src/components/Icon/Globe.tsx | 7 +- .../src/components/Icon/Google.tsx | 6 +- .../src/components/Icon/Governance.tsx | 7 +- .../src/components/Icon/HardwareWallet.tsx | 12 +- .../src/components/Icon/Icon.stories.tsx | 22 +- .../src/components/Icon/Image.tsx | 7 +- .../src/components/Icon/Info.tsx | 11 +- .../src/components/Icon/InfoCircle.tsx | 7 +- .../src/components/Icon/Language.tsx | 11 +- .../src/components/Icon/Launchpad.tsx | 7 +- .../src/components/Icon/Ledger.tsx | 12 +- .../src/components/Icon/Lightning.tsx | 7 +- .../src/components/Icon/Link.tsx | 7 +- .../src/components/Icon/Lock.tsx | 7 +- .../src/components/Icon/LockFilled.tsx | 7 +- .../src/components/Icon/Logout.tsx | 7 +- .../src/components/Icon/Magnify.tsx | 7 +- .../src/components/Icon/Megaphone.tsx | 7 +- .../src/components/Icon/Message.tsx | 7 +- .../src/components/Icon/MinSwap.tsx | 6 +- .../src/components/Icon/MuesliSwap.tsx | 6 +- .../src/components/Icon/MultiParty.tsx | 9 +- .../src/components/Icon/MultipleWallets.tsx | 7 +- .../src/components/Icon/NftAsset.tsx | 7 +- .../src/components/Icon/NoNfts.tsx | 6 +- .../wallet-mobile/src/components/Icon/Pin.tsx | 7 +- .../src/components/Icon/Placeholder.tsx | 7 +- .../src/components/Icon/PlateNumber.tsx | 7 +- .../src/components/Icon/Plus.tsx | 7 +- .../src/components/Icon/PlusCircle.tsx | 7 +- .../src/components/Icon/Portfolio.tsx | 7 +- apps/wallet-mobile/src/components/Icon/Qr.tsx | 7 +- .../src/components/Icon/QuestionMark.tsx | 7 +- .../src/components/Icon/Received.tsx | 7 +- .../src/components/Icon/Refresh.tsx | 8 +- .../src/components/Icon/Reload.tsx | 7 +- .../src/components/Icon/Resync.tsx | 7 +- .../components/Icon/RewardManuallyPayout.tsx | 10 +- .../src/components/Icon/RewardWithdrawn.tsx | 10 +- .../src/components/Icon/Sandbox.tsx | 7 +- .../src/components/Icon/Send.tsx | 7 +- .../src/components/Icon/Settings.tsx | 7 +- .../src/components/Icon/Share.tsx | 7 +- .../src/components/Icon/Share2.tsx | 7 +- .../src/components/Icon/SliderSettings.tsx | 7 +- .../src/components/Icon/SortTable.tsx | 7 +- .../src/components/Icon/SpectrumSwap.tsx | 6 +- .../src/components/Icon/Square.tsx | 7 +- .../src/components/Icon/Staking.tsx | 7 +- .../Icon/StakingKeyDeregistered.tsx | 10 +- .../components/Icon/StakingKeyRegistered.tsx | 10 +- .../src/components/Icon/StarFilled.tsx | 7 +- .../src/components/Icon/StarOutlined.tsx | 7 +- .../src/components/Icon/SundaeSwap.tsx | 6 +- .../src/components/Icon/Support.tsx | 7 +- .../src/components/Icon/Swap.tsx | 4 +- .../src/components/Icon/Switch.tsx | 4 +- .../src/components/Icon/TabDiscover.tsx | 7 +- .../src/components/Icon/TabDiscoverActive.tsx | 7 +- .../src/components/Icon/TabMenu.tsx | 7 +- .../src/components/Icon/TabMenuActive.tsx | 7 +- .../src/components/Icon/TabPortfolio.tsx | 4 +- .../components/Icon/TabPortfolioActive.tsx | 7 +- .../src/components/Icon/TabStaking.tsx | 4 +- .../src/components/Icon/TabWallet.tsx | 7 +- .../src/components/Icon/TabWalletActive.tsx | 7 +- .../src/components/Icon/Table.tsx | 7 +- .../src/components/Icon/Telegram.tsx | 7 +- .../src/components/Icon/TermsOfUse.tsx | 7 +- .../src/components/Icon/Theme.tsx | 7 +- .../src/components/Icon/ThumbsUp.tsx | 7 +- .../src/components/Icon/Tokens.tsx | 7 +- .../src/components/Icon/TotalAda.tsx | 13 +- .../src/components/Icon/TotalDelegated.tsx | 15 +- .../src/components/Icon/TotalReward.tsx | 13 +- .../src/components/Icon/Transaction.tsx | 7 +- .../src/components/Icon/Twitter.tsx | 7 +- .../wallet-mobile/src/components/Icon/Usb.tsx | 11 +- .../src/components/Icon/Verify.tsx | 8 +- .../src/components/Icon/VyfiSwap.tsx | 6 +- .../src/components/Icon/Wallet.tsx | 7 +- .../src/components/Icon/WalletAvatar.tsx | 8 +- .../src/components/Icon/WalletStack.tsx | 7 +- .../src/components/Icon/Wallets.tsx | 7 +- .../src/components/Icon/Warning.tsx | 7 +- .../src/components/Icon/WingRiders.tsx | 7 +- .../src/components/Icon/YoroiApp.tsx | 6 +- .../src/components/Icon/YoroiNightly.tsx | 7 +- .../src/components/Icon/YoroiWallet.tsx | 10 +- .../wallet-mobile/src/components/Icon/type.ts | 4 + .../src/components/ModalError/ModalError.tsx | 6 +- .../ShareQRCodeCard.stories.tsx | 1 - .../ShareQRCodeCard/ShareQRCodeCard.tsx | 46 +-- .../TwoActionView/TwoActionView.tsx | 10 +- .../Auth/OsLoginScreen/OsLoginScreen.tsx | 2 +- .../Claim/useCases/AskConfirmation.tsx | 21 +- .../Claim/useCases/ShowSuccessScreen.tsx | 2 +- .../src/features/Dev/DeveloperScreen.tsx | 1 - .../common/ConfirmConnectionModal.stories.tsx | 4 +- .../common/ConfirmConnectionModal.tsx | 2 +- .../Discover/common/HWNotSupportedModal.tsx | 2 +- .../common/UnverifiedDappModal.stories.tsx | 2 +- .../Discover/common/UnverifiedDappModal.tsx | 2 +- .../ReviewTransaction/ReviewTransaction.tsx | 2 +- .../SelectDappFromList/WelcomeDAppModal.tsx | 2 +- .../Exchange/common/AmountCard/AmountCard.tsx | 6 +- .../common/ShowBuyBanner/BuyBannerBig.tsx | 15 +- .../common/ShowBuyBanner/BuyBannerSmall.tsx | 76 ++-- .../ShowBuyBanner/PreprodFaucetBanner.tsx | 52 ++- .../ShowBuyBanner/SanchonetFaucetBanner.tsx | 52 ++- .../common/ShowBuyBanner/ShowBuyBanner.tsx | 22 +- .../CreateExchangeButton.tsx | 2 +- .../LoadingLink/ErrorScreen.tsx | 8 +- .../ShowExchangeResultOrderScreen.tsx | 2 +- .../ChooseBiometricLoginScreen.tsx | 12 +- .../DarkThemeAnnouncement.tsx | 2 +- .../InitialScreen/InitialScreen.tsx | 8 +- .../TermsOfServiceChangedScreen.tsx | 2 +- .../AskToOpenAWalletScreen.tsx | 6 +- .../AskToRedirect/AskToRedirectScreen.tsx | 6 +- .../RequestedAdaPaymentWithLinkScreen.tsx | 6 +- .../RequestedBrowserLaunchDappUrlScreen.tsx | 6 +- .../MediaDetailsScreen/MediaDetailsScreen.tsx | 25 +- .../common/TokenAmountItem/TokenInfoIcon.tsx | 2 +- .../BuyADABanner/BuyADABanner.tsx | 15 +- .../DashboardTokensList/TradeTokensBanner.tsx | 15 +- .../PortfolioTokenDetails/Actions.tsx | 20 +- .../PortfolioTokenInfo/Overview/Overview.tsx | 17 +- .../TradeTokensBannerBig.tsx | 15 +- .../AddressDetailCard/AddressDetailCard.tsx | 10 +- .../SingleOrMultipleAddressesModal.tsx | 21 +- .../SmallAddressCard/SmallAddressCard.tsx | 36 +- .../DescribeSelectedAddressScreen.tsx | 49 ++- .../useCases/ListMultipleAddressesScreen.tsx | 3 +- .../useCases/RequestSpecificAmountScreen.tsx | 30 +- .../common/InsufficientFundsModal.tsx | 6 +- .../useCases/ConfirmPin/ConfirmPin.tsx | 2 +- .../ConfirmVotingTx/ConfirmVotingTx.tsx | 2 +- .../useCases/DisplayPin/DisplayPin.tsx | 2 +- .../DownloadCatalystAppScreen.tsx | 7 +- .../useCases/ShowQrCode/ShowQrCode.tsx | 10 +- .../features/ReviewTx/common/CopiableText.tsx | 6 +- .../features/ReviewTx/common/TokenDetails.tsx | 6 +- .../ReviewTxScreen/ReviewTxScreen.tsx | 2 +- .../OpenDeviceAppSettingsButton.tsx | 4 +- .../ShowCameraPermissionDeniedScreen.tsx | 10 +- .../ConfirmTx/FailedTx/FailedTxScreen.tsx | 7 +- .../SubmittedTx/SubmittedTxScreen.tsx | 2 +- .../EditAmount/EditAmountScreen.tsx | 1 - .../ListAmountsToSendScreen.tsx | 7 +- .../StartMultiTokenTxScreen.tsx | 8 +- .../ChangeNetwork/ChangeNetworkScreen.tsx | 1 - .../Settings/ChangeNetwork/NetworkTag.tsx | 6 +- .../ChangePassword/ChangePasswordScreen.tsx | 1 - .../DisableEasyConfirmationScreen.tsx | 2 +- .../EnableEasyConfirmationScreen.tsx | 1 - .../EnableLoginWithOsScreen.tsx | 20 +- .../ConfirmTx/FailedTx/FailedTxScreen.tsx | 2 +- .../SubmittedTx/SubmittedTxScreen.tsx | 2 +- .../InitialCollateralInfoModal.tsx | 2 +- .../ManageCollateralScreen.tsx | 9 +- .../RenameWalletScreen/RenameWalletScreen.tsx | 1 - .../Settings/SettingsScreenNavigator.tsx | 4 +- .../common/ButtonCard/ButtonCard.tsx | 6 +- .../CardAboutPhrase/CardAboutPhrase.tsx | 6 +- .../SaveReadOnlyWalletScreen.tsx | 4 - .../legacy/WalletNameForm/WalletNameForm.tsx | 8 - .../ChooseMnemonicTypeScreen.tsx | 4 +- .../ChooseSetupType/ChooseSetupTypeScreen.tsx | 6 +- .../AboutRecoveryPhraseScreen.tsx | 1 - .../CreateWallet/RecoveryPhraseScreen.tsx | 12 +- .../VerifyRecoveryPhraseScreen.tsx | 3 +- .../CreateWallet/WalletDetailsScreen.tsx | 6 +- .../RestoreHwWallet/CheckNanoXScreen.tsx | 2 +- .../RestoreHwWallet/SaveNanoXScreen.tsx | 7 +- .../SelectHwConnectionModal.tsx | 20 +- .../MnemonicInput/MnemonicInput.tsx | 6 +- .../RestoreWalletDetailsScreen.tsx | 7 +- .../RestoreWallet/RestoreWalletScreen.tsx | 7 +- .../useCases/ConfirmTx/ConfirmTxScreen.tsx | 2 +- .../EnterDrepIdModal/EnterDrepIdModal.tsx | 1 - .../useCases/FailedTx/FailedTxScreen.tsx | 6 +- .../useCases/NoFunds/NoFundsScreen.tsx | 6 +- .../NotSupportedCardanoAppVersion.tsx | 2 +- .../useCases/SuccessTx/SuccessTxScreen.tsx | 6 +- .../WithdrawWarningModal.tsx | 2 +- .../Swap/common/AmountCard/AmountCard.tsx | 8 +- .../ConfirmWithSpendingPassword.tsx | 1 - .../ServiceUnavailable/ServiceUnavailable.tsx | 2 +- .../ConfirmTxScreen/ConfirmTxScreen.tsx | 1 - .../ConfirmTxScreen/LedgerTransportSwitch.tsx | 8 +- .../ShowFailedTxScreen/ShowFailedTxScreen.tsx | 2 +- .../ShowSubmittedTxScreen.tsx | 22 +- .../EditBuyAmount/EditBuyAmount.tsx | 2 +- .../EditSellAmount/EditSellAmount.tsx | 2 +- .../EditSlippageScreen/EditSlippageScreen.tsx | 8 +- .../CreateOrder/StartSwapOrderScreen.tsx | 2 +- .../WarnLimitPrice/WarnLimitPrice.tsx | 17 +- .../WarnPriceImpact/WarnPriceImpact.tsx | 14 +- .../CreateOrder/WarnSlippage/WarnSlippage.tsx | 17 +- .../ListOrders/OpenOrders.tsx | 14 +- .../TxDetails/AddressModal/AddressModal.tsx | 32 +- .../useCases/TxDetails/TxDetails.tsx | 14 +- .../useCases/TxHistory/ActionsBanner.tsx | 178 +++------ apps/wallet-mobile/src/hooks/useCopy.ts | 22 -- .../src/kernel/i18n/global-messages.ts | 2 +- .../src/kernel/i18n/locales/en-US.json | 2 +- .../src/legacy/Dashboard/Dashboard.tsx | 2 - .../src/legacy/Dashboard/StakePoolInfo.tsx | 54 +-- .../src/legacy/Dashboard/UserSummary.tsx | 45 +-- .../ConfirmTx/ConfirmTxWithPassword.tsx | 12 +- .../WithdrawStakingRewards.tsx | 1 - .../legacy/HW/LedgerConnect/LedgerConnect.tsx | 1 - .../LedgerTransportSwitchModal.tsx | 10 +- .../DelegationConfirmation.tsx | 1 - .../Staking/FailedTx/FailedTxScreen.tsx | 9 +- .../Staking/PoolDetails/PoolDetailScreen.tsx | 1 - .../PoolTransition/PoolTransitionModal.tsx | 27 +- .../PoolTransition/PoolTransitionNotice.tsx | 2 +- .../messages/src/AppNavigator.json | 32 +- .../src/components/Analytics/Analytics.json | 88 ++--- .../src/components/ErrorModal/ErrorModal.json | 16 +- .../Auth/OsLoginScreen/OsLoginScreen.json | 4 +- .../DarkThemeAnnouncement.json | 16 +- .../MediaDetailsScreen.json | 88 ++--- .../ListAmountsToSendScreen.json | 8 +- .../ChangePassword/ChangePasswordScreen.json | 48 +-- .../DisableEasyConfirmationScreen.json | 8 +- .../EnableEasyConfirmationScreen.json | 32 +- .../EnableLoginWithOsScreen.json | 40 +- .../RenameWalletScreen.json | 16 +- .../Settings/SettingsScreenNavigator.json | 160 ++++---- .../WalletSettings/WalletSettingsScreen.json | 168 ++++----- .../SaveReadOnlyWalletScreen.json | 40 +- .../legacy/WalletNameForm/WalletNameForm.json | 16 +- .../src/kernel/i18n/global-messages.json | 232 ++++++------ .../src/legacy/Dashboard/Dashboard.json | 8 +- .../src/legacy/Dashboard/StakePoolInfo.json | 40 +- .../src/legacy/Dashboard/UserSummary.json | 32 +- .../WithdrawStakingRewards.json | 72 ++-- .../HW/LedgerConnect/LedgerConnect.json | 32 +- .../LedgerTransportSwitchModal.json | 64 ++-- .../DelegationConfirmation.json | 32 +- .../Staking/FailedTx/FailedTxScreen.json | 32 +- .../Staking/PoolDetails/PoolDetailScreen.json | 56 +-- 312 files changed, 2105 insertions(+), 2854 deletions(-) create mode 100644 apps/wallet-mobile/src/components/Clipboard/ClipboardProvider.tsx create mode 100644 apps/wallet-mobile/src/components/Icon/type.ts delete mode 100644 apps/wallet-mobile/src/hooks/useCopy.ts diff --git a/apps/wallet-mobile/src/AppNavigator.tsx b/apps/wallet-mobile/src/AppNavigator.tsx index 69d986fd38..108013fb24 100644 --- a/apps/wallet-mobile/src/AppNavigator.tsx +++ b/apps/wallet-mobile/src/AppNavigator.tsx @@ -9,6 +9,7 @@ import {Alert, AppState, AppStateStatus, InteractionManager, Platform} from 'rea import RNBootSplash from 'react-native-bootsplash' import StorybookScreen from '../.storybook' +import {ClipboardProvider} from './components/Clipboard/ClipboardProvider' import {ModalProvider} from './components/Modal/ModalContext' import {ModalScreen} from './components/Modal/ModalScreen' import {useAuth} from './features/Auth/AuthProvider' @@ -99,112 +100,114 @@ export const AppNavigator = () => { onReady={onReady} ref={navRef} > - - - {/* Not Authenticated */} - - {isLoggedOut && ( - - {firstAction === 'first-run' && ( - - {() => ( - - - - )} - - )} - - {firstAction === 'show-agreement-changed-notice' && ( - {() => } - )} - - {firstAction === 'auth-with-pin' && ( - - )} - - {firstAction === 'auth-with-os' && ( - - )} - - {firstAction === 'request-new-pin' && ( - - )} - - )} - - {/* Authenticated */} - - {isLoggedIn && ( - <> + + + + {/* Not Authenticated */} + + {isLoggedOut && ( - {afterLoginAction === 'choose-biometric-login' && ( - + {firstAction === 'first-run' && ( + + {() => ( + + + + )} + )} - {afterLoginAction === 'dark-theme-announcement' && ( - + {firstAction === 'show-agreement-changed-notice' && ( + {() => } )} - {afterLoginAction === 'setup-wallet' && ( - )} - {afterLoginAction === 'manage-wallets' && ( - WalletNavigator} /> + {firstAction === 'auth-with-os' && ( + )} - - - + {firstAction === 'request-new-pin' && ( + + )} - - )} + )} + + {/* Authenticated */} + + {isLoggedIn && ( + <> + + {afterLoginAction === 'choose-biometric-login' && ( + + )} + + {afterLoginAction === 'dark-theme-announcement' && ( + + )} - {/* Development */} + {afterLoginAction === 'setup-wallet' && ( + + )} - {__DEV__ && ( - - + {afterLoginAction === 'manage-wallets' && ( + WalletNavigator} /> + )} + + + + + + + )} + + {/* Development */} + + {__DEV__ && ( + + - + - - - )} - - + + + )} + + + ) } diff --git a/apps/wallet-mobile/src/components/Analytics/Analytics.tsx b/apps/wallet-mobile/src/components/Analytics/Analytics.tsx index 1f580b428f..0e433a0a40 100644 --- a/apps/wallet-mobile/src/components/Analytics/Analytics.tsx +++ b/apps/wallet-mobile/src/components/Analytics/Analytics.tsx @@ -4,12 +4,12 @@ import {defineMessages, useIntl} from 'react-intl' import {StyleSheet, TextStyle, TouchableOpacity, useWindowDimensions, View} from 'react-native' import {ScrollView} from 'react-native-gesture-handler' -import {Button} from '../../components/Button/Button' import {Spacer} from '../../components/Spacer/Spacer' import {Text} from '../../components/Text' import {YoroiLogo} from '../../components/YoroiLogo/YoroiLogo' import {SettingsSwitch} from '../../features/Settings/common/SettingsSwitch' import {useMetrics} from '../../kernel/metrics/metricsManager' +import {Button, ButtonType} from '../Button/Button' import {AnalyticsImage} from './AnalyticsImage' type Props = { @@ -64,15 +64,13 @@ const Notice = ({onClose, onReadMore}: {onClose?: () => void; onReadMore?: () =>