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.icon.CurrencyIcon
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.extensions.TextReference
import com.tangem.core.ui.extensions.resolveReference
@ -89,6 +90,7 @@ fun AmountFieldV2(
} else {
amountUM.amountTextField.cryptoAmount to amountUM.amountTextField.value
}
val colors = TangemAmountTextFieldColors
AmountTextField(
value = primaryValue,
decimals = primaryAmount.decimals,
@ -97,9 +99,10 @@ fun AmountFieldV2(
symbol = primaryAmount.currencySymbol,
currencyCode = currencyCode,
decimalFormat = decimalFormat,
symbolColor = TangemTheme.colors.text.disabled,
symbolColor = colors.disabledTextColor,
),
onValueChange = onValueChange,
colors = colors,
keyboardOptions = amountUM.amountTextField.keyboardOptions,
keyboardActions = amountUM.amountTextField.keyboardActions,
textStyle = TangemTheme.typography.head.copy(

View file

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

View file

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

View file

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

View file

@ -26,6 +26,7 @@ import coil.compose.AsyncImage
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
import com.tangem.core.ui.components.SpacerH
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.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe
@ -84,18 +85,20 @@ private fun OnrampHeaderTitle() {
private fun OnrampAmountField(amountField: AmountFieldModel, currencyCode: String) {
val decimalFormat = rememberDecimalFormat()
val requester = remember { FocusRequester() }
val colors = TangemAmountTextFieldColors
AmountTextField(
value = amountField.fiatValue,
decimals = amountField.fiatAmount.decimals,
colors = colors,
visualTransformation = AmountVisualTransformation(
decimals = amountField.fiatAmount.decimals,
symbol = currencyCode,
currencyCode = currencyCode,
decimalFormat = decimalFormat,
symbolColor = if (amountField.fiatValue.isBlank()) {
TangemTheme.colors.text.disabled
colors.disabledTextColor
} else {
TangemTheme.colors.text.primary1
colors.textColor
},
),
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.models.TopAppBarButtonUM
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.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe
@ -99,20 +100,22 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
text = "$5000",
)
} else {
val colors = TangemAmountTextFieldColors
AmountTextField(
value = state.amountFieldModel.value,
decimals = state.amountFieldModel.decimals,
onValueChange = state.amountFieldModel.onValueChange,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
colors = colors,
visualTransformation = AmountVisualTransformation(
decimals = state.amountFieldModel.decimals,
symbol = state.currencyCode,
currencyCode = state.currencyCode,
decimalFormat = rememberDecimalFormat(),
symbolColor = if (state.amountFieldModel.value.isBlank()) {
TangemTheme.colors.text.disabled
colors.disabledTextColor
} else {
TangemTheme.colors.text.primary1
colors.textColor
},
),
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.clickable
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.text.KeyboardOptions
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.unit.dp
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.ds.image.TangemIconUM
import com.tangem.core.ui.ds.topbar.TangemTopBar
@ -107,27 +111,32 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
radius = TangemTheme.dimens2.x25,
)
} else {
val colors = TangemAmountTextFieldColors.copy(
textColor = TangemTheme.colors3.text.primary,
disabledTextColor = TangemTheme.colors3.text.tertiary,
backgroundColor = TangemTheme.colors3.bg.secondary,
)
AmountTextField(
value = state.amountFieldModel.value,
decimals = state.amountFieldModel.decimals,
onValueChange = state.amountFieldModel.onValueChange,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
colors = colors,
visualTransformation = AmountVisualTransformation(
decimals = state.amountFieldModel.decimals,
symbol = state.currencyCode,
currencyCode = state.currencyCode,
decimalFormat = rememberDecimalFormat(),
symbolColor = if (state.amountFieldModel.value.isBlank()) {
TangemTheme.colors3.text.tertiary
colors.disabledTextColor
} else {
TangemTheme.colors3.text.primary
colors.textColor
},
),
textStyle = TangemTheme.typography3.display.medium.copy(
textAlign = TextAlign.Center,
),
isAutoResize = true,
backgroundColor = TangemTheme.colors3.bg.secondary,
)
}
}
@ -136,17 +145,13 @@ private fun AmountBlock(state: TangemPayCardLimitSetupUM, modifier: Modifier = M
@Composable
private fun PresetsRow(presets: ImmutableList<TangemPayCardLimitSetupUM.LimitPresetUM>) {
if (presets.isEmpty()) return
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = TangemTheme.dimens2.x3, vertical = 6.dp),
horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens2.x2),
LazyRow(
state = rememberLazyListState(),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
presets.forEach { preset ->
PresetChip(
preset = preset,
modifier = Modifier.weight(1f),
)
items(presets) { preset ->
PresetChip(preset = preset)
}
}
}
@ -164,9 +169,7 @@ private fun PresetChip(preset: TangemPayCardLimitSetupUM.LimitPresetUM, modifier
verticalAlignment = Alignment.CenterVertically,
) {
Text(
modifier = Modifier
.padding(vertical = 1.dp)
.fillMaxWidth(),
modifier = Modifier.padding(vertical = 1.dp),
text = preset.label,
style = TangemTheme.typography3.subheading.medium,
color = TangemTheme.colors3.text.primary,

View file

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