From 07c9cf223c25dc00a0bcc01f94c208c119358041 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 28 Oct 2026 09:40:07 +0100 Subject: [PATCH] Hide camera discard and send actions until there is captured media --- .../utun/chat/ui/screens/CameraRecordScreen.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/CameraRecordScreen.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/CameraRecordScreen.kt index cecbb511..332f5a2b 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/CameraRecordScreen.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/CameraRecordScreen.kt @@ -472,19 +472,22 @@ fun CameraRecordScreen(initialMode: CaptureMode, onSend: (String, CaptureMode) - else if (photoSize.first > 0) "${photoSize.first}×${photoSize.second}" else "" BoxWithConstraints(Modifier.fillMaxWidth().heightIn(min = 76.dp)) { val captureEnabled = camera != null && (idle || phase == CapturePhase.RECORDING || phase == CapturePhase.PAUSED) + val showDiscard = output != null && phase != CapturePhase.SENDING + val showSend = output != null && + (phase == CapturePhase.CAPTURED || phase == CapturePhase.RECORDING || phase == CapturePhase.PAUSED) val shutterSize = 76.dp val shutterWidth = if (captureEnabled) shutterSize else shutterSize / 2 val controlsWidth = 48.dp * 2 + 24.dp * 2 + shutterWidth val infoWidth = ((maxWidth - controlsWidth) / 2 - 8.dp).coerceIn(0.dp, 80.dp) - LaunchedEffect(captureEnabled, infoWidth) { - LogManager.addLog("DEBUG", "Capture", "Controls centered panel=$maxWidth shutterVisible=$captureEnabled " + - "centerSlot=$shutterWidth infoMaxWidth=$infoWidth") + LaunchedEffect(phase, captureEnabled, showDiscard, showSend, infoWidth) { + LogManager.addLog("DEBUG", "Capture", "Controls phase=$phase panel=$maxWidth shutterVisible=$captureEnabled " + + "discardVisible=$showDiscard sendVisible=$showSend centerSlot=$shutterWidth infoMaxWidth=$infoWidth") } Row(Modifier.align(Alignment.Center).heightIn(min = shutterSize), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(24.dp)) { - IconButton(onClick = { if (idle) onClose() else reset() }, enabled = phase != CapturePhase.SENDING) { + if (showDiscard) IconButton(onClick = { reset() }) { Icon(Icons.Default.Delete, stringResource(R.string.retake), tint = MaterialTheme.colorScheme.onSurface) - } + } else Spacer(Modifier.width(48.dp)) if (captureEnabled) FilledIconButton(modifier = Modifier.size(shutterSize), shape = CircleShape, onClick = { when (phase) { @@ -498,13 +501,12 @@ fun CameraRecordScreen(initialMode: CaptureMode, onSend: (String, CaptureMode) - Icons.Default.Pause else Icons.Default.Videocam, stringResource(if (mode == CaptureMode.PHOTO) R.string.take_photo else R.string.record_video), modifier = Modifier.size(36.dp)) } else Spacer(Modifier.width(shutterWidth)) - IconButton(enabled = phase == CapturePhase.CAPTURED || phase == CapturePhase.RECORDING || phase == CapturePhase.PAUSED, - onClick = { + if (showSend) IconButton(onClick = { if (phase == CapturePhase.CAPTURED) sendResult() else { pendingSend = true; phase = CapturePhase.FINALIZING; recording?.stop() } }) { Icon(Icons.AutoMirrored.Filled.Send, stringResource(R.string.send), tint = MaterialTheme.colorScheme.onSurface) - } + } else Spacer(Modifier.width(48.dp)) } if (info.isNotEmpty()) Text(info, color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 11.sp, lineHeight = 13.sp, maxLines = 2, textAlign = TextAlign.End,