Add time to voice message composer UI (#1720)
--------- Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
parent
b7e6375ac3
commit
3e58e03a10
10 changed files with 50 additions and 23 deletions
|
|
@ -85,7 +85,6 @@ import io.element.android.wysiwyg.compose.RichTextEditor
|
|||
import io.element.android.wysiwyg.compose.RichTextEditorState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import uniffi.wysiwyg_composer.MenuAction
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
|
|
@ -211,6 +210,7 @@ fun TextComposer(
|
|||
isPlaying = voiceMessageState.isPlaying,
|
||||
waveform = voiceMessageState.waveform,
|
||||
playbackProgress = voiceMessageState.playbackProgress,
|
||||
time = voiceMessageState.time,
|
||||
onPlayClick = onPlayVoiceMessageClicked,
|
||||
onPauseClick = onPauseVoiceMessageClicked,
|
||||
onSeek = onSeekVoiceMessage,
|
||||
|
|
@ -816,13 +816,14 @@ internal fun TextComposerVoicePreview() = ElementPreview {
|
|||
enableVoiceMessages = true,
|
||||
)
|
||||
PreviewColumn(items = persistentListOf({
|
||||
VoicePreview(voiceMessageState = VoiceMessageState.Recording(61.seconds, List(100) { it.toFloat() / 100 }.toPersistentList()))
|
||||
VoicePreview(voiceMessageState = VoiceMessageState.Recording(61.seconds, createFakeWaveform()))
|
||||
}, {
|
||||
VoicePreview(
|
||||
voiceMessageState = VoiceMessageState.Preview(
|
||||
isSending = false,
|
||||
isPlaying = false,
|
||||
waveform = createFakeWaveform(),
|
||||
time = 0.seconds,
|
||||
playbackProgress = 0.0f
|
||||
)
|
||||
)
|
||||
|
|
@ -832,6 +833,7 @@ internal fun TextComposerVoicePreview() = ElementPreview {
|
|||
isSending = false,
|
||||
isPlaying = true,
|
||||
waveform = createFakeWaveform(),
|
||||
time = 3.seconds,
|
||||
playbackProgress = 0.2f
|
||||
)
|
||||
)
|
||||
|
|
@ -841,6 +843,7 @@ internal fun TextComposerVoicePreview() = ElementPreview {
|
|||
isSending = true,
|
||||
isPlaying = false,
|
||||
waveform = createFakeWaveform(),
|
||||
time = 61.seconds,
|
||||
playbackProgress = 0.0f
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.libraries.designsystem.components.media.WaveformPlaybackView
|
||||
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
|
||||
|
|
@ -42,16 +43,21 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
|||
import io.element.android.libraries.designsystem.text.applyScaleUp
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.textcomposer.R
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import io.element.android.libraries.ui.utils.time.formatShort
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@Composable
|
||||
internal fun VoiceMessagePreview(
|
||||
isInteractive: Boolean,
|
||||
isPlaying: Boolean,
|
||||
waveform: ImmutableList<Float>,
|
||||
time: Duration,
|
||||
modifier: Modifier = Modifier,
|
||||
playbackProgress: Float = 0f,
|
||||
onPlayClick: () -> Unit = {},
|
||||
|
|
@ -85,7 +91,13 @@ internal fun VoiceMessagePreview(
|
|||
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
// TODO Add timer UI
|
||||
Text(
|
||||
text = time.formatShort(),
|
||||
color = ElementTheme.materialColors.secondary,
|
||||
style = ElementTheme.typography.fontBodySmMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
|
||||
|
|
@ -151,8 +163,8 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
|||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
VoiceMessagePreview(isInteractive = true, isPlaying = true, waveform = createFakeWaveform())
|
||||
VoiceMessagePreview(isInteractive = true, isPlaying = false, waveform = createFakeWaveform())
|
||||
VoiceMessagePreview(isInteractive = false, isPlaying = false, waveform = createFakeWaveform())
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ sealed class VoiceMessageState {
|
|||
val isSending: Boolean,
|
||||
val isPlaying: Boolean,
|
||||
val playbackProgress: Float,
|
||||
val time: Duration,
|
||||
val waveform: ImmutableList<Float>,
|
||||
): VoiceMessageState()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue