-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: Replace Settings modals with design-system BottomSheets #34847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
6622c78
a68d08f
c978ef0
0f84c1c
b2cf742
6020eff
46e6df1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,8 @@ | ||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||
| import { View } from 'react-native'; | ||||||||||||||||||
| import React, { useCallback, useRef } from 'react'; | ||||||||||||||||||
| import Text, { | ||||||||||||||||||
| TextVariant, | ||||||||||||||||||
| } from '../../../../../component-library/components/Texts/Text'; | ||||||||||||||||||
| import { strings } from '../../../../../../locales/i18n'; | ||||||||||||||||||
| import ActionModal from '../../../../UI/ActionModal'; | ||||||||||||||||||
| import { wipeTransactions } from '../../../../../util/transaction-controller'; | ||||||||||||||||||
| import { wipeSmartTransactions } from '../../../../../util/smart-transactions'; | ||||||||||||||||||
| import { wipeBridgeStatus } from '../../../../UI/Bridge/utils'; | ||||||||||||||||||
|
|
@@ -15,6 +13,13 @@ import { selectSelectedInternalAccountFormattedAddress } from '../../../../../se | |||||||||||||||||
| import { selectChainId } from '../../../../../selectors/networkController'; | ||||||||||||||||||
| import { usePerpsFirstTimeUser } from '../../../../UI/Perps/hooks/usePerpsFirstTimeUser'; | ||||||||||||||||||
| import { AdvancedViewSelectorsIDs } from '../AdvancedView.testIds'; | ||||||||||||||||||
| import { | ||||||||||||||||||
| BottomSheet, | ||||||||||||||||||
| BottomSheetFooter, | ||||||||||||||||||
| BottomSheetHeader, | ||||||||||||||||||
| type BottomSheetRef, | ||||||||||||||||||
| Box, | ||||||||||||||||||
| } from '@metamask/design-system-react-native'; | ||||||||||||||||||
|
|
||||||||||||||||||
| export const ResetAccountModal = ({ | ||||||||||||||||||
| resetModalVisible, | ||||||||||||||||||
|
|
@@ -27,14 +32,15 @@ export const ResetAccountModal = ({ | |||||||||||||||||
| styles: any; | ||||||||||||||||||
| }) => { | ||||||||||||||||||
| const navigation = useNavigation<AppNavigationProp>(); | ||||||||||||||||||
| const sheetRef = useRef<BottomSheetRef>(null); | ||||||||||||||||||
| const selectedAddress = useSelector( | ||||||||||||||||||
| selectSelectedInternalAccountFormattedAddress, | ||||||||||||||||||
| ); | ||||||||||||||||||
| const chainId = useSelector(selectChainId); | ||||||||||||||||||
| const { resetFirstTimeUserState, clearPendingTransactionRequests } = | ||||||||||||||||||
| usePerpsFirstTimeUser(); | ||||||||||||||||||
|
|
||||||||||||||||||
| const resetAccount = () => { | ||||||||||||||||||
| const resetAccount = useCallback(() => { | ||||||||||||||||||
| if (selectedAddress) { | ||||||||||||||||||
| wipeBridgeStatus(selectedAddress, chainId); | ||||||||||||||||||
| wipeSmartTransactions(selectedAddress); | ||||||||||||||||||
|
|
@@ -45,26 +51,57 @@ export const ResetAccountModal = ({ | |||||||||||||||||
| // Clear any stuck pending Perps transactions | ||||||||||||||||||
| clearPendingTransactionRequests(); | ||||||||||||||||||
| navigation.navigate('WalletView'); | ||||||||||||||||||
| }; | ||||||||||||||||||
| }, [ | ||||||||||||||||||
| chainId, | ||||||||||||||||||
| clearPendingTransactionRequests, | ||||||||||||||||||
| navigation, | ||||||||||||||||||
| resetFirstTimeUserState, | ||||||||||||||||||
| selectedAddress, | ||||||||||||||||||
| ]); | ||||||||||||||||||
|
|
||||||||||||||||||
| const handleRequestClose = useCallback(() => { | ||||||||||||||||||
| sheetRef.current?.onCloseBottomSheet(); | ||||||||||||||||||
| }, []); | ||||||||||||||||||
|
|
||||||||||||||||||
| const handleConfirm = useCallback(() => { | ||||||||||||||||||
| sheetRef.current?.onCloseBottomSheet(() => { | ||||||||||||||||||
| resetAccount(); | ||||||||||||||||||
| }); | ||||||||||||||||||
| }, [resetAccount]); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!resetModalVisible) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| return ( | ||||||||||||||||||
| <ActionModal | ||||||||||||||||||
| modalVisible={resetModalVisible} | ||||||||||||||||||
| confirmText={strings('app_settings.reset_account_confirm_button')} | ||||||||||||||||||
| cancelText={strings('app_settings.reset_account_cancel_button')} | ||||||||||||||||||
| confirmTestID={AdvancedViewSelectorsIDs.RESET_ACCOUNT_CONFIRM_BUTTON} | ||||||||||||||||||
| onCancelPress={cancelResetAccount} | ||||||||||||||||||
| onRequestClose={cancelResetAccount} | ||||||||||||||||||
| onConfirmPress={resetAccount} | ||||||||||||||||||
| <BottomSheet | ||||||||||||||||||
| ref={sheetRef} | ||||||||||||||||||
| isInteractable | ||||||||||||||||||
| onClose={cancelResetAccount} | ||||||||||||||||||
| keyboardAvoidingViewEnabled | ||||||||||||||||||
| > | ||||||||||||||||||
| <View style={styles.modalView}> | ||||||||||||||||||
| <BottomSheetHeader onClose={handleRequestClose}> | ||||||||||||||||||
| <Text style={styles.modalTitle} variant={TextVariant.HeadingMD}> | ||||||||||||||||||
| {strings('app_settings.reset_account_modal_title')} | ||||||||||||||||||
| </Text> | ||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cursoragent remove the wrapping text BottomSheet header should be standardized font size and is handled by the component
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated
Suggested change
Pushed the fix to the existing PR: #34847. |
||||||||||||||||||
| </BottomSheetHeader> | ||||||||||||||||||
| <Box twClassName="px-4 pt-2 pb-6"> | ||||||||||||||||||
| <Text style={styles.modalText}> | ||||||||||||||||||
| {strings('app_settings.reset_account_modal_message')} | ||||||||||||||||||
| </Text> | ||||||||||||||||||
| </View> | ||||||||||||||||||
| </ActionModal> | ||||||||||||||||||
| </Box> | ||||||||||||||||||
| <BottomSheetFooter | ||||||||||||||||||
| secondaryButtonProps={{ | ||||||||||||||||||
| children: strings('app_settings.reset_account_cancel_button'), | ||||||||||||||||||
| onPress: handleRequestClose, | ||||||||||||||||||
| }} | ||||||||||||||||||
| primaryButtonProps={{ | ||||||||||||||||||
| children: strings('app_settings.reset_account_confirm_button'), | ||||||||||||||||||
| onPress: handleConfirm, | ||||||||||||||||||
| isDanger: true, | ||||||||||||||||||
| testID: AdvancedViewSelectorsIDs.RESET_ACCOUNT_CONFIRM_BUTTON, | ||||||||||||||||||
| }} | ||||||||||||||||||
| /> | ||||||||||||||||||
| </BottomSheet> | ||||||||||||||||||
| ); | ||||||||||||||||||
| }; | ||||||||||||||||||


Uh oh!
There was an error while loading. Please reload this page.