Repository: kiwicom/orbit-compose
Issue: Update TextFields to match Figma

- do not change background, keep it gray
- focus outline has a higher priority than error outline

Changed files:
ui/src/main/java/kiwi/orbit/compose/ui/controls/TextField.kt, ui/src/main/java/kiwi/orbit/compose/ui/controls/field/FieldContent.kt

diff --git a/ui/src/main/java/kiwi/orbit/compose/ui/controls/TextField.kt b/ui/src/main/java/kiwi/orbit/compose/ui/controls/TextField.kt
index a1b6b895..3711588f 100644
--- a/ui/src/main/java/kiwi/orbit/compose/ui/controls/TextField.kt
+++ b/ui/src/main/java/kiwi/orbit/compose/ui/controls/TextField.kt
@@ -129,17 +129,8 @@ public fun TextField(
             ) {
                 when (it) {
                     InputState.Normal -> Color.Transparent
-                    InputState.Focused -> OrbitTheme.colors.interactive.main
-                    InputState.NormalError, InputState.FocusedError -> OrbitTheme.colors.critical.main
-                }
-            }
-            val backgroundColor = transition.animateColor(
-                transitionSpec = { tween(durationMillis = AnimationDuration) },
-                label = "backgroundColor"
-            ) {
-                when (it) {
-                    InputState.Focused, InputState.FocusedError -> OrbitTheme.colors.surface.main
-                    else -> OrbitTheme.colors.surface.subtle
+                    InputState.Focused, InputState.FocusedError -> OrbitTheme.colors.interactive.main
+                    InputState.NormalError -> OrbitTheme.colors.critical.main
                 }
             }
 
@@ -154,7 +145,7 @@ public fun TextField(
                 modifier = Modifier
                     .then(autoBringIntoViewFocusModifier)
                     .border(1.dp, borderColor.value, OrbitTheme.shapes.normal)
-                    .background(backgroundColor.value, OrbitTheme.shapes.normal),
+                    .background(OrbitTheme.colors.surface.subtle, OrbitTheme.shapes.normal),
                 enabled = enabled,
                 readOnly = readOnly,
                 textStyle = mergedTextStyle,
diff --git a/ui/src/main/java/kiwi/orbit/compose/ui/controls/field/FieldContent.kt b/ui/src/main/java/kiwi/orbit/compose/ui/controls/field/FieldContent.kt
index 3ac914a5..6833a31b 100644
--- a/ui/src/main/java/kiwi/orbit/compose/ui/controls/field/FieldContent.kt
+++ b/ui/src/main/java/kiwi/orbit/compose/ui/controls/field/FieldContent.kt
@@ -42,10 +42,20 @@ internal fun FieldContent(
     Layout(
         content = {
             if (leadingIcon != null) {
-                FieldIcon(LeadingId, onLeadingIconClick, leadingIcon, Modifier.padding(start = FieldIconPadding))
+                FieldIcon(
+                    LeadingId,
+                    onLeadingIconClick,
+                    leadingIcon,
+                    Modifier.padding(start = FieldIconPadding)
+                )
             }
             if (trailingIcon != null) {
-                FieldIcon(TrailingId, onTrailingIconClick, trailingIcon, Modifier.padding(end = FieldIconPadding))
+                FieldIcon(
+                    TrailingId,
+                    onTrailingIconClick,
+                    trailingIcon,
+                    Modifier.padding(end = FieldIconPadding)
+                )
             }
 
             val padding = Modifier.padding(
@@ -54,14 +64,20 @@ internal fun FieldContent(
             )
 
             if (placeholder != null) {
-                Box(Modifier.layoutId(PlaceholderId).then(padding)) {
+                Box(
+                    Modifier
+                        .layoutId(PlaceholderId)
+                        .then(padding)
+                ) {
                     ProvideMergedTextStyle(OrbitTheme.typography.bodyNormal) {
                         ProvideContentEmphasis(ContentEmphasis.Subtle, content = placeholder)
                     }
                 }
             }
             Box(
-                Modifier.layoutId(FieldId).then(padding),
+                Modifier
+                    .layoutId(FieldId)
+                    .then(padding),
                 propagateMinConstraints = true,
             ) {
                 fieldContent()
@@ -98,9 +114,9 @@ private class FieldContentMeasurePolicy(
             )
         val fieldPlaceable = measurables.first { it.layoutId == FieldId }.measure(fieldConstraints)
 
-        // Placeholder
         val placeholderConstraints = fieldConstraints.copy(minWidth = 0)
-        val placeholderPlaceable = measurables.find { it.layoutId == PlaceholderId }?.measure(placeholderConstraints)
+        val placeholderPlaceable = measurables.find { it.layoutId == PlaceholderId }
+            ?.measure(placeholderConstraints)
 
         val width = calculateWidth(
             fieldWidth = fieldPlaceable.width,
@@ -119,15 +135,23 @@ private class FieldContentMeasurePolicy(
         )
 
         return layout(width, height) {
-            val verticalPaddingPadding = (FieldPadding.value * density).roundToInt()
+            val verticalPaddingPx = FieldPadding.roundToPx()
 
             leadingPlaceable?.placeRelative(
                 x = 0,
-                y = Alignment.CenterVertically.align(leadingPlaceable.height, height)
+                y = if (singleLine) {
+                    Alignment.CenterVertically.align(leadingPlaceable.height, height)
+                } else {
+                    verticalPaddingPx
+                },
             )
             trailingPlaceable?.placeRelative(
                 x = width - trailingPlaceable.width,
-                y = Alignment.CenterVertically.align(trailingPlaceable.height, height)
+                y = if (singleLine) {
+                    Alignment.CenterVertically.align(trailingPlaceable.height, height)
+                } else {
+                    verticalPaddingPx
+                },
             )
 
             // Single line text field without label places its input center vertically. Multiline text
@@ -135,7 +159,7 @@ private class FieldContentMeasurePolicy(
             val fieldVerticalPosition = if (singleLine) {
                 Alignment.CenterVertically.align(fieldPlaceable.height, height)
             } else {
-                verticalPaddingPadding
+                verticalPaddingPx
             }
             fieldPlaceable.placeRelative(
                 x = leadingPlaceable?.width ?: 0,
@@ -148,7 +172,7 @@ private class FieldContentMeasurePolicy(
                 val placeholderVerticalPosition = if (singleLine) {
                     Alignment.CenterVertically.align(placeholderPlaceable.height, height)
                 } else {
-                    verticalPaddingPadding
+                    verticalPaddingPx
                 }
                 placeholderPlaceable.placeRelative(
                     x = leadingPlaceable?.width ?: 0,