import { AssetController, AssetUtil, ConnectionsController, OnRampController, RouterController, ThemeController } from '@reown/appkit-core-react-native'; import { BorderRadius, Button, FlexView, Image, Separator, Spacing, Text, Toggle, useCustomDimensions, useTheme } from '@reown/appkit-ui-react-native'; import { ScrollView, StyleSheet } from 'react-native'; import { useSnapshot } from 'valtio'; import { NumberUtil, StringUtil } from '@reown/appkit-common-react-native'; export function OnRampCheckoutView() { const Theme = useTheme(); const { padding } = useCustomDimensions(); const { themeMode } = useSnapshot(ThemeController.state); const { networkImages } = useSnapshot(AssetController.state); const { selectedQuote, selectedPaymentMethod, purchaseCurrency } = useSnapshot( OnRampController.state ); const { activeNetwork } = useSnapshot(ConnectionsController.state); const networkImage = AssetUtil.getNetworkImage(activeNetwork, networkImages); const value = NumberUtil.roundNumber(selectedQuote?.destinationAmount ?? 0, 6, 5); const symbol = selectedQuote?.destinationCurrencyCode; const paymentLogo = selectedPaymentMethod?.logos[themeMode ?? 'light']; const providerImage = OnRampController.getServiceProviderImage( selectedQuote?.serviceProvider ?? '' ); const showNetworkFee = selectedQuote?.networkFee != null; const showTransactionFee = selectedQuote?.transactionFee != null; const showTotalFee = selectedQuote?.totalFee != null; const showFees = showNetworkFee || showTransactionFee || showTotalFee; const onConfirm = () => { RouterController.push('OnRampLoading'); }; return ( You Buy {value} {symbol?.split('_')[0] ?? symbol ?? ''} via {providerImage ? : null} {StringUtil.capitalize(selectedQuote?.serviceProvider)} You Pay {selectedQuote?.sourceAmount} {selectedQuote?.sourceCurrencyCode} You Receive {value} {symbol?.split('_')[0] ?? ''} {purchaseCurrency?.symbolImageUrl ? ( ) : null} Network {purchaseCurrency?.chainName} Pay with {paymentLogo ? ( ) : null} {selectedPaymentMethod?.name} {showFees ? ( Fees{' '} {showTotalFee ? ( {selectedQuote?.totalFee} {selectedQuote?.sourceCurrencyCode} ) : null} } style={[styles.feesToggle, { backgroundColor: Theme['gray-glass-002'] }]} contentContainerStyle={styles.feesToggleContent} > {showNetworkFee ? ( Network Fees {networkImage ? ( ) : null} {selectedQuote?.networkFee} {selectedQuote?.sourceCurrencyCode} ) : null} {showTransactionFee ? ( Transaction Fees {selectedQuote.transactionFee} {selectedQuote?.sourceCurrencyCode} ) : null} ) : null} ); } const styles = StyleSheet.create({ amount: { fontSize: 38, marginRight: Spacing['3xs'] }, separator: { marginVertical: Spacing.m }, feesToggle: { borderRadius: BorderRadius.xs }, feesToggleContent: { paddingHorizontal: Spacing.xs, paddingBottom: Spacing.xs }, toggleItem: { padding: Spacing.s, borderRadius: BorderRadius.xxs }, paymentMethodImage: { width: 14, height: 14, marginRight: Spacing['3xs'] }, confirmButton: { marginLeft: Spacing.s, flex: 3 }, cancelButton: { flex: 1 }, providerImage: { height: 16, width: 16, marginRight: 2 }, tokenImage: { height: 20, width: 20, marginLeft: 4, borderRadius: BorderRadius.full, borderWidth: 1 }, networkImage: { height: 16, width: 16, marginRight: 4, borderRadius: BorderRadius.full, borderWidth: 1 }, paymentMethodContainer: { borderWidth: StyleSheet.hairlineWidth, borderRadius: BorderRadius.full, padding: Spacing.xs } });