Hide camera discard and send actions until there is captured media
This commit is contained in:
1 parent
f351f289af
commit
07c9cf223c
1 file changed
+10
-8
+10
-8
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user