diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/list/RoundedListWithDividers.kt b/core/ui/src/main/java/com/tangem/core/ui/components/list/RoundedListWithDividers.kt index 641044c813..5f85437fb2 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/list/RoundedListWithDividers.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/list/RoundedListWithDividers.kt @@ -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, ) diff --git a/core/ui/src/main/java/com/tangem/core/ui/extensions/String.kt b/core/ui/src/main/java/com/tangem/core/ui/extensions/String.kt index be264409bc..f227e8b1cb 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/extensions/String.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/extensions/String.kt @@ -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() } \ No newline at end of file +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 +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/extensions/TextReference.kt b/core/ui/src/main/java/com/tangem/core/ui/extensions/TextReference.kt index d29cce8cf4..3f1d59e115 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/extensions/TextReference.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/extensions/TextReference.kt @@ -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 } \ No newline at end of file diff --git a/core/utils/src/main/java/com/tangem/utils/extensions/String.kt b/core/utils/src/main/java/com/tangem/utils/extensions/String.kt deleted file mode 100644 index d8ad9d24a8..0000000000 --- a/core/utils/src/main/java/com/tangem/utils/extensions/String.kt +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt index 5701a7ed0c..96a17749b0 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt @@ -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 -> {