import { useSnapshot } from 'valtio'; import { ScrollView, View } from 'react-native'; import { ApiController, EventUtil, EventsController, OptionsController, RouterController } from '@reown/appkit-core-react-native'; import { type WcWallet } from '@reown/appkit-common-react-native'; import { FlexView, Icon, ListItem, Separator, Text, useCustomDimensions } from '@reown/appkit-ui-react-native'; import { Placeholder } from '../../partials/w3m-placeholder'; import { AllWalletsButton } from './components/all-wallets-button'; import { AllWalletList } from './components/all-wallet-list'; import { SocialLoginList } from './components/social-login-list'; import styles from './styles'; import { WcHelpersUtil } from '../../utils/HelpersUtil'; export function ConnectView() { const { prefetchError } = useSnapshot(ApiController.state); const { features } = useSnapshot(OptionsController.state); const { padding } = useCustomDimensions(); const isSocialEnabled = features?.socials && features?.socials.length > 0; const showConnectWalletsButton = isSocialEnabled && !features?.showWallets; const showLoadingError = !showConnectWalletsButton && prefetchError; const showList = !showConnectWalletsButton && !showLoadingError; const onWalletPress = (wallet: WcWallet, displayIndex: number, isInstalled?: boolean) => { const isExternal = WcHelpersUtil.isExternalWallet(wallet); if (isExternal) { RouterController.push('ConnectingExternal', { wallet }); } else { RouterController.push('WalletConnect', { wallet }); } const platform = EventUtil.getWalletPlatform(wallet, isInstalled); EventsController.sendEvent({ type: 'track', event: 'SELECT_WALLET', properties: { name: wallet.name ?? 'Unknown', platform, explorerId: wallet.id, walletRank: wallet.order, displayIndex, view: 'Connect' } }); }; const onViewAllPress = () => { RouterController.push('AllWallets'); EventsController.sendEvent({ type: 'track', event: 'CLICK_ALL_WALLETS' }); }; return ( {isSocialEnabled ? ( <> ) : null} {showConnectWalletsButton ? ( Continue with a wallet ) : null} {showLoadingError ? ( ) : null} {showList ? ( <> ) : null} ); }