Skip to content

Commit

Permalink
Use transparent background for disabled TextField/TextArea (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosejr authored Oct 25, 2024
1 parent 3feee80 commit 8881269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ private fun readTextAreaStyle(metrics: TextFieldMetrics): TextAreaStyle {
val colors =
TextAreaColors(
background = normalBackground,
backgroundDisabled = retrieveColorOrUnspecified("TextArea.disabledBackground"),
backgroundDisabled = Color.Transparent,
backgroundFocused = normalBackground,
backgroundPressed = normalBackground,
backgroundHovered = normalBackground,
Expand Down Expand Up @@ -947,7 +947,7 @@ private fun readTextFieldStyle(): TextFieldStyle {
val colors =
TextFieldColors(
background = normalBackground,
backgroundDisabled = retrieveColorOrUnspecified("TextField.disabledBackground"),
backgroundDisabled = Color.Transparent,
backgroundFocused = normalBackground,
backgroundPressed = normalBackground,
backgroundHovered = normalBackground,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -123,16 +124,20 @@ private fun RowScope.ColumnOne() {
DefaultButton({}, enabled = false) { Text("Default") }
}

val state = rememberTextFieldState("")
TextField(
state = state,
modifier =
Modifier.width(200.dp).provideData {
set(ActionSystemTestAction.COMPONENT_DATA_KEY.name, "TextField")
lazy(ActionSystemTestAction.COMPONENT_DATA_KEY.name) { Math.random().toString() }
},
placeholder = { Text("Write something...") },
)
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
val state = rememberTextFieldState("")
TextField(
state = state,
modifier =
Modifier.width(200.dp).provideData {
set(ActionSystemTestAction.COMPONENT_DATA_KEY.name, "TextField")
lazy(ActionSystemTestAction.COMPONENT_DATA_KEY.name) { Math.random().toString() }
},
placeholder = { Text("Write something...") },
)

TextField(TextFieldState("Can't write here, I'm disabled"), enabled = false)
}

var checked by remember { mutableStateOf(false) }
var validated by remember { mutableStateOf(false) }
Expand Down

0 comments on commit 8881269

Please sign in to comment.