Updated on 2026-08-14
This commit is contained in:
parent
47a1b16137
commit
43738a6b63
8 changed files with 88 additions and 32 deletions
|
|
@ -24,7 +24,6 @@ import com.tangem.core.ui.components.inputrow.inner.InputRowAsyncImage
|
|||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resolveAnnotatedReference
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemColorPalette
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
|
||||
|
|
@ -33,15 +32,17 @@ import com.tangem.core.ui.res.TangemThemePreview
|
|||
* [Input Row Image](https://www.figma.com/design/14ISV23YB1yVW1uNVwqrKv/Android?node-id=2841-1589&t=u6pOF6lsdpvWLELb-4)
|
||||
*
|
||||
* @param subtitle subtitle text
|
||||
* @param caption caption text
|
||||
* @param modifier modifier
|
||||
* @param caption caption text
|
||||
* @param imageUrl icon to load
|
||||
* @param iconRes icon resource
|
||||
* @param subtitleColor subtitle text color
|
||||
* @param captionColor caption text color
|
||||
* @param iconTint icon tint
|
||||
* @param isGrayscaleImage whether to display grayscale image
|
||||
* @param subtitleEndIconRes icon to show after subtitle
|
||||
* @param iconEndRes icon to end of row
|
||||
* @param onImageError composable to show if image loading failed
|
||||
* @param subtitleExtraContent subtitle extra content
|
||||
* @param extraContent extra content
|
||||
*/
|
||||
@Suppress("LongMethod")
|
||||
|
|
@ -56,10 +57,9 @@ internal fun InputRowImageBase(
|
|||
captionColor: Color = TangemTheme.colors.text.tertiary,
|
||||
iconTint: Color = TangemTheme.colors.icon.informative,
|
||||
isGrayscaleImage: Boolean = false,
|
||||
@DrawableRes subtitleEndIconRes: Int? = null,
|
||||
subtitleEndIconTint: Color = TangemColorPalette.Azure,
|
||||
@DrawableRes iconEndRes: Int? = null,
|
||||
onImageError: (@Composable () -> Unit)? = null,
|
||||
subtitleExtraContent: (@Composable RowScope.() -> Unit)? = null,
|
||||
extraContent: (@Composable RowScope.() -> Unit)? = null,
|
||||
) {
|
||||
Row(
|
||||
|
|
@ -100,10 +100,7 @@ internal fun InputRowImageBase(
|
|||
style = TangemTheme.typography.subtitle2,
|
||||
color = subtitleColor,
|
||||
)
|
||||
SubtitleEndIconRes(
|
||||
subtitleEndIconRes = subtitleEndIconRes,
|
||||
subtitleEndIconTint = subtitleEndIconTint,
|
||||
)
|
||||
subtitleExtraContent?.invoke(this)
|
||||
}
|
||||
if (caption != null) {
|
||||
Text(
|
||||
|
|
@ -124,23 +121,6 @@ internal fun InputRowImageBase(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.SubtitleEndIconRes(subtitleEndIconRes: Int?, subtitleEndIconTint: Color) {
|
||||
AnimatedVisibility(
|
||||
visible = subtitleEndIconRes != null,
|
||||
label = "Subtitle end icon visibility animation",
|
||||
modifier = Modifier.align(Alignment.CenterVertically),
|
||||
) {
|
||||
val icon = remember(this) { requireNotNull(subtitleEndIconRes) }
|
||||
Icon(
|
||||
painter = rememberVectorPainter(image = ImageVector.vectorResource(id = icon)),
|
||||
tint = subtitleEndIconTint,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing4),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.InputRowEndIcon(iconRes: Int?) {
|
||||
AnimatedVisibility(
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@ package com.tangem.core.ui.components.inputrow
|
|||
|
||||
import android.content.res.Configuration
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
|
|
@ -17,6 +24,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
|||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.atoms.text.EllipsisText
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.core.ui.res.TangemColorPalette
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
|
||||
|
|
@ -24,17 +32,19 @@ import com.tangem.core.ui.res.TangemThemePreview
|
|||
* Input row component with selector
|
||||
* [Input Row Image](https://www.figma.com/design/14ISV23YB1yVW1uNVwqrKv/Android?node-id=2841-1589&t=u6pOF6lsdpvWLELb-4)
|
||||
*
|
||||
* @param title title text
|
||||
* @param subtitle subtitle text
|
||||
* @param caption caption text
|
||||
* @param infoTitle info title text
|
||||
* @param infoSubtitle info subtitle text
|
||||
* @param modifier modifier
|
||||
* @param title title text
|
||||
* @param caption caption text
|
||||
* @param infoSubtitle info subtitle text
|
||||
* @param imageUrl icon to load
|
||||
* @param iconRes icon resource
|
||||
* @param subtitleColor subtitle text color
|
||||
* @param captionColor caption text color
|
||||
* @param iconTint icon color
|
||||
* @param isGrayscaleImage whether to display grayscale image
|
||||
* @param showPendingIcon whether to show pending icon
|
||||
* @param subtitleEndIconRes subtitle icon to end of row
|
||||
* @param iconEndRes icon to end of row
|
||||
* @param onImageError composable to show if image loading failed
|
||||
*/
|
||||
|
|
@ -78,9 +88,14 @@ fun InputRowImageInfo(
|
|||
subtitleColor = subtitleColor,
|
||||
captionColor = captionColor,
|
||||
isGrayscaleImage = isGrayscaleImage,
|
||||
subtitleEndIconRes = subtitleEndIconRes,
|
||||
iconEndRes = iconEndRes,
|
||||
onImageError = onImageError,
|
||||
subtitleExtraContent = {
|
||||
SubtitleEndIconRes(
|
||||
subtitleEndIconRes = subtitleEndIconRes,
|
||||
subtitleEndIconTint = TangemColorPalette.Azure,
|
||||
)
|
||||
},
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing2),
|
||||
|
|
@ -120,6 +135,23 @@ fun InputRowImageInfo(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.SubtitleEndIconRes(subtitleEndIconRes: Int?, subtitleEndIconTint: Color) {
|
||||
AnimatedVisibility(
|
||||
visible = subtitleEndIconRes != null,
|
||||
label = "Subtitle end icon visibility animation",
|
||||
modifier = Modifier.align(Alignment.CenterVertically),
|
||||
) {
|
||||
val icon = remember(this) { requireNotNull(subtitleEndIconRes) }
|
||||
Icon(
|
||||
painter = rememberVectorPainter(image = ImageVector.vectorResource(id = icon)),
|
||||
tint = subtitleEndIconTint,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing4),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region Preview
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.res.Configuration
|
|||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -40,8 +41,9 @@ import java.math.BigDecimal
|
|||
* @param subtitleColor subtitle text color
|
||||
* @param captionColor caption text color
|
||||
* @param isSelected true if selected
|
||||
* @param selectorContent selector content
|
||||
* @param onImageError composable to show if image loading failed
|
||||
* @param subtitleExtraContent subtitle selector content
|
||||
* @param selectorContent selector content
|
||||
*/
|
||||
@Composable
|
||||
fun InputRowImageSelector(
|
||||
|
|
@ -54,6 +56,7 @@ fun InputRowImageSelector(
|
|||
captionColor: Color = TangemTheme.colors.text.tertiary,
|
||||
isSelected: Boolean = false,
|
||||
onImageError: (@Composable () -> Unit)? = null,
|
||||
subtitleExtraContent: (@Composable RowScope.() -> Unit)? = null,
|
||||
selectorContent: @Composable ((isSelected: Boolean, isEnabled: Boolean, onSelect: () -> Unit) -> Unit),
|
||||
) {
|
||||
InputRowImageBase(
|
||||
|
|
@ -63,6 +66,7 @@ fun InputRowImageSelector(
|
|||
subtitleColor = subtitleColor,
|
||||
captionColor = captionColor,
|
||||
onImageError = onImageError,
|
||||
subtitleExtraContent = subtitleExtraContent,
|
||||
modifier = modifier
|
||||
.clickable(
|
||||
onClick = onSelect,
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class YieldConverter(
|
|||
stakedBalance = validatorDTO.stakedBalance,
|
||||
votingPower = validatorDTO.votingPower,
|
||||
preferred = validatorDTO.preferred,
|
||||
isStrategicPartner = isStrategicPartner(validatorDTO.address),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -174,4 +175,12 @@ class YieldConverter(
|
|||
else -> Yield.Args.ArgType.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
private fun isStrategicPartner(validatorAddress: String): Boolean = PARTNERS.any { it == validatorAddress }
|
||||
|
||||
private companion object {
|
||||
val PARTNERS = listOf(
|
||||
"cosmosvaloper1wrx0x9m9ykdhw9sg04v7uljme53wuj03aa5d4f",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ data class Yield(
|
|||
val stakedBalance: String? = null,
|
||||
val votingPower: Double? = null,
|
||||
val preferred: Boolean,
|
||||
val isStrategicPartner: Boolean,
|
||||
) {
|
||||
|
||||
enum class ValidatorStatus {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ internal object ConfirmationStatePreviewData {
|
|||
website = "https://luganodes.com/",
|
||||
votingPower = 0.09778360195377911,
|
||||
preferred = true,
|
||||
isStrategicPartner = false,
|
||||
),
|
||||
Yield.Validator(
|
||||
address = "0x35b1ca0f398905cf752e6fe122b51c88022fca32",
|
||||
|
|
@ -40,6 +41,7 @@ internal object ConfirmationStatePreviewData {
|
|||
website = "https://infstones.com/",
|
||||
votingPower = 0.0034366257754399774,
|
||||
preferred = true,
|
||||
isStrategicPartner = false,
|
||||
),
|
||||
Yield.Validator(
|
||||
address = "0xd14a87025109013b0a2354a775cb335f926af65a",
|
||||
|
|
@ -52,6 +54,7 @@ internal object ConfirmationStatePreviewData {
|
|||
website = "https://infstones.com/",
|
||||
votingPower = 0.023487238579718264,
|
||||
preferred = true,
|
||||
isStrategicPartner = true,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ internal object InitialStakingStatePreview {
|
|||
stakedBalance = null,
|
||||
votingPower = null,
|
||||
preferred = false,
|
||||
isStrategicPartner = false,
|
||||
),
|
||||
pendingActions = persistentListOf(),
|
||||
isClickable = true,
|
||||
|
|
|
|||
|
|
@ -5,16 +5,22 @@ import androidx.compose.animation.AnimatedVisibility
|
|||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.components.inputrow.InputRowImageSelector
|
||||
import com.tangem.core.ui.decorations.roundedShapeItemDecoration
|
||||
import com.tangem.core.ui.extensions.*
|
||||
|
|
@ -78,6 +84,9 @@ internal fun StakingValidatorListContent(
|
|||
false,
|
||||
)
|
||||
.background(TangemTheme.colors.background.action),
|
||||
subtitleExtraContent = {
|
||||
ValidatorLabel(item.isStrategicPartner)
|
||||
},
|
||||
selectorContent = { checked, _, _ ->
|
||||
AnimatedVisibility(
|
||||
modifier = Modifier,
|
||||
|
|
@ -99,6 +108,23 @@ internal fun StakingValidatorListContent(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.ValidatorLabel(isStrategicPartner: Boolean) {
|
||||
if (isStrategicPartner) {
|
||||
Text(
|
||||
text = stringResource(R.string.staking_validators_label),
|
||||
style = TangemTheme.typography.caption1,
|
||||
color = TangemTheme.colors.icon.constant,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterVertically)
|
||||
.padding(horizontal = 6.dp)
|
||||
.clip(RoundedCornerShape(6.dp))
|
||||
.background(TangemTheme.colors.text.accent)
|
||||
.padding(horizontal = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region Preview
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue