Display duration of recorded voice message (#1733)

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
jonnyandrew
2023-11-03 12:59:36 +00:00
committed by GitHub
parent 0e89080a50
commit 413ec4b5db
12 changed files with 119 additions and 40 deletions

View File

@@ -207,6 +207,7 @@ fun TextComposer(
VoiceMessagePreview(
isInteractive = !voiceMessageState.isSending,
isPlaying = voiceMessageState.isPlaying,
showCursor = voiceMessageState.showCursor,
waveform = voiceMessageState.waveform,
playbackProgress = voiceMessageState.playbackProgress,
time = voiceMessageState.time,
@@ -816,6 +817,7 @@ internal fun TextComposerVoicePreview() = ElementPreview {
voiceMessageState = VoiceMessageState.Preview(
isSending = false,
isPlaying = false,
showCursor = false,
waveform = createFakeWaveform(),
time = 0.seconds,
playbackProgress = 0.0f
@@ -826,6 +828,7 @@ internal fun TextComposerVoicePreview() = ElementPreview {
voiceMessageState = VoiceMessageState.Preview(
isSending = false,
isPlaying = true,
showCursor = true,
waveform = createFakeWaveform(),
time = 3.seconds,
playbackProgress = 0.2f
@@ -836,6 +839,7 @@ internal fun TextComposerVoicePreview() = ElementPreview {
voiceMessageState = VoiceMessageState.Preview(
isSending = true,
isPlaying = false,
showCursor = false,
waveform = createFakeWaveform(),
time = 61.seconds,
playbackProgress = 0.0f

View File

@@ -55,6 +55,7 @@ import kotlin.time.Duration.Companion.seconds
internal fun VoiceMessagePreview(
isInteractive: Boolean,
isPlaying: Boolean,
showCursor: Boolean,
waveform: ImmutableList<Float>,
time: Duration,
modifier: Modifier = Modifier,
@@ -105,7 +106,7 @@ internal fun VoiceMessagePreview(
.weight(1f)
.height(26.dp),
playbackProgress = playbackProgress,
showCursor = isInteractive,
showCursor = showCursor,
waveform = waveform,
seekEnabled = false, // TODO enable seeking
onSeek = onSeek,
@@ -162,8 +163,29 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
VoiceMessagePreview(isInteractive = true, isPlaying = true, time = 2.seconds, playbackProgress = 0.2f, waveform = createFakeWaveform())
VoiceMessagePreview(isInteractive = true, isPlaying = false, time = 0.seconds, playbackProgress = 0.0f, waveform = createFakeWaveform())
VoiceMessagePreview(isInteractive = false, isPlaying = false, time = 789.seconds, playbackProgress = 0.0f, waveform = createFakeWaveform())
VoiceMessagePreview(
isInteractive = true,
isPlaying = true,
time = 2.seconds,
playbackProgress = 0.2f,
showCursor = true,
waveform = createFakeWaveform()
)
VoiceMessagePreview(
isInteractive = true,
isPlaying = false,
time = 0.seconds,
playbackProgress = 0.0f,
showCursor = true,
waveform = createFakeWaveform()
)
VoiceMessagePreview(
isInteractive = false,
isPlaying = false,
time = 789.seconds,
playbackProgress = 0.0f,
showCursor = false,
waveform = createFakeWaveform()
)
}
}

View File

@@ -25,6 +25,7 @@ sealed class VoiceMessageState {
data class Preview(
val isSending: Boolean,
val isPlaying: Boolean,
val showCursor: Boolean,
val playbackProgress: Float,
val time: Duration,
val waveform: ImmutableList<Float>,