package com.peachpasswords.ui.vault import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box 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.shape.RoundedCornerShape import androidx.compose.foundation.text.BasicTextField import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.peachpasswords.ui.theme.LocalPeachAccent import com.peachpasswords.ui.theme.PeachColors import com.peachpasswords.ui.theme.PeachType /** E3 — hard cap on additional URLs, matching the spec. */ const val MAX_ADDITIONAL_URLS = 5 /** * E3 — editor block for the additional-URLs list. Self-contained (mirrors the * underline `Field` style in EntryEditScreen) so it drops into the login branch * below the main `url` field without depending on the screen's private `Field`. * * Each row is an underlined input labeled "URL N" with an "×" remove control. * A ghost "+ add URL" affordance appends an empty entry; it disappears at the * cap and is replaced by the limit hint. */ @Composable fun AdditionalUrlsEditor( urls: List, onChange: (Int, String) -> Unit, onAdd: () -> Unit, onRemove: (Int) -> Unit, ) { val accent = LocalPeachAccent.current Column(Modifier.fillMaxWidth()) { urls.forEachIndexed { index, value -> // Label numbering starts at 2 so it reads as a continuation of the // primary URL field (which is conceptually "URL 1"). Column(Modifier.fillMaxWidth().padding(bottom = 14.dp)) { Text( "URL ${index + 2}", color = PeachColors.T1, fontFamily = PeachType.Mono, fontSize = 8.sp, ) Spacer(Modifier.height(6.dp)) Row(verticalAlignment = Alignment.CenterVertically) { Box( Modifier.weight(1f) .border(1.dp, PeachColors.T3, RoundedCornerShape(10.dp)) .padding(horizontal = 12.dp, vertical = 12.dp), ) { BasicTextField( value = value, onValueChange = { onChange(index, it) }, singleLine = true, textStyle = TextStyle( color = PeachColors.T0, fontFamily = PeachType.Mono, fontSize = 13.sp, ), cursorBrush = SolidColor(accent), modifier = Modifier.fillMaxWidth(), ) } Spacer(Modifier.width(8.dp)) Text( "×", color = PeachColors.T2, fontFamily = PeachType.Mono, fontSize = 16.sp, modifier = Modifier .clip(RoundedCornerShape(6.dp)) .clickable { onRemove(index) } .padding(horizontal = 8.dp, vertical = 4.dp), ) } } } if (urls.size < MAX_ADDITIONAL_URLS) { Text( "+ add URL", color = accent, fontFamily = PeachType.Mono, fontSize = 11.sp, modifier = Modifier .clip(RoundedCornerShape(6.dp)) .clickable(onClick = onAdd) .padding(vertical = 4.dp), ) Spacer(Modifier.height(14.dp)) } else { Text( "Max $MAX_ADDITIONAL_URLS additional URLs", color = PeachColors.T2, fontFamily = PeachType.Mono, fontSize = 9.sp, ) Spacer(Modifier.height(14.dp)) } } }