1package com.peachpasswords.ui.components23import androidx.compose.foundation.interaction.MutableInteractionSource4import androidx.compose.foundation.interaction.collectIsFocusedAsState5import androidx.compose.foundation.layout.Column6import androidx.compose.foundation.layout.Row7import androidx.compose.foundation.layout.Spacer8import androidx.compose.foundation.layout.fillMaxWidth9import androidx.compose.foundation.layout.padding10import androidx.compose.foundation.layout.width11import androidx.compose.foundation.text.BasicTextField12import androidx.compose.foundation.text.KeyboardOptions13import androidx.compose.material3.Text14import androidx.compose.runtime.Composable15import androidx.compose.runtime.getValue16import androidx.compose.runtime.remember17import androidx.compose.ui.Alignment18import androidx.compose.ui.Modifier19import androidx.compose.ui.draw.drawBehind20import androidx.compose.ui.geometry.Offset21import androidx.compose.ui.geometry.Size22import androidx.compose.ui.graphics.SolidColor23import androidx.compose.ui.text.TextStyle24import androidx.compose.ui.text.input.KeyboardType25import androidx.compose.ui.text.input.VisualTransformation26import androidx.compose.ui.unit.dp27import androidx.compose.ui.unit.em28import androidx.compose.ui.unit.sp29import com.peachpasswords.ui.theme.LocalPeachAccent30import com.peachpasswords.ui.theme.PeachSpacing31import com.peachpasswords.ui.theme.PeachType32import com.peachpasswords.ui.theme.peachColors3334@Composable35fun PeachField(36 label: String,37 value: String,38 onValueChange: (String) -> Unit,39 modifier: Modifier = Modifier,40 singleLine: Boolean = true,41 mono: Boolean = true,42 keyboardType: KeyboardType = KeyboardType.Text,43 visualTransformation: VisualTransformation = VisualTransformation.None,44 trailing: (@Composable () -> Unit)? = null,45) {46 val accent = LocalPeachAccent.current47 val interaction = remember { MutableInteractionSource() }48 val focused by interaction.collectIsFocusedAsState()49 val hairline = peachColors.T35051 Column(modifier.fillMaxWidth()) {52 Text(53 label.uppercase(),54 color = peachColors.T2,55 fontFamily = PeachType.Mono,56 fontSize = 9.sp,57 letterSpacing = 0.08.em,58 )59 Row(verticalAlignment = Alignment.CenterVertically) {60 BasicTextField(61 value = value,62 onValueChange = onValueChange,63 singleLine = singleLine,64 textStyle = TextStyle(65 color = peachColors.T0,66 fontFamily = if (mono) PeachType.Mono else PeachType.Body,67 fontSize = 13.sp,68 ),69 cursorBrush = SolidColor(accent),70 interactionSource = interaction,71 keyboardOptions = KeyboardOptions(keyboardType = keyboardType),72 visualTransformation = visualTransformation,73 modifier = Modifier74 .weight(1f)75 .drawBehind {76 drawRect(77 color = if (focused) accent else hairline,78 topLeft = Offset(0f, size.height - 1.dp.toPx()),79 size = Size(size.width, 1.dp.toPx()),80 )81 }82 .padding(vertical = PeachSpacing.sm),83 )84 if (trailing != null) {85 Spacer(Modifier.width(PeachSpacing.sm))86 trailing()87 }88 }89 }90}