Updated on 2026-08-14

This commit is contained in:
Tangem 2023-06-26 21:06:43 +03:00
parent a4e960106e
commit c0fb9e8bdb
8 changed files with 24 additions and 14 deletions

View file

@ -14,7 +14,9 @@ private fun internalReduce(action: Action, state: AppState): HomeState {
when (action) {
is HomeAction.InsertStory -> {
state = state.copy(
stories = listOf(action.story) + state.stories,
stories = state.stories.toMutableList().apply {
add(action.position, action.story)
},
)
}
is HomeAction.ScanInProgress -> {

View file

@ -170,7 +170,7 @@ class DefaultLearn2earnInteractor(
}
override fun buildUriForOldUser(): Uri {
return webViewUriBuilder.buildUriForOlgUser()
return webViewUriBuilder.buildUriForOldUser()
}
override fun getBasicAuthHeaders(): ArrayList<String> {
@ -242,11 +242,7 @@ class DefaultLearn2earnInteractor(
}
private fun getCurrencyForAward(): Currency? {
if (promotion.info == null) return null
val info = promotion.getPromotionInfo()
val token = info.awardPaymentToken
// use only the first available network
val token = promotion.info?.awardPaymentToken ?: return null
return Currency.NonNativeToken(
id = token.id,

View file

@ -3,7 +3,8 @@ package com.tangem.feature.learn2earn.domain
import com.tangem.utils.converter.TwoWayConverter
/**
* Converter which helps prepare a list of headers to put it into the Intent and extract them later.
* A converter that helps prepare a list of headers to put in an intent and retrieve them later.
*
[REDACTED_AUTHOR]
*/
internal class HeadersConverter : TwoWayConverter<Map<String, String>, ArrayList<String>> {

View file

@ -23,7 +23,7 @@ internal class WebViewUriBuilder(
return builder.build()
}
fun buildUriForOlgUser(): Uri {
fun buildUriForOldUser(): Uri {
val builder = makeWebViewUriBuilder()
.appendQueryParameter("type", QUERY_EXISTED_CARD)

View file

@ -4,7 +4,7 @@ import android.net.Uri
/**
* Handler that helps determine what actions to take inside the WebView of the Learn2earnWebViewActivity after
* a redirect has been processedWebViewRedirectHandler
* a redirect has been processed by WebViewRedirectHandler
*
[REDACTED_AUTHOR]
*/

View file

@ -49,7 +49,7 @@ internal fun GetBonusView(state: MainScreenState, modifier: Modifier = Modifier)
Box(modifier = Modifier.padding(horizontal = TangemTheme.dimens.size16)) {
Image(
painter = painterResource(id = R.drawable.img_1inch_logo_42_40),
alpha = state.logoAlphaValue,
alpha = state.logoState.alpha,
contentDescription = null,
)
if (state.showProgress) {
@ -147,5 +147,6 @@ private fun makePreviewState(): MainScreenState = MainScreenState(
isVisible = true,
onClick = {},
description = MainScreenState.Description.Learn(0, "0"),
logoState = MainScreenState.LogoState.Idle,
showProgress = false,
)

View file

@ -25,10 +25,15 @@ data class MainScreenState(
val onClick: () -> Unit,
val description: Description,
val showProgress: Boolean,
val logoAlphaValue: Float = 1f,
val logoState: LogoState,
val dialog: Dialog? = null,
) {
sealed class LogoState(val alpha: Float) {
object Idle : LogoState(alpha = 1.0f)
object InProgress : LogoState(alpha = 0.2f)
}
sealed class Description(val title: TextReference, val subtitle: TextReference) {
class Learn(count: Int, award: String) : Description(

View file

@ -13,6 +13,7 @@ internal fun Learn2earnState.Companion.init(uiActions: UiActions): Learn2earnSta
isVisible = false,
onClick = uiActions.buttonMainClick,
description = MainScreenState.Description.Learn(0, "0"),
logoState = MainScreenState.LogoState.Idle,
showProgress = false,
),
)
@ -42,7 +43,7 @@ internal fun Learn2earnState.updateGetBonusVisibility(isVisible: Boolean): Learn
}
}
internal fun Learn2earnState.changeGetBounsDescription(description: MainScreenState.Description,): Learn2earnState {
internal fun Learn2earnState.changeGetBounsDescription(description: MainScreenState.Description): Learn2earnState {
return if (mainScreenState.description == description) {
this
} else {
@ -86,7 +87,11 @@ internal fun Learn2earnState.updateProgress(showProgress: Boolean): Learn2earnSt
copy(
mainScreenState = mainScreenState.copy(
showProgress = showProgress,
logoAlphaValue = if (showProgress) 0.2f else 1f,
logoState = if (showProgress) {
MainScreenState.LogoState.InProgress
} else {
MainScreenState.LogoState.Idle
},
),
)
}