import React from 'react' import { Trans, useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import { useSelector } from 'react-redux' import BottomSheet, { BottomSheetModalRefType } from 'src/components/BottomSheet' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import { formatValueToDisplay } from 'src/components/TokenDisplay' import { getLocalCurrencySymbol, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' import { AppFeeAmount, SwapFeeAmount } from 'src/swap/types' interface Props { forwardedRef: React.RefObject appFee?: AppFeeAmount crossChainFee?: SwapFeeAmount networkFee?: SwapFeeAmount fetchingSwapQuote: boolean } function FeeAmount({ fee, showMaxAmount, isLoading, }: { fee: SwapFeeAmount | undefined showMaxAmount?: boolean isLoading: boolean }) { const { t } = useTranslation() const usdToLocalCurrencyRate = useSelector(usdToLocalCurrencyRateSelector) const localCurrencySymbol = useSelector(getLocalCurrencySymbol) const feeAmount = showMaxAmount ? fee?.maxAmount : fee?.amount const feeAmountInLocalCurrency = feeAmount && fee?.token?.priceUsd && usdToLocalCurrencyRate ? feeAmount.times(fee.token.priceUsd).times(usdToLocalCurrencyRate) : undefined const isFeeZero = feeAmount && feeAmount.isZero() const loadingText = t('loading') const fallbackText = t('unknown') const zeroFeeText = t('swapScreen.transactionDetails.swapFeeWaived') return ( {isLoading ? ( loadingText ) : isFeeZero ? ( zeroFeeText ) : fee && fee.token && feeAmount ? ( ) : ( fallbackText )} ) } function FeeInfoBottomSheet({ forwardedRef, crossChainFee, appFee, networkFee, fetchingSwapQuote, }: Props) { const { t } = useTranslation() return ( {t('swapScreen.transactionDetails.feesBreakdown')} {t('swapScreen.transactionDetails.estimatedNetworkFee')} {t('swapScreen.transactionDetails.maxNetworkFee')} {t('swapScreen.transactionDetails.appFee')} {crossChainFee && ( <> {t('swapScreen.transactionDetails.estimatedCrossChainFee')} {t('swapScreen.transactionDetails.maxCrossChainFee')} )} {t('swapScreen.transactionDetails.feesMoreInfoLabel')}