1package com.peachpasswords.ui.vault23import androidx.compose.foundation.clickable4import androidx.compose.foundation.background5import androidx.compose.foundation.layout.Box6import androidx.compose.foundation.layout.Column7import androidx.compose.foundation.layout.Row8import androidx.compose.foundation.layout.Spacer9import androidx.compose.foundation.layout.fillMaxWidth10import androidx.compose.foundation.layout.height11import androidx.compose.foundation.layout.padding12import androidx.compose.foundation.text.BasicTextField13import androidx.compose.foundation.shape.RoundedCornerShape14import androidx.compose.material3.Text15import androidx.compose.runtime.Composable16import androidx.compose.ui.Alignment17import androidx.compose.ui.Modifier18import androidx.compose.ui.draw.clip19import androidx.compose.ui.graphics.SolidColor20import androidx.compose.ui.text.TextStyle21import androidx.compose.ui.unit.dp22import androidx.compose.ui.unit.sp23import com.peachpasswords.ui.theme.LocalPeachAccent24import com.peachpasswords.ui.theme.PeachSpacing25import com.peachpasswords.ui.theme.PeachType26import com.peachpasswords.ui.theme.peachColors272829const val MAX_ADDITIONAL_URLS = 5303132@Composable33fun AdditionalUrlsEditor(34 urls: List<String>,35 onChange: (Int, String) -> Unit,36 onAdd: () -> Unit,37 onRemove: (Int) -> Unit,38) {39 val accent = LocalPeachAccent.current40 Column(Modifier.fillMaxWidth()) {41 urls.forEachIndexed { index, value ->42 Column(Modifier.fillMaxWidth()) {43 Row(44 Modifier.fillMaxWidth().padding(horizontal = PeachSpacing.lg, vertical = PeachSpacing.sm),45 verticalAlignment = Alignment.CenterVertically,46 ) {47 Column(Modifier.weight(1f)) {48 Text(49 "URL ${index + 2}",50 color = peachColors.T1,51 fontFamily = PeachType.Mono,52 fontSize = 8.sp,53 )54 Spacer(Modifier.height(4.dp))55 BasicTextField(56 value = value,57 onValueChange = { onChange(index, it) },58 singleLine = true,59 textStyle = TextStyle(60 color = peachColors.T0,61 fontFamily = PeachType.Mono,62 fontSize = 13.sp,63 ),64 cursorBrush = SolidColor(accent),65 modifier = Modifier.fillMaxWidth().padding(vertical = 6.dp),66 )67 }68 if (urls.size < MAX_ADDITIONAL_URLS) {69 Text(70 "+ add",71 color = accent,72 fontFamily = PeachType.Mono,73 fontSize = 11.sp,74 modifier = Modifier75 .clip(RoundedCornerShape(6.dp))76 .clickable(onClick = onAdd)77 .padding(horizontal = PeachSpacing.sm, vertical = 8.dp),78 )79 }80 Text(81 "×",82 color = peachColors.T2,83 fontFamily = PeachType.Mono,84 fontSize = 20.sp,85 modifier = Modifier86 .clip(RoundedCornerShape(6.dp))87 .clickable { onRemove(index) }88 .padding(start = PeachSpacing.sm, end = PeachSpacing.sm, top = 7.dp, bottom = 7.dp),89 )90 }91 if (index < urls.lastIndex) {92 Box(Modifier.fillMaxWidth().height(1.dp).background(peachColors.T3))93 }94 }95 }96 }97}