package com.tangem.features.swap.v2.impl.notifications

import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.ui.Modifier
import com.tangem.common.ui.notifications.NotificationUM
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.model.getOrCreateModel
import com.tangem.domain.express.models.ExpressError
import com.tangem.domain.express.models.ExpressProvider
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.PriceImpact
import java.math.BigDecimal
import com.tangem.features.swap.v2.impl.notifications.model.SwapNotificationsModel
import com.tangem.features.swap.v2.impl.notifications.ui.swapNotifications
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.StateFlow

internal class SwapNotificationsComponent(
    appComponentContext: AppComponentContext,
    params: Params,
) : AppComponentContext by appComponentContext {
    private val model: SwapNotificationsModel = getOrCreateModel(params)

    val state: StateFlow<ImmutableList<NotificationUM>> = model.uiState

    fun LazyListScope.content(
        state: ImmutableList<NotificationUM>,
        modifier: Modifier = Modifier,
        hasPaddingAbove: Boolean = false,
        isClickDisabled: Boolean = false,
    ) {
        swapNotifications(
            notifications = state,
            modifier = modifier,
            hasPaddingAbove = hasPaddingAbove,
            isClickDisabled = isClickDisabled,
        )
    }

    data class Params(
        val swapNotificationData: SwapNotificationData,
    ) {
        data class SwapNotificationData(
            val expressError: ExpressError?,
            val fromCryptoCurrency: CryptoCurrency?,
            val destinationAddress: String,
            val memo: String? = null,
            val toCryptoCurrencyStatus: CryptoCurrencyStatus? = null,
            val userWalletId: UserWalletId? = null,
            val enteredFromAmount: BigDecimal? = null,
            val fromCryptoCurrencyStatus: CryptoCurrencyStatus? = null,
            val priceImpact: PriceImpact? = null,
            val provider: ExpressProvider? = null,
            val amountType: SwapAmountType? = null,
            val shouldIncludeFeeInBalanceCheck: Boolean = false,
            val feeValue: BigDecimal? = null,
        )
    }
}