TP-40997 | Implementation of moving cursor to end in case of ifsc sel… (#176)
This commit is contained in:
@@ -17,6 +17,7 @@ import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.layout.layoutId
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.*
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -75,18 +76,23 @@ class CustomTextFieldRenderer(
|
||||
customTextFieldData =
|
||||
customTextFieldData?.copyNonNull(dataState.value) ?: dataState.value
|
||||
}
|
||||
val isTextTransformedValueUpdated = remember {
|
||||
val isTextTransformedValueEdited = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
var cursorSelection by remember { mutableStateOf(TextRange.Zero) }
|
||||
|
||||
var inputValue by remember(customTextFieldData?.inputText) {
|
||||
if (isTextTransformedValueEdited.value.not()) {
|
||||
cursorSelection = TextRange(customTextFieldData?.inputText.orEmpty().length)
|
||||
}
|
||||
val input = onInputValueChange(
|
||||
input = customTextFieldData?.inputText.orEmpty(),
|
||||
property = property,
|
||||
customTextFieldData = customTextFieldData,
|
||||
uiTronViewModel = uiTronViewModel,
|
||||
isTextTransformedValueUpdated = isTextTransformedValueUpdated
|
||||
isTextTransformedValueUpdated = isTextTransformedValueEdited
|
||||
)
|
||||
mutableStateOf(input)
|
||||
mutableStateOf(TextFieldValue(text = input, selection = cursorSelection))
|
||||
}
|
||||
var isFocused by remember {
|
||||
mutableStateOf(false)
|
||||
@@ -200,14 +206,17 @@ class CustomTextFieldRenderer(
|
||||
value = inputValue,
|
||||
onValueChange = { input ->
|
||||
val editedInput = onInputValueChange(
|
||||
input = input,
|
||||
input = input.text,
|
||||
property = property,
|
||||
customTextFieldData = customTextFieldData,
|
||||
uiTronViewModel = uiTronViewModel,
|
||||
isTextTransformedValueUpdated = mutableStateOf(false)
|
||||
)
|
||||
isTextTransformedValueUpdated.value = true
|
||||
inputValue = editedInput
|
||||
if (input.text != inputValue.text) {
|
||||
isTextTransformedValueEdited.value = true
|
||||
}
|
||||
cursorSelection = TextRange(input.selection.start)
|
||||
inputValue = TextFieldValue(text = editedInput, selection = cursorSelection)
|
||||
},
|
||||
singleLine = property.singleLine ?: false,
|
||||
visualTransformation = property.visualTransformation?.getVisualTransformation()
|
||||
@@ -217,7 +226,7 @@ class CustomTextFieldRenderer(
|
||||
property.cursorColor?.hexToComposeColor ?: Color.Gray
|
||||
)
|
||||
)
|
||||
if (inputValue.isEmpty()) {
|
||||
if (inputValue.text.isEmpty()) {
|
||||
property.hintStyle?.let {
|
||||
TextRenderer().Render(
|
||||
property = it,
|
||||
@@ -245,7 +254,7 @@ class CustomTextFieldRenderer(
|
||||
}
|
||||
uiTronViewModel.handle[property.errorMessageLayoutId.getDataId()] =
|
||||
TextData(customTextFieldData.errorMessage)
|
||||
} else if (inputValue.isNotNullAndNotEmpty()) {
|
||||
} else if (inputValue.text.isNotNullAndNotEmpty()) {
|
||||
if (isFocused) {
|
||||
borderColor = property.colors?.focusedBorderColor
|
||||
} else {
|
||||
@@ -253,7 +262,7 @@ class CustomTextFieldRenderer(
|
||||
}
|
||||
val successText = getTransformedText(
|
||||
property.successTextTransformation,
|
||||
inputValue
|
||||
inputValue.text
|
||||
)
|
||||
if (successText.isNotNullAndNotEmpty()) {
|
||||
property.successView?.let {
|
||||
@@ -320,6 +329,10 @@ class CustomTextFieldRenderer(
|
||||
uiTronViewModel.handleActions(customTextFieldData?.onValueChangeAction)
|
||||
}
|
||||
}
|
||||
if (property.isDataMutable.orFalse()) {
|
||||
uiTronViewModel.handle[property.layoutId.getDataId()] =
|
||||
customTextFieldData?.copy(inputText = inputValue)
|
||||
}
|
||||
uiTronViewModel.handleActions(customTextFieldData?.onInputValueChangeAction)
|
||||
}
|
||||
return inputValue
|
||||
|
||||
Reference in New Issue
Block a user