Fix cursor position in converter

This commit is contained in:
Sad Ellie 2023-09-19 09:45:05 +03:00
parent 0bb260e921
commit 06c9224cbb

View File

@ -63,7 +63,11 @@ internal class ConverterViewModel @Inject constructor(
) : ViewModel() {
private val converterInputKey = "CONVERTER_INPUT"
private val _input = MutableStateFlow(TextFieldValue(savedStateHandle[converterInputKey] ?: ""))
private val _input = MutableStateFlow(
with(savedStateHandle[converterInputKey] ?: "") {
TextFieldValue(this, TextRange(this.length))
}
)
private val _calculation = MutableStateFlow<BigDecimal?>(null)
private val _result = MutableStateFlow<ConverterResult>(ConverterResult.Loading)
private val _unitFrom = MutableStateFlow<AbstractUnit?>(null)