Updated on 2026-08-14
This commit is contained in:
parent
a8c5f41ea6
commit
fc0295bf33
1 changed files with 12 additions and 0 deletions
|
|
@ -21,11 +21,14 @@ import com.tangem.features.tangempay.model.transformers.DetailsRevealedStateTran
|
|||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.JobHolder
|
||||
import com.tangem.utils.coroutines.saveIn
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import com.tangem.utils.transformer.update as transformerUpdate
|
||||
|
||||
private const val SHOW_DETAILS_TIME = 30_000L
|
||||
|
||||
@Stable
|
||||
@ModelScoped
|
||||
internal class TangemPayCardDetailsBlockModel @Inject constructor(
|
||||
|
|
@ -49,6 +52,7 @@ internal class TangemPayCardDetailsBlockModel @Inject constructor(
|
|||
field = MutableStateFlow(stateFactory.getInitialState())
|
||||
|
||||
private val revealCardDetailsJobHolder = JobHolder()
|
||||
private val showCardDetailsTimerJobHolder = JobHolder()
|
||||
|
||||
init {
|
||||
subscribeToCardFrozenState()
|
||||
|
|
@ -82,6 +86,7 @@ internal class TangemPayCardDetailsBlockModel @Inject constructor(
|
|||
onClickHide = ::hideCardDetails,
|
||||
),
|
||||
)
|
||||
launchShowDetailsTimer()
|
||||
}
|
||||
.onLeft {
|
||||
uiState.transformerUpdate(transformer = DetailsHiddenStateTransformer(stateFactory))
|
||||
|
|
@ -90,6 +95,13 @@ internal class TangemPayCardDetailsBlockModel @Inject constructor(
|
|||
}.saveIn(revealCardDetailsJobHolder)
|
||||
}
|
||||
|
||||
private fun launchShowDetailsTimer() {
|
||||
modelScope.launch {
|
||||
delay(SHOW_DETAILS_TIME)
|
||||
hideCardDetails()
|
||||
}.saveIn(showCardDetailsTimerJobHolder)
|
||||
}
|
||||
|
||||
fun hideCardDetails() {
|
||||
modelScope.launch {
|
||||
revealCardDetailsJobHolder.cancel()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue