import React from 'react'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, View } from 'react-native'
import RowDivider from 'src/components/RowDivider'
import TokenDisplay from 'src/components/TokenDisplay'
import ArrowRightThick from 'src/icons/ArrowRightThick'
import { NETWORK_NAMES } from 'src/shared/conts'
import Colors from 'src/styles/colors'
import { typeScale } from 'src/styles/fonts'
import { Spacing } from 'src/styles/styles'
import { useTokenInfo } from 'src/tokens/hooks'
import FeeRowItem from 'src/transactions/feed/detailContent/FeeRowItem'
import { DepositOrWithdraw, FeeType, TokenTransactionTypeV2 } from 'src/transactions/types'
interface DepositOrWithdrawContentProps {
transaction: DepositOrWithdraw
}
export function DepositOrWithdrawContent({ transaction }: DepositOrWithdrawContentProps) {
const { t } = useTranslation()
const txAppName = transaction.appName
const isDeposit =
transaction.type === TokenTransactionTypeV2.Deposit ||
transaction.type === TokenTransactionTypeV2.CrossChainDeposit
const isCrossChain = transaction.type === TokenTransactionTypeV2.CrossChainDeposit
const depositTokenInfo = useTokenInfo(
isDeposit ? transaction.outAmount.tokenId : transaction.inAmount.tokenId
)
const fromTokenInfo = useTokenInfo(transaction.swap?.outAmount.tokenId)
const tokenSymbol = depositTokenInfo?.symbol ?? ''
const amount = isDeposit ? transaction.outAmount : transaction.inAmount
return (
<>
{t('transactionDetails.descriptionLabel')}
{t(
isDeposit ? 'transactionDetails.depositSubtitle' : 'transactionDetails.withdrawSubtitle',
{ context: !txAppName ? 'noTxAppName' : undefined, txAppName, tokenSymbol }
)}
{t(
isDeposit
? 'transactionDetails.depositDetails'
: 'transactionDetails.withdrawDetails'
)}
{transaction.swap && (
{t('transactionDetails.swap')}
)}
{t('transactionDetails.network')}
{isCrossChain && fromTokenInfo && depositTokenInfo // these tokens should be present for cross chain
? t('swapTransactionDetailPage.networkValue', {
fromNetwork: NETWORK_NAMES[fromTokenInfo.networkId],
toNetwork: NETWORK_NAMES[depositTokenInfo.networkId],
})
: NETWORK_NAMES[transaction.networkId]}
{t('transactionDetails.fees')}
>
)
}
const styles = StyleSheet.create({
detailsTitle: {
...typeScale.labelSmall,
},
detailsSubtitle: {
...typeScale.bodyMedium,
},
row: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
flexWrap: 'wrap',
},
bodyText: {
...typeScale.bodyMedium,
},
bodyTextValue: {
...typeScale.bodyMedium,
textAlign: 'right',
},
amountTitle: {
...typeScale.labelSemiBoldMedium,
},
amountSubtitle: {
...typeScale.bodySmall,
color: Colors.contentSecondary,
marginLeft: 'auto',
},
amountContainer: {
gap: Spacing.Regular16,
},
feeContainer: {
marginTop: Spacing.Smallest8,
gap: Spacing.Regular16,
},
swapValueContainer: {
flexDirection: 'row',
justifyContent: 'flex-end',
gap: Spacing.Tiny4,
alignItems: 'center',
},
})