package com.peachpasswords.ui.vault import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.collectIsFocusedAsState import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp import com.peachpasswords.ui.theme.LocalPeachAccent import com.peachpasswords.ui.theme.peachColors import com.peachpasswords.ui.theme.PeachType /** * The Peach text field used across the entry-edit screens: a bare underline (no * border box), drawn in t3 and lit to the accent while focused — matching the * lock screen's credential inputs. Label is IBM Plex Mono 9sp, uppercase, t2, * with 0.08em tracking. * * Replaces the old boxed `Field`/`CardField` primitives so every new-entry input * shares one underline style (brief Fix 6). */ @Composable fun PeachField( label: String, value: String, onChange: (String) -> Unit, modifier: Modifier = Modifier, singleLine: Boolean = true, mono: Boolean = true, keyboardType: KeyboardType = KeyboardType.Text, visualTransformation: VisualTransformation = VisualTransformation.None, labelTrailing: (@Composable () -> Unit)? = null, trailing: (@Composable () -> Unit)? = null, ) { val accent = LocalPeachAccent.current val interaction = remember { MutableInteractionSource() } val focused by interaction.collectIsFocusedAsState() val hairline = peachColors.T3 Column(modifier.fillMaxWidth().padding(bottom = 14.dp)) { Row(verticalAlignment = Alignment.CenterVertically) { Text( label.uppercase(), color = peachColors.T2, fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.08.em, ) if (labelTrailing != null) { Spacer(Modifier.width(8.dp)) labelTrailing() } } Spacer(Modifier.height(6.dp)) Row(verticalAlignment = Alignment.CenterVertically) { BasicTextField( value = value, onValueChange = onChange, singleLine = singleLine, textStyle = TextStyle( color = peachColors.T0, fontFamily = if (mono) PeachType.Mono else PeachType.Body, fontSize = 13.sp, ), cursorBrush = SolidColor(accent), interactionSource = interaction, keyboardOptions = KeyboardOptions(keyboardType = keyboardType), visualTransformation = visualTransformation, modifier = Modifier .weight(1f) .drawBehind { drawRect( color = if (focused) accent else hairline, topLeft = Offset(0f, size.height - 1.dp.toPx()), size = Size(size.width, 1.dp.toPx()), ) } .padding(vertical = 8.dp), ) if (trailing != null) { Spacer(Modifier.width(8.dp)) trailing() } } } }