I'm using an OutlinedTextField for the user to input a dollar amount. It works as desired but I would like to add a $ in front of what they are inputting, whether it's one digit or five.
val patternPool: Regex = Regex("^\\d{1,5}\$")
OutlinedTextField(
value = siteValues.valueExtraMoney.value,
onValueChange = { if (it.isEmpty() || it.matches(sitePatterns.patternPool)) siteValues.valueExtraMoney.value = it },
modifier = Modifier
.weight(1f)
.fillMaxHeight(),
textStyle = TextStyle(fontSize = fonts.fontSizeText, textAlign = TextAlign.Center),
label = {
Text(
text ="Extra money taken out of prize pool",
modifier = Modifier.fillMaxWidth(),
fontSize = fonts.fontSizeEntry,
textAlign = TextAlign.Center
)
},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
shape = RectangleShape,
colors = TextFieldDefaults.outlinedTextFieldColors(textColor = Color.Black)
)
I've tried valueExtraMoney.value = "$$it". That outputs a $ plus what ever digit is inputed. But now the string doesn't satisfy the regex and I can't alter the input anymore. I tried playing with the regex to allow a $ but it still gets frozen.