Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-20 17:26:21 +03:00
commit e2632c785c
5 changed files with 46 additions and 6 deletions

View file

@ -4,6 +4,7 @@ import com.tangem.blockchain.common.AmountType
import com.tangem.domain.feedback.models.BlockchainErrorInfo
import com.tangem.domain.redux.LegacyAction
import com.tangem.domain.utils.convertToSdkAmount
import com.tangem.tap.common.extensions.dispatchWithMain
import com.tangem.tap.common.extensions.inject
import com.tangem.tap.common.extensions.stripZeroPlainString
import com.tangem.tap.common.feedback.FeedbackEmail
@ -11,13 +12,23 @@ import com.tangem.tap.common.feedback.RateCanBeBetterEmail
import com.tangem.tap.common.feedback.SendTransactionFailedEmail
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.details.redux.DetailsAction
import com.tangem.tap.proxy.redux.DaggerGraphState
import com.tangem.tap.scope
import com.tangem.tap.store
import com.tangem.utils.coroutines.JobHolder
import com.tangem.utils.coroutines.saveIn
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.rekotlin.Middleware
internal object LegacyMiddleware {
private val prepareDetailsScreenJobHolder = JobHolder()
val legacyMiddleware: Middleware<AppState> = { _, _ ->
{ next ->
{ action ->
@ -85,6 +96,24 @@ internal object LegacyMiddleware {
}
}
}
is LegacyAction.PrepareDetailsScreen -> {
val userWalletsListManager = store.inject(DaggerGraphState::generalUserWalletsListManager)
val walletsRepository = store.inject(DaggerGraphState::walletsRepository)
userWalletsListManager.selectedUserWallet
.distinctUntilChanged()
.onEach { selectedUserWallet ->
store.dispatchWithMain(
DetailsAction.PrepareScreen(
scanResponse = selectedUserWallet.scanResponse,
shouldSaveUserWallets = walletsRepository.shouldSaveUserWalletsSync(),
),
)
}
.flowOn(Dispatchers.IO)
.launchIn(scope)
.saveIn(prepareDetailsScreenJobHolder)
}
}
next(action)
}

View file

@ -20,6 +20,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.tangem.core.ui.components.ResizableText
import com.tangem.core.ui.res.TangemTheme
@ -85,7 +86,9 @@ fun TangemButton(
},
icon = { iconResId ->
Icon(
modifier = Modifier.buttonContentSize(maxContentSize),
modifier = Modifier
.buttonContentSize(maxContentSize)
.padding(vertical = 2.dp),
painter = painterResource(id = iconResId),
tint = colors.contentColor(enabled = enabled).value,
contentDescription = null,

View file

@ -33,9 +33,8 @@ internal fun TangemButtonSize.toHeightDp(): Dp = when (this) {
@Composable
@ReadOnlyComposable
internal fun TangemButtonSize.toShape(): Shape = when (this) {
TangemButtonSize.Default,
TangemButtonSize.WideAction,
-> TangemTheme.shapes.roundedCornersMedium
TangemButtonSize.Default -> TangemTheme.shapes.roundedCornersXMedium
TangemButtonSize.WideAction -> TangemTheme.shapes.roundedCornersMedium
TangemButtonSize.Text -> TangemTheme.shapes.roundedCornersSmall
TangemButtonSize.Selector -> TangemTheme.shapes.roundedCornersSmall
TangemButtonSize.Action -> TangemTheme.shapes.roundedCornersMedium
@ -64,8 +63,8 @@ internal fun TangemButtonSize.toContentPadding(icon: TangemButtonIconPosition):
return when (this) {
TangemButtonSize.Default -> PaddingValues(
top = TangemTheme.dimens.spacing14,
bottom = TangemTheme.dimens.spacing14,
top = TangemTheme.dimens.spacing12,
bottom = TangemTheme.dimens.spacing12,
start = horizontalPadding.first,
end = horizontalPadding.second,
)

View file

@ -38,4 +38,6 @@ sealed interface LegacyAction : Action {
val errorMessage: String,
val scanResponse: ScanResponse,
) : LegacyAction
data object PrepareDetailsScreen : LegacyAction
}

View file

@ -61,6 +61,9 @@ internal class DetailsModel @Inject constructor(
)
init {
// Use to save compatibility with screens that using Redux states
bootstrapScreenState()
items
.onEach(::updateState)
.launchIn(modelScope)
@ -82,6 +85,10 @@ internal class DetailsModel @Inject constructor(
)
}
private fun bootstrapScreenState() {
appStateHolder.dispatch(LegacyAction.PrepareDetailsScreen)
}
private fun sendFeedback() {
modelScope.launch {
val scanResponse = getSelectedWalletSyncUseCase().getOrNull()?.scanResponse