Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-10 11:53:17 +05:00
parent 6d325ab008
commit 06fae63efa
3 changed files with 17 additions and 9 deletions

View file

@ -71,7 +71,18 @@ fun SimpleTextField(
}
}
var lastTextValue by remember(value) { mutableStateOf(value) }
var lastTextValue by remember(value) {
derivedStateOf {
val isSelectionLastIndex = textFieldValueState.selection.end == textFieldValueState.text.lastIndex
if (textFieldValueState.text.isBlank() || isSelectionLastIndex) {
textFieldValueState = textFieldValueState.copy(
text = value,
selection = getValueRange(value),
)
}
}
mutableStateOf(value)
}
CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) {
BasicTextField(
@ -82,9 +93,7 @@ fun SimpleTextField(
val stringChangedSinceLastInvocation = lastTextValue != newTextFieldValueState.text
lastTextValue = newTextFieldValueState.text
if (stringChangedSinceLastInvocation) {
onValueChange(newTextFieldValueState.text)
}
if (stringChangedSinceLastInvocation) onValueChange(newTextFieldValueState.text)
},
textStyle = textStyle.copy(color = color),
cursorBrush = SolidColor(TangemTheme.colors.text.primary1),