Updated on 2026-08-14
This commit is contained in:
parent
319f62f008
commit
00032d7d11
8 changed files with 50 additions and 5 deletions
|
|
@ -296,6 +296,7 @@ private fun SinglePrimaryButton(config: NotificationButtonsState.PrimaryButtonCo
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
size = TangemButtonSize.WideAction,
|
||||
enabled = isEnabled,
|
||||
showProgress = config.shouldShowProgress,
|
||||
)
|
||||
} else {
|
||||
PrimaryButton(
|
||||
|
|
@ -304,6 +305,7 @@ private fun SinglePrimaryButton(config: NotificationButtonsState.PrimaryButtonCo
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
size = TangemButtonSize.WideAction,
|
||||
enabled = isEnabled,
|
||||
showProgress = config.shouldShowProgress,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ data class NotificationConfig(
|
|||
val additionalText: TextReference? = null,
|
||||
@DrawableRes val iconResId: Int? = null,
|
||||
val onClick: () -> Unit,
|
||||
val shouldShowProgress: Boolean = false,
|
||||
) : ButtonsState()
|
||||
|
||||
data class SecondaryButtonConfig(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.tangem.core.ui.message.bottomSheetMessage
|
|||
import com.tangem.domain.feedback.GetWalletMetaInfoUseCase
|
||||
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.pay.TangemPayDetailsConfig
|
||||
import com.tangem.domain.pay.TangemPayEligibilityManager
|
||||
|
|
@ -20,6 +21,8 @@ import com.tangem.domain.pay.usecase.ProduceTangemPayInitialDataUseCase
|
|||
import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.TangemPayHideOnboardingStateTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.TangemPayRefreshNeededStateTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.TangemPayRefreshShowProgressTransformer
|
||||
import com.tangem.features.tangempay.TangemPayFeatureToggles
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
|
@ -28,7 +31,7 @@ internal interface TangemPayIntents {
|
|||
|
||||
suspend fun onPullToRefresh()
|
||||
|
||||
fun onRefreshPayToken(userWalletId: UserWalletId)
|
||||
fun onRefreshPayToken(userWallet: UserWallet)
|
||||
|
||||
fun openDetails(userWalletId: UserWalletId, config: TangemPayDetailsConfig)
|
||||
|
||||
|
|
@ -70,10 +73,21 @@ internal class TangemPayClickIntentsImplementor @Inject constructor(
|
|||
tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId)
|
||||
}
|
||||
|
||||
override fun onRefreshPayToken(userWalletId: UserWalletId) {
|
||||
override fun onRefreshPayToken(userWallet: UserWallet) {
|
||||
stateHolder.update(TangemPayRefreshShowProgressTransformer(userWallet.walletId))
|
||||
|
||||
modelScope.launch {
|
||||
produceInitialDataTangemPay.invoke(userWalletId)
|
||||
tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId)
|
||||
produceInitialDataTangemPay.invoke(userWallet.walletId)
|
||||
.onRight { tangemPayMainScreenCustomerInfoUseCase.fetch(userWallet.walletId) }
|
||||
.onLeft {
|
||||
stateHolder.update(
|
||||
transformer = TangemPayRefreshNeededStateTransformer(
|
||||
userWallet = userWallet,
|
||||
userWalletId = userWallet.walletId,
|
||||
onRefreshClick = { onRefreshPayToken(userWallet) },
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
@DrawableRes private val tangemIcon: Int?,
|
||||
private val onRefreshClick: () -> Unit,
|
||||
private val buttonText: TextReference,
|
||||
private val shouldShowProgress: Boolean,
|
||||
) : Warning(
|
||||
title = resourceReference(id = R.string.tangempay_payment_account_sync_needed),
|
||||
subtitle = resourceReference(id = R.string.tangempay_use_tangem_device_to_restore_payment_account),
|
||||
|
|
@ -161,6 +162,7 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
text = buttonText,
|
||||
iconResId = tangemIcon,
|
||||
onClick = onRefreshClick,
|
||||
shouldShowProgress = shouldShowProgress,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ internal class TangemPayRefreshNeededStateTransformer(
|
|||
is UserWallet.Hot -> resourceReference(id = R.string.tangempay_sync_needed_restore_access)
|
||||
},
|
||||
onRefreshClick = onRefreshClick,
|
||||
shouldShowProgress = false,
|
||||
),
|
||||
)
|
||||
return if (prevState is WalletState.MultiCurrency.Content) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
|
||||
internal class TangemPayRefreshShowProgressTransformer(
|
||||
userWalletId: UserWalletId,
|
||||
) : WalletStateTransformer(userWalletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
val multiContentState = prevState as? WalletState.MultiCurrency.Content ?: return prevState
|
||||
val refreshNeededState = multiContentState.tangemPayState as? TangemPayState.RefreshNeeded ?: return prevState
|
||||
val refreshNotification =
|
||||
refreshNeededState.notification as? WalletNotification.Warning.TangemPayRefreshNeeded ?: return prevState
|
||||
|
||||
return multiContentState.copy(
|
||||
tangemPayState = refreshNeededState.copy(
|
||||
notification = refreshNotification.copy(shouldShowProgress = true),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
transformer = TangemPayRefreshNeededStateTransformer(
|
||||
userWalletId = userWalletId,
|
||||
userWallet = userWallet,
|
||||
onRefreshClick = { clickIntents.onRefreshPayToken(userWalletId) },
|
||||
onRefreshClick = { clickIntents.onRefreshPayToken(userWallet) },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ private fun TangemPayRefreshBlockPreview() {
|
|||
tangemIcon = R.drawable.ic_tangem_24,
|
||||
buttonText = resourceReference(id = R.string.tangempay_sync_needed_restore_access),
|
||||
onRefreshClick = {},
|
||||
shouldShowProgress = true,
|
||||
),
|
||||
),
|
||||
modifier = Modifier,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue