Код: Выделить всё
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FormTextFieldComponent(
topText: String,
initialText: String=""
) = Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
// Small Text at the top (dynamic content)
var textState by remember { mutableStateOf(TextFieldValue(initialText)) }
OutlinedTextField(
value = textState,
onValueChange = {
textState = it
},
label = { Text(topText) }
)
}
Код: Выделить всё
FormTextFieldComponent("First Name", "Van")
Spacer(modifier = Modifier.height(1.dp))
FormTextFieldComponent("Last Name", "Chen")
Spacer(modifier = Modifier.height(1.dp))
Подробнее здесь: https://stackoverflow.com/questions/773 ... -only-once