Can anyone advise on the wisdom of using `BasicTex...
# compose
c
Can anyone advise on the wisdom of using
BasicTextField
to simply show text, in addition to allowing it to be editable? That is, instead of doing this:
Copy code
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }

if (isEditing) {
  BasicTextField(...)
} else {
  Text(...)
}
You do this:
Copy code
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }

BasicTextField(
  ...
  value = text,
  enabled = isEditing,
  decorationBox = { innerTextField ->
    Surface(
      ...
      // A visual cue to show that the field is being edited
      border = if (isEditing) BorderStroke(...) else null
    ) {
      innerTextField()
    }
  }
)
đź§µ 2
c
What about using the
readOnly
parameter?
c
Hmm yes this seems to be the better option, thanks for the idea
Can I ask, is it preferable to put code blocks in the thread? Is that what the “thread” reaction means
c
Thank you!
👍 1