Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

5.19 pre release #3999

Merged
merged 10 commits into from
Dec 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ object TradeCryptoMiddleware {
is TradeCryptoAction.FinishSelling -> openReceiptUrl(action.transactionId)
is TradeCryptoAction.Buy -> proceedBuyAction(state, action)
is TradeCryptoAction.Sell -> proceedSellAction(action)
is TradeCryptoAction.SendToken -> handleNewSendToken(action = action)
is TradeCryptoAction.SendCoin -> handleNewSendCoin(action = action)
}
}

Expand Down Expand Up @@ -166,37 +164,4 @@ object TradeCryptoMiddleware {
transactionId = transactionId,
)?.let { store.dispatchOpenUrl(it) }
}

private fun handleNewSendToken(action: TradeCryptoAction.SendToken) {
handleNewSend(
userWalletId = action.userWallet.walletId,
txInfo = action.transactionInfo,
currency = action.tokenCurrency,
)
}

private fun handleNewSendCoin(action: TradeCryptoAction.SendCoin) {
handleNewSend(
userWalletId = action.userWallet.walletId,
txInfo = action.transactionInfo,
currency = action.coinStatus.currency,
)
}

private fun handleNewSend(
userWalletId: UserWalletId,
txInfo: TradeCryptoAction.TransactionInfo?,
currency: CryptoCurrency,
) {
val route = AppRoute.Send(
currency = currency,
userWalletId = userWalletId,
transactionId = txInfo?.transactionId,
destinationAddress = txInfo?.destinationAddress,
amount = txInfo?.amount,
tag = txInfo?.tag,
)

store.dispatchNavigationAction { push(route) }
}
}
2 changes: 2 additions & 0 deletions common/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation(deps.compose.navigation)
implementation(deps.compose.navigation.hilt)
implementation(deps.compose.coil)
implementation(deps.compose.constraintLayout)

/** Deps */
implementation(deps.kotlin.immutable.collections)
Expand All @@ -34,6 +35,7 @@ dependencies {
implementation(projects.domain.tokens.models)
implementation(projects.domain.transaction.models)
implementation(projects.domain.wallets.models)
implementation(projects.domain.onramp.models)

implementation(deps.tangem.card.core)
implementation(deps.tangem.blockchain) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express
package com.tangem.common.ui.expressStatus

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
Expand All @@ -8,16 +8,16 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import com.tangem.common.ui.R
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
import com.tangem.core.ui.components.inputrow.InputRowApprox
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.features.tokendetails.impl.R

@Suppress("LongParameterList")
@Composable
internal fun ExpressEstimate(
fun ExpressEstimate(
timestamp: TextReference,
fromTokenIconState: CurrencyIconState,
toTokenIconState: CurrencyIconState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express
package com.tangem.common.ui.expressStatus

import android.content.res.Configuration
import android.widget.Toast
Expand Down Expand Up @@ -29,7 +29,7 @@ import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview

@Composable
internal fun ExpressProvider(
fun ExpressProvider(
providerName: TextReference,
providerType: TextReference,
providerTxId: String?,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.tangem.common.ui.expressStatus

import androidx.compose.runtime.Composable
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
import com.tangem.core.ui.res.TangemTheme

data class ExpressStatusBottomSheetConfig(
val value: ExpressTransactionStateUM,
) : TangemBottomSheetConfigContent

@Composable
fun ExpressStatusBottomSheet(config: TangemBottomSheetConfig) {
TangemBottomSheet(
config = config,
containerColor = TangemTheme.colors.background.tertiary,
) { content: ExpressStatusBottomSheetConfig ->
when (val state = content.value) {
is ExpressTransactionStateUM.OnrampUM -> OnrampStatusBottomSheetContent(state)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express
package com.tangem.common.ui.expressStatus

import android.content.res.Configuration
import androidx.annotation.DrawableRes
Expand All @@ -18,6 +18,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.constraintlayout.compose.*
import com.tangem.common.ui.R
import com.tangem.core.ui.components.atoms.text.EllipsisText
import com.tangem.core.ui.components.atoms.text.TextEllipsis
import com.tangem.core.ui.components.currency.icon.CurrencyIcon
Expand All @@ -27,7 +28,6 @@ import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.features.tokendetails.impl.R

@Suppress("DestructuringDeclarationWithTooManyEntries", "LongMethod", "LongParameterList")
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express
package com.tangem.common.ui.expressStatus

import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.ui.Modifier
import com.tangem.common.ui.R
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateIconUM
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM
import com.tangem.core.ui.res.TangemTheme
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExpressTransactionStateIconUM
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExpressTransactionStateUM
import com.tangem.features.tokendetails.impl.R
import kotlinx.collections.immutable.PersistentList

internal fun LazyListScope.expressTransactionsItems(
fun LazyListScope.expressTransactionsItems(
expressTxs: PersistentList<ExpressTransactionStateUM>,
modifier: Modifier = Modifier,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.onramp
package com.tangem.common.ui.expressStatus

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
Expand All @@ -8,21 +8,17 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import com.tangem.common.ui.expressStatus.ExpressStatusBlock
import com.tangem.common.ui.expressStatus.ExpressStatusNotificationBlock
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM
import com.tangem.core.ui.R
import com.tangem.core.ui.components.SpacerH10
import com.tangem.core.ui.components.SpacerH12
import com.tangem.core.ui.components.SpacerH16
import com.tangem.core.ui.components.SpacerH24
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExpressTransactionStateUM
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.ExpressEstimate
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.ExpressProvider

@Composable
internal fun OnrampStatusBottomSheetContent(state: ExpressTransactionStateUM.OnrampUM) {
fun OnrampStatusBottomSheetContent(state: ExpressTransactionStateUM.OnrampUM) {
Column(modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing16)) {
SpacerH10()
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
package com.tangem.feature.tokendetails.presentation.tokendetails.state.express
package com.tangem.common.ui.expressStatus.state

import com.tangem.common.ui.expressStatus.state.ExpressStatusUM
import com.tangem.common.ui.notifications.NotificationUM
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
import com.tangem.core.ui.extensions.TextReference
import com.tangem.domain.onramp.model.OnrampStatus
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus
import com.tangem.feature.swap.domain.models.domain.SwapProvider
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotifications
import kotlinx.collections.immutable.ImmutableList

internal sealed class ExpressTransactionStateUM {
interface ExpressTransactionStateUM {

abstract val info: ExpressTransactionStateInfoUM

data class ExchangeUM(
override val info: ExpressTransactionStateInfoUM,
val provider: SwapProvider,
val activeStatus: ExchangeStatus?,
val statuses: ImmutableList<ExchangeStatusState>,
val notification: ExchangeStatusNotifications? = null,
val showProviderLink: Boolean,
val isRefundTerminalStatus: Boolean,
val fromCryptoCurrency: CryptoCurrency,
val toCryptoCurrency: CryptoCurrency,
) : ExpressTransactionStateUM()
val info: ExpressTransactionStateInfoUM

data class OnrampUM(
override val info: ExpressTransactionStateInfoUM,
Expand All @@ -34,10 +16,10 @@ internal sealed class ExpressTransactionStateUM {
val providerType: String, // todo onramp fix after SwapProvider moved to own module
val activeStatus: OnrampStatus.Status,
val fromCurrencyCode: String,
) : ExpressTransactionStateUM()
) : ExpressTransactionStateUM
}

internal data class ExpressTransactionStateInfoUM(
data class ExpressTransactionStateInfoUM(
val title: TextReference,
val status: ExpressStatusUM,
val notification: NotificationUM?,
Expand All @@ -49,7 +31,6 @@ internal data class ExpressTransactionStateInfoUM(
val onGoToProviderClick: (String) -> Unit,
val onClick: () -> Unit,
val iconState: ExpressTransactionStateIconUM,

val toAmount: TextReference,
val toFiatAmount: TextReference?,
val toAmountSymbol: String,
Expand All @@ -61,7 +42,7 @@ internal data class ExpressTransactionStateInfoUM(
val fromCurrencyIcon: CurrencyIconState,
)

internal enum class ExpressTransactionStateIconUM {
enum class ExpressTransactionStateIconUM {
Warning,
Error,
None,
Expand Down
2 changes: 2 additions & 0 deletions core/res/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@
<string name="onramp_choose_provider_title_hint">Der Kauf von Kryptowährungen bei Tangem wird von Drittanbietern zu deren Bedingungen durchgeführt.</string>
<string name="onramp_country_search">Suche nach Land</string>
<string name="onramp_country_unavailable">Nicht verfügbar</string>
<string name="onramp_currency_other">Andere Währungen</string>
<string name="onramp_currency_popular">Beliebte Fiats</string>
<string name="onramp_currency_search">Suche nach Währung</string>
<string name="onramp_legal">Durch die Nutzung der Onramp-Funktionalität stimmst Du den %1$s und %2$s des Anbieters zu.</string>
<string name="onramp_max_amount_restriction">Der Kaufbetrag sollte nicht höher sein als %s</string>
Expand Down
Loading
Loading