import { useState } from 'react'; import { useSnapshot } from 'valtio'; import { Balance, FlexView, IconLink, Tabs } from '@reown/appkit-ui-react-native'; import { ConnectionsController, ConstantsUtil, CoreHelperUtil, EventsController, OnRampController, OptionsController, RouterController, SwapController } from '@reown/appkit-core-react-native'; import type { Balance as BalanceType } from '@reown/appkit-common-react-native'; import { AccountActivity } from '../w3m-account-activity'; import { AccountTokens } from '../w3m-account-tokens'; import styles from './styles'; export function AccountWalletFeatures() { const [activeTab, setActiveTab] = useState(0); const { features, isOnRampEnabled } = useSnapshot(OptionsController.state); const { activeNetwork, balances, activeNamespace } = useSnapshot(ConnectionsController.state); const balance = CoreHelperUtil.calculateAndFormatBalance(balances as BalanceType[]); const network = ConnectionsController.state.activeNetwork?.caipNetworkId; const isSmartAccount = ConnectionsController.state.accountType === 'smartAccount'; const showSend = activeNamespace && ConstantsUtil.SEND_SUPPORTED_NAMESPACES.includes(activeNamespace); const isSwapsEnabled = features?.swaps && activeNetwork?.caipNetworkId && ConstantsUtil.SWAP_SUPPORTED_NETWORKS.includes(activeNetwork.caipNetworkId); const onTabChange = (index: number) => { setActiveTab(index); if (index === 2) { onTransactionsPress(); } }; const onTransactionsPress = () => { EventsController.sendEvent({ type: 'track', event: 'CLICK_TRANSACTIONS', properties: { isSmartAccount } }); }; const onSwapPress = () => { SwapController.resetState(); EventsController.sendEvent({ type: 'track', event: 'OPEN_SWAP', properties: { network, isSmartAccount } }); RouterController.push('Swap'); }; const onSendPress = () => { EventsController.sendEvent({ type: 'track', event: 'OPEN_SEND', properties: { network, isSmartAccount } }); RouterController.push('WalletSend'); }; const onReceivePress = () => { RouterController.push('WalletReceive'); }; const onBuyPress = () => { EventsController.sendEvent({ type: 'track', event: 'SELECT_BUY_CRYPTO' }); OnRampController.resetState(); RouterController.push('OnRamp'); }; return ( {isOnRampEnabled ? ( ) : null} {isSwapsEnabled ? ( ) : null} {showSend ? ( ) : null} {activeTab === 0 && } {activeTab === 1 && } ); }