1package com.peachpasswords.ui.vault23import androidx.compose.foundation.background4import androidx.compose.foundation.border5import androidx.compose.foundation.layout.Box6import androidx.compose.foundation.layout.Column7import androidx.compose.foundation.layout.Spacer8import androidx.compose.foundation.layout.fillMaxWidth9import androidx.compose.foundation.layout.height10import androidx.compose.foundation.layout.heightIn11import androidx.compose.foundation.layout.padding12import androidx.compose.foundation.shape.RoundedCornerShape13import androidx.compose.foundation.text.BasicTextField14import androidx.compose.material3.DropdownMenu15import androidx.compose.material3.DropdownMenuItem16import androidx.compose.material3.Text17import androidx.compose.runtime.Composable18import androidx.compose.runtime.getValue19import androidx.compose.runtime.mutableStateOf20import androidx.compose.runtime.remember21import androidx.compose.runtime.setValue22import androidx.compose.ui.Modifier23import androidx.compose.ui.draw.clip24import androidx.compose.ui.focus.onFocusChanged25import androidx.compose.ui.graphics.SolidColor26import androidx.compose.ui.text.TextStyle27import androidx.compose.ui.unit.dp28import androidx.compose.ui.unit.sp29import androidx.compose.ui.window.PopupProperties30import com.peachpasswords.ui.theme.LocalPeachAccent31import com.peachpasswords.ui.theme.peachColors32import com.peachpasswords.ui.theme.PeachType33343536373839404142434445464748@Composable49fun IdentitySuggestDropdown(50 expanded: Boolean,51 suggestions: List<String>,52 onPick: (String) -> Unit,53 onDismiss: () -> Unit,54) {55 DropdownMenu(56 expanded = expanded && suggestions.isNotEmpty(),57 onDismissRequest = onDismiss,58 properties = PopupProperties(focusable = false),59 modifier = Modifier60 .heightIn(max = 240.dp)61 .background(peachColors.S2)62 .border(1.dp, peachColors.T3, RoundedCornerShape(10.dp))63 .clip(RoundedCornerShape(10.dp)),64 ) {65 suggestions.forEach { suggestion ->66 DropdownMenuItem(67 text = {68 Text(69 suggestion,70 style = TextStyle(71 color = peachColors.T1,72 fontFamily = PeachType.Mono,73 fontSize = 11.sp,74 ),75 )76 },77 onClick = { onPick(suggestion) },78 modifier = Modifier.fillMaxWidth(),79 )80 }81 }82}838485868788899091929394959697@Composable98fun IdentitySuggestField(99 label: String,100 value: String,101 suggestions: List<String>,102 onChange: (String) -> Unit,103 joined: Boolean = false,104 divider: Boolean = false,105) {106 val accent = LocalPeachAccent.current107 var focused by remember { mutableStateOf(false) }108109 Column(110 Modifier.fillMaxWidth()111 .then(if (joined) Modifier else Modifier.padding(bottom = 14.dp))112 .then(113 if (joined) Modifier.padding(horizontal = 18.dp, vertical = 14.dp)114 else Modifier.border(1.dp, peachColors.T3, RoundedCornerShape(16.dp)).padding(horizontal = 18.dp, vertical = 14.dp),115 ),116 ) {117 Text(label.uppercase(), color = peachColors.T2, fontFamily = PeachType.Mono, fontSize = 9.sp)118 Spacer(Modifier.height(6.dp))119 Box(Modifier.fillMaxWidth()) {120 BasicTextField(121 value = value,122 onValueChange = onChange,123 singleLine = true,124 textStyle = TextStyle(color = peachColors.T0, fontFamily = PeachType.Mono, fontSize = 13.sp),125 cursorBrush = SolidColor(accent),126 modifier = Modifier127 .fillMaxWidth()128 .onFocusChanged { focused = it.isFocused },129 )130 }131 IdentitySuggestDropdown(132 expanded = focused,133 suggestions = suggestions.filter { it != value },134 onPick = { picked ->135 onChange(picked)136 focused = false137 },138 onDismiss = { focused = false },139 )140 }141 if (joined && divider) Box(Modifier.fillMaxWidth().height(1.dp).background(peachColors.T3))142}