Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-12 11:18:11 +02:00
parent b7cd4e300e
commit 85858df71a
8 changed files with 64 additions and 32 deletions

View file

@ -40,6 +40,7 @@ import com.tangem.core.ui.components.TextShimmer
import com.tangem.core.ui.components.currency.fiaticon.FiatIcon import com.tangem.core.ui.components.currency.fiaticon.FiatIcon
import com.tangem.core.ui.components.currency.icon.CurrencyIcon import com.tangem.core.ui.components.currency.icon.CurrencyIcon
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resolveReference
@ -89,6 +90,7 @@ fun AmountFieldV2(
} else { } else {
amountUM.amountTextField.cryptoAmount to amountUM.amountTextField.value amountUM.amountTextField.cryptoAmount to amountUM.amountTextField.value
} }
val colors = TangemAmountTextFieldColors
AmountTextField( AmountTextField(
value = primaryValue, value = primaryValue,
decimals = primaryAmount.decimals, decimals = primaryAmount.decimals,
@ -97,9 +99,10 @@ fun AmountFieldV2(
symbol = primaryAmount.currencySymbol, symbol = primaryAmount.currencySymbol,
currencyCode = currencyCode, currencyCode = currencyCode,
decimalFormat = decimalFormat, decimalFormat = decimalFormat,
symbolColor = TangemTheme.colors.text.disabled, symbolColor = colors.disabledTextColor,
), ),
onValueChange = onValueChange, onValueChange = onValueChange,
colors = colors,
keyboardOptions = amountUM.amountTextField.keyboardOptions, keyboardOptions = amountUM.amountTextField.keyboardOptions,
keyboardActions = amountUM.amountTextField.keyboardActions, keyboardActions = amountUM.amountTextField.keyboardActions,
textStyle = TangemTheme.typography.head.copy( textStyle = TangemTheme.typography.head.copy(

View file

@ -39,7 +39,7 @@ import java.text.DecimalFormat
* @param onValueChange callback * @param onValueChange callback
* @param textStyle text and placeholder styles * @param textStyle text and placeholder styles
* @param modifier modifier * @param modifier modifier
* @param color text color * @param colors text and background colors
* @param visualTransformation text visual transformation * @param visualTransformation text visual transformation
* @param keyboardOptions keyboard options * @param keyboardOptions keyboard options
* @param keyboardActions keyboard actions * @param keyboardActions keyboard actions
@ -55,11 +55,10 @@ fun AmountTextField(
onValueChange: (String) -> Unit, onValueChange: (String) -> Unit,
textStyle: TextStyle, textStyle: TextStyle,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
color: Color = TangemTheme.colors.text.primary1, colors: AmountTextFieldColors = TangemAmountTextFieldColors,
backgroundColor: Color = TangemTheme.colors.background.action,
visualTransformation: VisualTransformation = AmountVisualTransformation( visualTransformation: VisualTransformation = AmountVisualTransformation(
decimals = decimals, decimals = decimals,
symbolColor = if (value.isBlank()) TangemTheme.colors.text.disabled else color, symbolColor = if (value.isBlank()) colors.disabledTextColor else colors.textColor,
), ),
keyboardOptions: KeyboardOptions = KeyboardOptions( keyboardOptions: KeyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number, keyboardType = KeyboardType.Number,
@ -84,7 +83,7 @@ fun AmountTextField(
} else { } else {
textStyle.fontSize textStyle.fontSize
} }
val textColor = if (value.isBlank()) TangemTheme.colors.text.disabled else color val textColor = if (value.isBlank()) colors.disabledTextColor else colors.textColor
SimpleTextField( SimpleTextField(
value = value, value = value,
onValueChange = { newText -> onValueChange = { newText ->
@ -110,12 +109,28 @@ fun AmountTextField(
readOnly = !isEnabled, readOnly = !isEnabled,
visualTransformation = visualTransformation, visualTransformation = visualTransformation,
modifier = Modifier modifier = Modifier
.background(backgroundColor) .background(colors.backgroundColor)
.testTag(SendScreenTestTags.INPUT_TEXT_FIELD), .testTag(SendScreenTestTags.INPUT_TEXT_FIELD),
) )
} }
} }
val TangemAmountTextFieldColors: AmountTextFieldColors
@Composable
@ReadOnlyComposable
get() = AmountTextFieldColors(
textColor = TangemTheme.colors.text.primary1,
disabledTextColor = TangemTheme.colors.text.disabled,
backgroundColor = TangemTheme.colors.background.action,
)
@Immutable
data class AmountTextFieldColors(
val textColor: Color,
val disabledTextColor: Color,
val backgroundColor: Color,
)
private fun prepareEnter(oldValue: String, newValue: String, decimalFormat: DecimalFormat, decimals: Int): String { private fun prepareEnter(oldValue: String, newValue: String, decimalFormat: DecimalFormat, decimals: Int): String {
val decimalSymbol = decimalFormat.decimalFormatSymbols.decimalSeparator val decimalSymbol = decimalFormat.decimalFormatSymbols.decimalSeparator
return if (decimalFormat.isValidSymbols(newValue)) { return if (decimalFormat.isValidSymbols(newValue)) {
@ -179,6 +194,7 @@ private fun AmountTextFieldPreview(
value = text, value = text,
decimals = amount.decimals, decimals = amount.decimals,
onValueChange = { text = it }, onValueChange = { text = it },
colors = TangemAmountTextFieldColors,
textStyle = TangemTheme.typography.h2.copy( textStyle = TangemTheme.typography.h2.copy(
color = TangemTheme.colors.text.primary1, color = TangemTheme.colors.text.primary1,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,

View file

@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.components.inputrow.inner.DividerContainer
import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.TextReference
@ -85,7 +86,7 @@ fun InputRowEnterAmount(
symbolColor = textColor, symbolColor = textColor,
), ),
onValueChange = onValueChange, onValueChange = onValueChange,
color = textColor, colors = TangemAmountTextFieldColors.copy(textColor = textColor),
textStyle = TangemTheme.typography.body2, textStyle = TangemTheme.typography.body2,
keyboardOptions = keyboardOptions, keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions, keyboardActions = keyboardActions,

View file

@ -16,6 +16,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.tangem.core.ui.R import com.tangem.core.ui.R
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.components.inputrow.inner.DividerContainer
import com.tangem.core.ui.components.tooltip.TangemTooltip import com.tangem.core.ui.components.tooltip.TangemTooltip
@ -90,7 +91,7 @@ fun InputRowEnterInfoAmount(
symbolColor = textColor, symbolColor = textColor,
), ),
onValueChange = onValueChange, onValueChange = onValueChange,
color = textColor, colors = TangemAmountTextFieldColors.copy(textColor = textColor),
isEnabled = !isReadOnly, isEnabled = !isReadOnly,
textStyle = TangemTheme.typography.body2, textStyle = TangemTheme.typography.body2,
keyboardOptions = keyboardOptions, keyboardOptions = keyboardOptions,
@ -181,12 +182,14 @@ fun InputRowEnterInfoAmountV2(
symbolColor = symbolColor, symbolColor = symbolColor,
), ),
onValueChange = onValueChange, onValueChange = onValueChange,
color = textColor, colors = TangemAmountTextFieldColors.copy(
textColor = textColor,
backgroundColor = Color.Transparent,
),
isEnabled = !isReadOnly, isEnabled = !isReadOnly,
textStyle = TangemTheme.typography.body2, textStyle = TangemTheme.typography.body2,
keyboardOptions = keyboardOptions, keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions, keyboardActions = keyboardActions,
backgroundColor = Color.Transparent,
modifier = Modifier modifier = Modifier
.padding(top = TangemTheme.dimens.spacing8) .padding(top = TangemTheme.dimens.spacing8)
.weight(1f) .weight(1f)

View file

@ -26,6 +26,7 @@ import coil.compose.AsyncImage
import com.tangem.common.ui.amountScreen.models.AmountFieldModel import com.tangem.common.ui.amountScreen.models.AmountFieldModel
import com.tangem.core.ui.components.SpacerH import com.tangem.core.ui.components.SpacerH
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.extensions.stringResourceSafe
@ -84,18 +85,20 @@ private fun OnrampHeaderTitle() {
private fun OnrampAmountField(amountField: AmountFieldModel, currencyCode: String) { private fun OnrampAmountField(amountField: AmountFieldModel, currencyCode: String) {
val decimalFormat = rememberDecimalFormat() val decimalFormat = rememberDecimalFormat()
val requester = remember { FocusRequester() } val requester = remember { FocusRequester() }
val colors = TangemAmountTextFieldColors
AmountTextField( AmountTextField(
value = amountField.fiatValue, value = amountField.fiatValue,
decimals = amountField.fiatAmount.decimals, decimals = amountField.fiatAmount.decimals,
colors = colors,
visualTransformation = AmountVisualTransformation( visualTransformation = AmountVisualTransformation(
decimals = amountField.fiatAmount.decimals, decimals = amountField.fiatAmount.decimals,
symbol = currencyCode, symbol = currencyCode,
currencyCode = currencyCode, currencyCode = currencyCode,
decimalFormat = decimalFormat, decimalFormat = decimalFormat,
symbolColor = if (amountField.fiatValue.isBlank()) { symbolColor = if (amountField.fiatValue.isBlank()) {
TangemTheme.colors.text.disabled colors.disabledTextColor
} else { } else {
TangemTheme.colors.text.primary1 colors.textColor
}, },
), ),
onValueChange = amountField.onValueChange, onValueChange = amountField.onValueChange,

View file

@ -22,6 +22,7 @@ import com.tangem.core.ui.components.TextShimmer
import com.tangem.core.ui.components.appbar.TangemTopAppBar import com.tangem.core.ui.components.appbar.TangemTopAppBar
import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.extensions.stringResourceSafe
@ -99,20 +100,22 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
text = "$5000", text = "$5000",
) )
} else { } else {
val colors = TangemAmountTextFieldColors
AmountTextField( AmountTextField(
value = state.amountFieldModel.value, value = state.amountFieldModel.value,
decimals = state.amountFieldModel.decimals, decimals = state.amountFieldModel.decimals,
onValueChange = state.amountFieldModel.onValueChange, onValueChange = state.amountFieldModel.onValueChange,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
colors = colors,
visualTransformation = AmountVisualTransformation( visualTransformation = AmountVisualTransformation(
decimals = state.amountFieldModel.decimals, decimals = state.amountFieldModel.decimals,
symbol = state.currencyCode, symbol = state.currencyCode,
currencyCode = state.currencyCode, currencyCode = state.currencyCode,
decimalFormat = rememberDecimalFormat(), decimalFormat = rememberDecimalFormat(),
symbolColor = if (state.amountFieldModel.value.isBlank()) { symbolColor = if (state.amountFieldModel.value.isBlank()) {
TangemTheme.colors.text.disabled colors.disabledTextColor
} else { } else {
TangemTheme.colors.text.primary1 colors.textColor
}, },
), ),
textStyle = TangemTheme.typography.head.copy( textStyle = TangemTheme.typography.head.copy(

View file

@ -4,6 +4,9 @@ import android.content.res.Configuration
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
@ -17,6 +20,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.fields.AmountTextField import com.tangem.core.ui.components.fields.AmountTextField
import com.tangem.core.ui.components.fields.TangemAmountTextFieldColors
import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation
import com.tangem.core.ui.ds.image.TangemIconUM import com.tangem.core.ui.ds.image.TangemIconUM
import com.tangem.core.ui.ds.topbar.TangemTopBar import com.tangem.core.ui.ds.topbar.TangemTopBar
@ -107,27 +111,32 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
radius = TangemTheme.dimens2.x25, radius = TangemTheme.dimens2.x25,
) )
} else { } else {
val colors = TangemAmountTextFieldColors.copy(
textColor = TangemTheme.colors3.text.primary,
disabledTextColor = TangemTheme.colors3.text.tertiary,
backgroundColor = TangemTheme.colors3.bg.secondary,
)
AmountTextField( AmountTextField(
value = state.amountFieldModel.value, value = state.amountFieldModel.value,
decimals = state.amountFieldModel.decimals, decimals = state.amountFieldModel.decimals,
onValueChange = state.amountFieldModel.onValueChange, onValueChange = state.amountFieldModel.onValueChange,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
colors = colors,
visualTransformation = AmountVisualTransformation( visualTransformation = AmountVisualTransformation(
decimals = state.amountFieldModel.decimals, decimals = state.amountFieldModel.decimals,
symbol = state.currencyCode, symbol = state.currencyCode,
currencyCode = state.currencyCode, currencyCode = state.currencyCode,
decimalFormat = rememberDecimalFormat(), decimalFormat = rememberDecimalFormat(),
symbolColor = if (state.amountFieldModel.value.isBlank()) { symbolColor = if (state.amountFieldModel.value.isBlank()) {
TangemTheme.colors3.text.tertiary colors.disabledTextColor
} else { } else {
TangemTheme.colors3.text.primary colors.textColor
}, },
), ),
textStyle = TangemTheme.typography3.display.medium.copy( textStyle = TangemTheme.typography3.display.medium.copy(
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
), ),
isAutoResize = true, isAutoResize = true,
backgroundColor = TangemTheme.colors3.bg.secondary,
) )
} }
} }
@ -136,17 +145,13 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
@Composable @Composable
private fun PresetsRow(presets: ImmutableList<TangemPayCardLimitSetupUM.LimitPresetUM>) { private fun PresetsRow(presets: ImmutableList<TangemPayCardLimitSetupUM.LimitPresetUM>) {
if (presets.isEmpty()) return if (presets.isEmpty()) return
Row( LazyRow(
modifier = Modifier state = rememberLazyListState(),
.fillMaxWidth() contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp),
.padding(horizontal = TangemTheme.dimens2.x3, vertical = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens2.x2),
) { ) {
presets.forEach { preset -> items(presets) { preset ->
PresetChip( PresetChip(preset = preset)
preset = preset,
modifier = Modifier.weight(1f),
)
} }
} }
} }
@ -164,9 +169,7 @@ private fun PresetChip(preset: TangemPayCardLimitSetupUM.LimitPresetUM, modifier
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Text( Text(
modifier = Modifier modifier = Modifier.padding(vertical = 1.dp),
.padding(vertical = 1.dp)
.fillMaxWidth(),
text = preset.label, text = preset.label,
style = TangemTheme.typography3.subheading.medium, style = TangemTheme.typography3.subheading.medium,
color = TangemTheme.colors3.text.primary, color = TangemTheme.colors3.text.primary,

View file

@ -159,7 +159,7 @@ private fun CurrentLimitBlockV2(state: TangemPayDailyLimitBlockState, modifier:
.padding(start = TangemTheme.dimens2.x3) .padding(start = TangemTheme.dimens2.x3)
.layoutId(TangemRowLayoutId.TAIL), .layoutId(TangemRowLayoutId.TAIL),
variant = TangemButton.Variant.Secondary, variant = TangemButton.Variant.Secondary,
text = resourceReference(R.string.common_edit), text = resourceReference(R.string.tangempay_card_page_daily_limit_change),
onClick = state.onChangeClick, onClick = state.onChangeClick,
size = TangemButton.Size.X10, size = TangemButton.Size.X10,
) )