Browse Source

voice: fix waveform — pointerInput on Box, cursor + white bars stay on pause

- Canvas pointerInput moved to wrapping Box (state updates trigger recomposition)
- showCursor = playing || paused (cursor and white bars visible on pause)
- elapsed/dur stays visible on pause too
topo_upd
evgeny 2 months ago
parent
commit
2e8aa89397
  1. 9
      tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt

9
tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt

@ -129,7 +129,8 @@ private fun VoiceBubble(message: Message, textColor: Color,
/* Waveform with seek on tap */
if (wfCount >= 2) {
Canvas(modifier = Modifier.weight(1f).height(28.dp)
Box(
modifier = Modifier.weight(1f).height(28.dp)
.pointerInput(message.filePath) {
detectTapGestures { offset ->
if (message.filePath.isEmpty()) return@detectTapGestures
@ -140,9 +141,10 @@ private fun VoiceBubble(message: Message, textColor: Color,
}
}
) {
Canvas(modifier = Modifier.fillMaxSize()) {
val barW = size.width / wfCount
val ph = size.height
val showCursor = playing && !paused
val showCursor = playing || paused
val playedIdx = if (showCursor && progress > 0f) (progress * wfCount).toInt() else 0
for (i in 0 until wfCount) {
val level = wf[i].coerceIn(0f, 1f)
@ -163,6 +165,7 @@ private fun VoiceBubble(message: Message, textColor: Color,
}
}
}
}
Spacer(Modifier.height(4.dp))
@ -173,7 +176,7 @@ private fun VoiceBubble(message: Message, textColor: Color,
verticalAlignment = Alignment.Bottom
) {
Text(
if (playing && !paused) "${formatDurationMs(elapsedMs)} / ${formatDurationMs(durMs)}"
if (playing || paused) "${formatDurationMs(elapsedMs)} / ${formatDurationMs(durMs)}"
else formatDurationMs(durMs),
fontSize = 12.sp,
color = textColor.copy(alpha = 0.55f)

Loading…
Cancel
Save