From 6641e2612cc478e5e9f64059c19ad97e5b1288cb Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Thu, 26 Sep 2024 03:46:16 +0200 Subject: [PATCH 01/16] button refactor part 1 --- apps/wallet-mobile/src/AppNavigator.tsx | 187 ++++++------ .../src/components/Button/Button.stories.tsx | 278 ++++++++++++++---- .../src/components/Button/Button.tsx | 86 +----- .../src/components/Button/NewButton.tsx | 195 ++++++++++++ .../Clipboard/ClipboardProvider.tsx | 97 ++++++ .../src/components/CopyButton.tsx | 100 ++----- .../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 | 8 +- .../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 +- .../src/components/Icon/index.ts | 5 + .../ShareQRCodeCard.stories.tsx | 1 - .../ShareQRCodeCard/ShareQRCodeCard.tsx | 46 +-- .../Claim/useCases/AskConfirmation.tsx | 21 +- .../Exchange/common/AmountCard/AmountCard.tsx | 6 +- .../common/ShowBuyBanner/BuyBannerBig.tsx | 12 +- .../common/ShowBuyBanner/BuyBannerSmall.tsx | 13 +- .../ChooseBiometricLoginScreen.tsx | 12 +- .../MediaDetailsScreen/MediaDetailsScreen.tsx | 25 +- .../common/TokenAmountItem/TokenInfoIcon.tsx | 2 +- .../BuyADABanner/BuyADABanner.tsx | 17 +- .../DashboardTokensList/TradeTokensBanner.tsx | 17 +- .../PortfolioTokenDetails/Actions.tsx | 21 +- .../PortfolioTokenInfo/Overview/Overview.tsx | 17 +- .../TradeTokensBannerBig.tsx | 17 +- .../AddressDetailCard/AddressDetailCard.tsx | 10 +- .../SingleOrMultipleAddressesModal.tsx | 21 +- .../SmallAddressCard/SmallAddressCard.tsx | 36 +-- .../DescribeSelectedAddressScreen.tsx | 49 ++- .../useCases/ListMultipleAddressesScreen.tsx | 2 +- .../useCases/RequestSpecificAmountScreen.tsx | 32 +- .../useCases/ShowQrCode/ShowQrCode.tsx | 8 +- .../Settings/SettingsScreenNavigator.tsx | 4 +- .../common/ButtonCard/ButtonCard.tsx | 6 +- .../CardAboutPhrase/CardAboutPhrase.tsx | 6 +- .../ChooseMnemonicTypeScreen.tsx | 4 +- .../ChooseSetupType/ChooseSetupTypeScreen.tsx | 6 +- .../CreateWallet/RecoveryPhraseScreen.tsx | 10 +- .../VerifyRecoveryPhraseScreen.tsx | 2 +- .../CreateWallet/WalletDetailsScreen.tsx | 2 +- .../RestoreHwWallet/SaveNanoXScreen.tsx | 2 +- .../SelectHwConnectionModal.tsx | 20 +- .../MnemonicInput/MnemonicInput.tsx | 6 +- .../RestoreWalletDetailsScreen.tsx | 2 +- .../Swap/common/AmountCard/AmountCard.tsx | 8 +- .../EditBuyAmount/EditBuyAmount.tsx | 2 +- .../EditSellAmount/EditSellAmount.tsx | 2 +- .../ListOrders/OpenOrders.tsx | 14 +- .../TxDetails/AddressModal/AddressModal.tsx | 32 +- .../useCases/TxDetails/TxDetails.tsx | 13 +- .../useCases/TxHistory/ActionsBanner.tsx | 33 +-- apps/wallet-mobile/src/hooks/useCopy.ts | 22 -- .../src/legacy/Dashboard/UserSummary.tsx | 21 +- .../Staking/FailedTx/FailedTxScreen.tsx | 9 +- .../PoolTransition/PoolTransitionModal.tsx | 27 +- .../messages/src/AppNavigator.json | 32 +- .../MediaDetailsScreen.json | 88 +++--- .../src/legacy/Dashboard/UserSummary.json | 32 +- .../Staking/FailedTx/FailedTxScreen.json | 32 +- 199 files changed, 1245 insertions(+), 1604 deletions(-) create mode 100644 apps/wallet-mobile/src/components/Button/NewButton.tsx create mode 100644 apps/wallet-mobile/src/components/Clipboard/ClipboardProvider.tsx 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 9057d5410f..23503bdffd 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' @@ -100,114 +101,116 @@ 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/Button/Button.stories.tsx b/apps/wallet-mobile/src/components/Button/Button.stories.tsx index 43c1c62fe3..104b316ea1 100644 --- a/apps/wallet-mobile/src/components/Button/Button.stories.tsx +++ b/apps/wallet-mobile/src/components/Button/Button.stories.tsx @@ -1,100 +1,252 @@ -import {action} from '@storybook/addon-actions' import {storiesOf} from '@storybook/react-native' import {useTheme} from '@yoroi/theme' import React from 'react' import {ScrollView, StyleSheet, View, ViewProps} from 'react-native' -import icon from '../../assets/img/icon/dashboard.png' +import {Accordion} from '../Accordion/Accordion' import {Icon} from '../Icon' -import {Button} from './Button' +import {Button, ButtonType} from './NewButton' storiesOf('Button', module).add('default', () => { const {color, isDark, selectThemeName} = useTheme() + const [expanded, setExpanded] = React.useState(ButtonType.Primary) return ( - - + +