import BigNumber from 'bignumber.js' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { LayoutAnimation, StyleSheet, Text, View } from 'react-native' import Expandable from 'src/components/Expandable' import { ExchangeFeeIcon, SecurityFeeIcon } from 'src/components/FeeIcon' import LineItemRow from 'src/components/LineItemRow' import TokenDisplay from 'src/components/TokenDisplay' import Touchable from 'src/components/Touchable' import colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' interface Props { isEstimate?: boolean isExchange?: boolean securityFee?: BigNumber exchangeFee?: BigNumber feeLoading?: boolean feeHasError?: boolean totalFee?: BigNumber testID?: string showLocalAmount?: boolean tokenId?: string } export default function FeeDrawer({ isEstimate, isExchange, securityFee, exchangeFee, feeLoading, feeHasError, totalFee, testID, showLocalAmount, tokenId, }: Props) { const { t } = useTranslation() const [expanded, setExpanded] = useState(false) const toggleExpanded = () => { LayoutAnimation.easeInEaseOut() setExpanded(!expanded) } const title = isEstimate ? t('feeEstimate') : t('feeActual') return ( // Uses View instead of Fragment to workaround a glitch with LayoutAnimation {title} ) } isLoading={feeLoading} hasError={feeHasError} /> {expanded && ( {isExchange && ( } amount={ exchangeFee && ( ) } textStyle={styles.dropDownText} /> )} } amount={ securityFee && ( ) } isLoading={feeLoading} hasError={feeHasError} textStyle={styles.dropDownText} /> )} ) } const styles = StyleSheet.create({ totalContainer: { flexDirection: 'row', justifyContent: 'space-between', }, title: { ...typeScale.bodyMedium, }, dropDownText: { ...typeScale.bodyMedium, color: colors.contentSecondary, }, })