@@ -3,17 +3,16 @@ import { Trans, useLingui } from '@lingui/react/macro'
33import { PersonaContext } from '@masknet/shared'
44import { EMPTY_LIST , NetworkPluginID , PopupRoutes } from '@masknet/shared-base'
55import { ActionButton , makeStyles } from '@masknet/theme'
6- import { useChainContext , useChainIdValid , useNetworks , useWallets , useWeb3State } from '@masknet/web3-hooks-base'
6+ import { useChainContext , useChainIdValid , useWallets , useWeb3State } from '@masknet/web3-hooks-base'
77import { EVMWeb3 } from '@masknet/web3-providers'
88import { isSameAddress } from '@masknet/web3-shared-base'
99import { ProviderType , type ChainId } from '@masknet/web3-shared-evm'
10- import { Box , Button , Typography } from '@mui/material'
10+ import { Box , Button , Typography , type BoxProps } from '@mui/material'
1111import { first } from 'lodash-es'
1212import { memo , useCallback , useMemo , useState } from 'react'
1313import { useNavigate , useSearchParams } from 'react-router-dom'
1414import { useAsync } from 'react-use'
1515import urlcat from 'urlcat'
16- import { BottomController } from '../../../components/BottomController/index.js'
1716import { WalletItem } from '../../../components/WalletItem/index.js'
1817import { useTitle , useVerifiedWallets } from '../../../hooks/index.js'
1918import { ProfilePhotoType } from '../type.js'
@@ -32,9 +31,20 @@ const useStyles = makeStyles()((theme) => ({
3231 justifyContent : 'center' ,
3332 alignItems : 'center' ,
3433 } ,
34+ actions : {
35+ background : theme . palette . maskColor . secondaryBottom ,
36+ padding : theme . spacing ( 2 ) ,
37+ boxShadow : theme . palette . maskColor . bottomBg ,
38+ backdropFilter : 'blur(8px)' ,
39+ display : 'flex' ,
40+ columnGap : theme . spacing ( 2 ) ,
41+ } ,
3542} ) )
3643
37- export const Component = memo ( function SelectWallet ( ) {
44+ interface SelectWalletProps extends BoxProps {
45+ embed ?: boolean
46+ }
47+ export const Component = memo ( function SelectWallet ( { embed, ...props } : SelectWalletProps ) {
3848 const { t } = useLingui ( )
3949 const { classes, cx } = useStyles ( )
4050 const navigate = useNavigate ( )
@@ -53,7 +63,6 @@ export const Component = memo(function SelectWallet() {
5363 chainId : chainIdSearched ? ( Number . parseInt ( chainIdSearched , 10 ) as ChainId ) : undefined ,
5464 } )
5565
56- const networks = useNetworks ( NetworkPluginID . PLUGIN_EVM )
5766 const chainIdValid = useChainIdValid ( NetworkPluginID . PLUGIN_EVM , chainId )
5867
5968 const { value : localWallets = EMPTY_LIST } = useAsync ( async ( ) => Services . Wallet . getWallets ( ) , [ ] )
@@ -83,13 +92,15 @@ export const Component = memo(function SelectWallet() {
8392 } , [ isVerifyWalletFlow ] )
8493
8594 const handleConfirm = useCallback ( async ( ) => {
86- if ( isVerifyWalletFlow || isSettingNFTAvatarFlow ) {
95+ if ( isVerifyWalletFlow || isSettingNFTAvatarFlow || embed ) {
8796 await EVMWeb3 . connect ( {
8897 account : selected ,
8998 chainId,
9099 providerType : ProviderType . MaskWallet ,
91100 } )
92101
102+ if ( embed ) return
103+
93104 navigate (
94105 isSettingNFTAvatarFlow ?
95106 urlcat ( PopupRoutes . PersonaAvatarSetting , { tab : ProfilePhotoType . NFT } )
@@ -112,22 +123,22 @@ export const Component = memo(function SelectWallet() {
112123 }
113124
114125 return Services . Helper . removePopupWindow ( )
115- } , [ source , isVerifyWalletFlow , selected , chainId , wallets , isSettingNFTAvatarFlow , networks , Network ] )
126+ } , [ source , isVerifyWalletFlow , selected , chainId , wallets , isSettingNFTAvatarFlow , Network , embed ] )
116127
117128 useTitle ( t `Select Wallet` )
118129
119130 if ( ! chainIdValid )
120131 return (
121- < Box className = { classes . placeholder } >
132+ < Box { ... props } className = { cx ( classes . placeholder , props . className ) } >
122133 < Typography >
123134 < Trans > Unsupported network type</ Trans >
124135 </ Typography >
125136 </ Box >
126137 )
127138
128139 return (
129- < Box overflow = "auto" data-hide-scrollbar >
130- < Box pt = { 1 } pb = { 9 } px = { 2 } display = "flex" flexDirection = "column" rowGap = "6px" >
140+ < Box overflow = "auto" display = "flex" flexGrow = { 1 } flexDirection = "column" data-hide-scrollbar { ... props } >
141+ < Box pt = { 1 } pb = { 9 } px = { 2 } display = "flex" flexGrow = { 1 } minHeight = { 0 } flexDirection = "column" rowGap = "6px" >
131142 { wallets . map ( ( item ) => {
132143 const disabled =
133144 isVerifyWalletFlow && bindingWallets ?. some ( ( x ) => isSameAddress ( x . identity , item . address ) )
@@ -146,14 +157,14 @@ export const Component = memo(function SelectWallet() {
146157 )
147158 } ) }
148159 </ Box >
149- < BottomController >
160+ < div className = { classes . actions } >
150161 < Button variant = "outlined" fullWidth onClick = { handleCancel } >
151162 < Trans > Cancel</ Trans >
152163 </ Button >
153164 < ActionButton fullWidth onClick = { handleConfirm } >
154165 < Trans > Confirm</ Trans >
155166 </ ActionButton >
156- </ BottomController >
167+ </ div >
157168 </ Box >
158169 )
159170} )
0 commit comments