Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-07 18:07:12 +03:00
parent fbf91e4c6d
commit 3e7108d417
5 changed files with 25 additions and 35 deletions

View file

@ -13,10 +13,10 @@ import com.tangem.core.ui.R
import com.tangem.core.ui.components.rows.CornersToRound
import com.tangem.core.ui.components.rows.RoundableCornersRow
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.orMaskWithStars
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.utils.extensions.orHide
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
@ -57,7 +57,7 @@ fun LazyListScope.roundedListWithDividersItems(
) { index, row ->
InitialInfoContentRow(
startText = row.startText.resolveReference(),
endText = row.endText.resolveReference().orHide(hideEndText && row.isEndTextHideable),
endText = row.endText.resolveReference().orMaskWithStars(hideEndText && row.isEndTextHideable),
cornersToRound = getCornersToRound(index, rows.size),
iconClick = row.iconClick,
)

View file

@ -6,6 +6,7 @@ import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType
import com.google.zxing.qrcode.QRCodeWriter
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
import com.tangem.utils.StringsSigns.STARS
import java.util.Hashtable
@Suppress("MagicNumber")
@ -31,4 +32,8 @@ fun String.toQrCode(sizePx: Int = 256, paddingPx: Int = 0): Bitmap {
return bmp
}
fun String.capitalize(): String = replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
fun String.capitalize(): String = replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
fun String.orMaskWithStars(maskWithStars: Boolean): String {
return if (maskWithStars) STARS else this
}

View file

@ -233,6 +233,21 @@ operator fun TextReference.plus(ref: TextReference): TextReference {
}
}
/**
* Returns the TextReference itself if hide is false, otherwise returns a reference with STARS.
*
* @param mask A boolean flag that determines whether to hide the string.
* If true, the original TextReference will be replaced by reference with STARS.
* If false, the original TextReference will be returned.
*
* @return The original reference if hide is false, or reference with STARS if hide is true.
*/
fun TextReference.orMaskWithStars(mask: Boolean): TextReference {
return if (mask) stringReference(STARS) else this
}
@Suppress("NOTHING_TO_INLINE")
@OptIn(ExperimentalContracts::class)
inline fun TextReference?.isNullOrEmpty(): Boolean {
@ -251,17 +266,4 @@ private fun formatAnnotated(rawString: String): AnnotatedString {
return buildAnnotatedString {
appendMarkdown(markdownText = rawString, node = parsedTree)
}
}
/**
* Returns the TextReference itself if hide is false, otherwise returns a reference with STARS.
*
* @param mask A boolean flag that determines whether to hide the string.
* If true, the original TextReference will be replaced by reference with STARS.
* If false, the original TextReference will be returned.
*
* @return The original reference if hide is false, or reference with STARS if hide is true.
*/
fun TextReference.orMaskWithStars(mask: Boolean): TextReference {
return if (mask) stringReference(STARS) else this
}

View file

@ -1,16 +0,0 @@
package com.tangem.utils.extensions
import com.tangem.utils.StringsSigns.STARS
/**
* Returns the string itself if hide is false, otherwise returns a string of stars.
*
* @param hide A boolean flag that determines whether to hide the string.
* If true, the string will be hidden (replaced by `STARS`).
* If false, the original string will be returned.
*
* @return The original string if hide is false, or STARS if hide is true.
*/
fun String.orHide(hide: Boolean): String {
return if (hide) STARS else this
}

View file

@ -51,7 +51,6 @@ import com.tangem.features.staking.impl.presentation.state.stub.StakingClickInte
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
import com.tangem.utils.StringsSigns.DOT
import com.tangem.utils.StringsSigns.PLUS
import com.tangem.utils.extensions.orHide
import com.tangem.utils.extensions.orZero
import kotlinx.collections.immutable.ImmutableList
@ -172,11 +171,11 @@ private fun StakingRewardBlock(
annotatedReference {
append(PLUS)
appendSpace()
append(rewardFiat.orHide(isBalanceHidden))
append(rewardFiat.orMaskWithStars(isBalanceHidden))
appendSpace()
append(DOT)
appendSpace()
append(rewardCrypto.orHide(isBalanceHidden))
append(rewardCrypto.orMaskWithStars(isBalanceHidden))
} to TangemTheme.colors.text.primary1
}
RewardBlockType.RewardUnavailable -> {