voice: played bars white, yellow cursor line on waveform
This commit is contained in:
1 parent
ee8167793c
commit
b8e15ad1f2
1 file changed
+16
-6
+16
-6
@@ -125,23 +125,33 @@ private fun VoiceBubble(message: Message, textColor: Color, onPlay: (String, ()
|
||||
Canvas(modifier = Modifier.weight(1f).height(28.dp)) {
|
||||
val barW = size.width / wfCount
|
||||
val ph = size.height
|
||||
val playedIdx = if (progress > 0f) (progress * wfCount).toInt() else 0
|
||||
val playedIdx = if (playing && progress > 0f) (progress * wfCount).toInt() else 0
|
||||
for (i in 0 until wfCount) {
|
||||
val level = wf[i].coerceIn(0f, 1f)
|
||||
val barH = (2f + level * (ph - 2f)).coerceAtMost(ph)
|
||||
val x = i.toFloat() * barW
|
||||
val y = ph - barH
|
||||
val played = i < playedIdx
|
||||
val played = playing && i < playedIdx
|
||||
drawRect(
|
||||
color = if (playing) {
|
||||
if (played) Color(0xFF3390EC) else Color(0xFF3390EC).copy(alpha = 0.35f)
|
||||
} else {
|
||||
Color(0xFFCCCCD4).copy(alpha = 0.8f)
|
||||
color = when {
|
||||
played -> Color.White
|
||||
playing -> Color(0xFFCCCCD4).copy(alpha = 0.8f)
|
||||
else -> Color(0xFFCCCCD4).copy(alpha = 0.8f)
|
||||
},
|
||||
topLeft = Offset(x, y),
|
||||
size = Size(barW * 0.75f, barH)
|
||||
)
|
||||
}
|
||||
/* yellow cursor line */
|
||||
if (playing && progress > 0f && progress < 1f) {
|
||||
val cursorX = progress * size.width
|
||||
drawLine(
|
||||
color = Color(0xFFFFD600),
|
||||
start = Offset(cursorX, 0f),
|
||||
end = Offset(cursorX, ph),
|
||||
strokeWidth = 2.5f
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user