123456789101112131415161718192021222324@OptIn(ExperimentalLayoutApi::class)25@Composable26private fun FeedbackBody(fg: Color, vm: SettingsViewModel) {27 val categories = listOf("Bug report", "Feature request", "Question", "Other")28 var category by remember { mutableStateOf(categories[0]) }29 var message by remember { mutableStateOf("") }30 val state by vm.feedbackState.collectAsState()3132 33 34 DisposableEffect(Unit) { onDispose { vm.resetFeedback() } }3536 if (state is FeedbackState.Sent) {37 Box(38 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp)).background(fg.copy(alpha = 0.08f))39 .border(1.dp, fg.copy(alpha = 0.32f), RoundedCornerShape(10.dp)).padding(16.dp),40 ) {41 Column {42 Text("Thank you", color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 18.sp)43 Text("Your note is in the queue. Someone will process it soon.", color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 12.sp, modifier = Modifier.padding(top = 4.dp))44 }45 }46 return47 }4849 val sending = state is FeedbackState.Sending5051 Text("Help us improve Peach. Every report goes directly to our inbox.", color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 12.sp, lineHeight = 17.sp)52 SubLabel("TYPE", fg)53 FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {54 categories.forEach { cat -> Pill(cat, category == cat, fg) { if (!sending) category = cat } }55 }56 SubLabel("MESSAGE", fg)57 Box(58 Modifier.fillMaxWidth().height(110.dp).clip(RoundedCornerShape(8.dp))59 .background(Color(0x2E000000)).border(1.dp, fg.copy(alpha = 0.22f), RoundedCornerShape(8.dp))60 .padding(10.dp),61 ) {62 if (message.isEmpty()) Text("Describe the issue or idea...", color = fg.copy(alpha = 0.42f), fontFamily = PeachType.Body, fontSize = 12.sp)63 BasicTextField(64 value = message, onValueChange = { message = it },65 enabled = !sending,66 textStyle = TextStyle(color = fg, fontFamily = PeachType.Body, fontSize = 12.sp),67 cursorBrush = SolidColor(fg), modifier = Modifier.fillMaxWidth(),68 )69 }70 Spacer(Modifier.height(8.dp))7172 Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {73 74 75 val canSend = !sending && message.isNotBlank()76 Box(77 Modifier.clip(RoundedCornerShape(8.dp))78 .border(1.dp, fg.copy(alpha = if (canSend) 0.28f else 0.14f), RoundedCornerShape(8.dp))79 .background(fg.copy(alpha = if (canSend) 0.08f else 0.04f))80 .clickable(enabled = canSend) { vm.sendFeedback(category, message) }81 .padding(horizontal = 12.dp, vertical = 6.dp),82 ) {83 Text(84 if (state is FeedbackState.Error) "Retry" else "Send",85 color = fg.copy(alpha = if (canSend) 1f else 0.4f),86 fontFamily = PeachType.Mono, fontSize = 11.sp,87 )88 }89 if (sending) {90 CircularProgressIndicator(91 color = LocalPeachAccent.current,92 strokeWidth = 2.dp,93 modifier = Modifier.size(16.dp),94 )95 }96 }9798 (state as? FeedbackState.Error)?.let { err ->99 Text(100 err.message,101 modifier = Modifier.padding(top = 8.dp),102 color = com.peachpasswords.ui.theme.PeachColors.Breach,103 fontFamily = PeachType.Mono,104 fontSize = 11.sp,105 lineHeight = 15.sp,106 )107 }108109 Hint("Sent anonymously · no account required", fg)110}