Updated on 2026-08-14
This commit is contained in:
parent
50332186fa
commit
5f6767abaf
58 changed files with 85 additions and 717 deletions
|
|
@ -1,6 +0,0 @@
|
|||
package com.tangem.features.tokendetails
|
||||
|
||||
interface TokenDetailsFeatureToggles {
|
||||
val isQuickTopUpEnabled: Boolean
|
||||
val isManageFundsEnabled: Boolean
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.tangem.feature.tokendetails
|
||||
|
||||
import com.tangem.core.configtoggle.FeatureToggles
|
||||
import com.tangem.core.configtoggle.feature.FeatureTogglesManager
|
||||
import com.tangem.features.tokendetails.TokenDetailsFeatureToggles
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class DefaultTokenDetailsFeatureToggles @Inject constructor(
|
||||
private val featureTogglesManager: FeatureTogglesManager,
|
||||
) : TokenDetailsFeatureToggles {
|
||||
|
||||
override val isQuickTopUpEnabled: Boolean = featureTogglesManager.isFeatureEnabled(
|
||||
toggle = FeatureToggles.AND_15258_QUICK_TOP_UP_ENABLED,
|
||||
)
|
||||
|
||||
override val isManageFundsEnabled: Boolean
|
||||
get() = featureTogglesManager.isFeatureEnabled(FeatureToggles.TWI_1377_MANAGE_FUNDS)
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.tangem.feature.tokendetails.di
|
||||
|
||||
import com.tangem.core.configtoggle.feature.FeatureTogglesManager
|
||||
import com.tangem.feature.tokendetails.DefaultTokenDetailsFeatureToggles
|
||||
import com.tangem.features.tokendetails.TokenDetailsFeatureToggles
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object TokenDetailsFeatureModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideTokenDetailsFeatureToggles(featureTogglesManager: FeatureTogglesManager): TokenDetailsFeatureToggles {
|
||||
return DefaultTokenDetailsFeatureToggles(featureTogglesManager)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,15 +8,12 @@ import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
|||
import com.tangem.domain.onramp.model.OnrampAvailability
|
||||
import com.tangem.domain.onramp.model.error.OnrampError
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.QuickTopUpBlockUM
|
||||
import com.tangem.features.tokendetails.TokenDetailsFeatureToggles
|
||||
import com.tangem.utils.extensions.isZero
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import java.math.BigDecimal
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class QuickTopUpBlockFactory @Inject constructor(
|
||||
private val featureToggles: TokenDetailsFeatureToggles,
|
||||
) {
|
||||
internal class QuickTopUpBlockFactory @Inject constructor() {
|
||||
|
||||
fun build(
|
||||
currencyStatus: CryptoCurrencyStatus,
|
||||
|
|
@ -25,8 +22,6 @@ internal class QuickTopUpBlockFactory @Inject constructor(
|
|||
onPresetClick: (BigDecimal, String) -> Unit,
|
||||
onOtherClick: () -> Unit,
|
||||
): QuickTopUpBlockUM? {
|
||||
if (!featureToggles.isQuickTopUpEnabled) return null
|
||||
|
||||
val amount = currencyStatus.value.amount
|
||||
if (amount == null || !amount.isZero()) return null
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.model.ExpressTr
|
|||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotification
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeUM
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.ExpressStatusBottomSheet
|
||||
import com.tangem.features.swap.SwapFeatureToggles
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.assisted.Assisted
|
||||
|
|
@ -47,7 +46,6 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
onrampStatusFactory: OnrampStatusFactory.Factory,
|
||||
exchangeStatusFactory: ExchangeStatusFactory.Factory,
|
||||
private val swapFeatureToggles: SwapFeatureToggles,
|
||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
) {
|
||||
|
||||
|
|
@ -221,7 +219,6 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
is ExpressStatusBottomSheetConfig -> ExpressStatusBottomSheet(
|
||||
config = this,
|
||||
extraContent = extraContent,
|
||||
isExpressShareButtonEnabled = swapFeatureToggles.isExpressShareButtonEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,44 +21,28 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.e
|
|||
@Composable
|
||||
internal fun ExpressStatusBottomSheet(
|
||||
config: TangemBottomSheetConfig,
|
||||
isExpressShareButtonEnabled: Boolean,
|
||||
extraContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
TangemBottomSheet(
|
||||
config = config,
|
||||
containerColor = TangemTheme.colors.background.tertiary,
|
||||
) { content: ExpressStatusBottomSheetConfig ->
|
||||
if (isExpressShareButtonEnabled) {
|
||||
Box {
|
||||
when (val state = content.value) {
|
||||
is ExpressTransactionStateUM.OnrampUM -> OnrampStatusBottomSheetContent(
|
||||
state = state,
|
||||
isExpressShareButtonEnabled = true,
|
||||
)
|
||||
is ExchangeUM -> ExchangeStatusBottomSheetContent(
|
||||
state = state,
|
||||
extraContent = extraContent,
|
||||
isExpressShareButtonEnabled = true,
|
||||
)
|
||||
}
|
||||
BottomFade(
|
||||
backgroundColor = TangemTheme.colors.background.tertiary,
|
||||
modifier = Modifier.align(Alignment.BottomCenter),
|
||||
)
|
||||
ExpressShareContent(state = content.value)
|
||||
}
|
||||
} else {
|
||||
Box {
|
||||
when (val state = content.value) {
|
||||
is ExpressTransactionStateUM.OnrampUM -> OnrampStatusBottomSheetContent(
|
||||
state = state,
|
||||
isExpressShareButtonEnabled = false,
|
||||
isExpressShareButtonEnabled = true,
|
||||
)
|
||||
is ExchangeUM -> ExchangeStatusBottomSheetContent(
|
||||
state = state,
|
||||
extraContent = extraContent,
|
||||
isExpressShareButtonEnabled = false,
|
||||
)
|
||||
}
|
||||
BottomFade(
|
||||
backgroundColor = TangemTheme.colors.background.tertiary,
|
||||
modifier = Modifier.align(Alignment.BottomCenter),
|
||||
)
|
||||
ExpressShareContent(state = content.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +60,6 @@ private fun PreviewExpressStatusBottomSheet(
|
|||
onDismissRequest = {},
|
||||
content = param,
|
||||
),
|
||||
isExpressShareButtonEnabled = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,6 @@ import com.tangem.core.ui.components.SpacerH
|
|||
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.components.notifications.CurrencyNotification
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
|
|
@ -38,11 +37,7 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.E
|
|||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Composable
|
||||
internal fun ExchangeStatusBottomSheetContent(
|
||||
state: ExchangeUM,
|
||||
isExpressShareButtonEnabled: Boolean,
|
||||
extraContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
internal fun ExchangeStatusBottomSheetContent(state: ExchangeUM, extraContent: (@Composable () -> Unit)? = null) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing16)
|
||||
|
|
@ -97,11 +92,7 @@ internal fun ExchangeStatusBottomSheetContent(
|
|||
isAutoDisposable = state.activeStatus?.isAutoDisposable == true,
|
||||
onClick = state.info.onDisposeExpressStatus,
|
||||
)
|
||||
if (isExpressShareButtonEnabled) {
|
||||
SpacerH(80.dp)
|
||||
} else {
|
||||
SpacerH24()
|
||||
}
|
||||
SpacerH(80.dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.tangem.domain.onramp.model.OnrampAvailability
|
|||
import com.tangem.domain.onramp.model.OnrampCountry
|
||||
import com.tangem.domain.onramp.model.OnrampCurrency
|
||||
import com.tangem.domain.onramp.model.error.OnrampError
|
||||
import com.tangem.features.tokendetails.TokenDetailsFeatureToggles
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import org.junit.jupiter.api.Test
|
||||
|
|
@ -19,10 +18,7 @@ import java.math.BigDecimal
|
|||
|
||||
internal class QuickTopUpBlockFactoryTest {
|
||||
|
||||
private val featureToggles: TokenDetailsFeatureToggles = mockk {
|
||||
every { isQuickTopUpEnabled } returns true
|
||||
}
|
||||
private val factory = QuickTopUpBlockFactory(featureToggles)
|
||||
private val factory = QuickTopUpBlockFactory()
|
||||
|
||||
private val zeroBalanceStatus: CryptoCurrencyStatus = mockk {
|
||||
every { value } returns mockk<CryptoCurrencyStatus.Loaded> {
|
||||
|
|
@ -69,24 +65,6 @@ internal class QuickTopUpBlockFactoryTest {
|
|||
|
||||
private val notSupported: OnrampAvailability = OnrampAvailability.NotSupported(country = countryMock)
|
||||
|
||||
@Test
|
||||
fun `returns null when feature toggle is disabled`() {
|
||||
val disabledToggles: TokenDetailsFeatureToggles = mockk {
|
||||
every { isQuickTopUpEnabled } returns false
|
||||
}
|
||||
val disabledFactory = QuickTopUpBlockFactory(disabledToggles)
|
||||
|
||||
val result = disabledFactory.build(
|
||||
currencyStatus = zeroBalanceStatus,
|
||||
isHistoryEmpty = true,
|
||||
onrampAvailability = availableUsd.right(),
|
||||
onPresetClick = { _, _ -> },
|
||||
onOtherClick = {},
|
||||
)
|
||||
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `returns null when balance is non-zero`() {
|
||||
val result = factory.build(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue