Skip to content

Commit

Permalink
Review: Use delegate properties in TextFieldsSample
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea authored and florentmaitre committed Jan 24, 2025
1 parent e90121a commit 83a771a
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ private fun Tabs(state: Int, onTabClick: (Int) -> Unit) {

@Composable
private fun TextFieldsSample(enabled: Boolean = true, isError: Boolean = false) {
val text: MutableState<String> = rememberSaveable { mutableStateOf("") }
val textForOutlined: MutableState<String> = rememberSaveable { mutableStateOf("") }
var text by rememberSaveable { mutableStateOf("") }
var textForOutlined by rememberSaveable { mutableStateOf("") }

val label: @Composable () -> Unit = { Text(text = "Label") }
val placeholder: @Composable () -> Unit = { Text(text = "Placeholder") }
Expand All @@ -864,8 +864,8 @@ private fun TextFieldsSample(enabled: Boolean = true, isError: Boolean = false)

TextField(
modifier = Modifier.fillMaxWidth(),
value = text.value,
onValueChange = { text.value = it },
value = text,
onValueChange = { text = it },
label = label,
placeholder = placeholder,
leadingIcon = icon,
Expand All @@ -876,8 +876,8 @@ private fun TextFieldsSample(enabled: Boolean = true, isError: Boolean = false)

OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = textForOutlined.value,
onValueChange = { textForOutlined.value = it },
value = textForOutlined,
onValueChange = { textForOutlined = it },
label = label,
placeholder = placeholder,
trailingIcon = icon,
Expand Down

0 comments on commit 83a771a

Please sign in to comment.