Let the preview provider use stable data. I do not get why the generated screenshot was always similar.
This commit is contained in:
parent
93ae7941a4
commit
90cd52b5d5
4 changed files with 32 additions and 20 deletions
|
|
@ -9,7 +9,6 @@ package io.element.android.features.messages.api.timeline.voicemessages.composer
|
||||||
|
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
import io.element.android.libraries.designsystem.components.media.WaveFormSamples
|
import io.element.android.libraries.designsystem.components.media.WaveFormSamples
|
||||||
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
|
|
||||||
import io.element.android.libraries.textcomposer.model.VoiceMessageState
|
import io.element.android.libraries.textcomposer.model.VoiceMessageState
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
|
|
@ -39,5 +38,5 @@ fun aVoiceMessagePreviewState() = VoiceMessageState.Preview(
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
playbackProgress = 0f,
|
playbackProgress = 0f,
|
||||||
time = 10.seconds,
|
time = 10.seconds,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ package io.element.android.libraries.designsystem.components.media
|
||||||
|
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
|
|
||||||
object WaveFormSamples {
|
object WaveFormSamples {
|
||||||
val allRangeWaveForm = List(100) { it.toFloat() / 100 }.toImmutableList()
|
val allRangeWaveForm = List(100) { it.toFloat() / 100 }.toImmutableList()
|
||||||
|
|
@ -23,4 +24,6 @@ object WaveFormSamples {
|
||||||
1.000f, 0.334f, 0.321f, 0.011f, 0.000f,
|
1.000f, 0.334f, 0.321f, 0.011f, 0.000f,
|
||||||
0.000f, 0.003f,
|
0.000f, 0.003f,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val longRealisticWaveForm = List(4) { realisticWaveForm }.flatten().toPersistentList()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
import io.element.android.libraries.androidutils.ui.showKeyboard
|
import io.element.android.libraries.androidutils.ui.showKeyboard
|
||||||
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
|
import io.element.android.libraries.designsystem.components.media.WaveFormSamples
|
||||||
import io.element.android.libraries.designsystem.preview.DAY_MODE_NAME
|
import io.element.android.libraries.designsystem.preview.DAY_MODE_NAME
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.NIGHT_MODE_NAME
|
import io.element.android.libraries.designsystem.preview.NIGHT_MODE_NAME
|
||||||
|
|
@ -808,30 +808,33 @@ internal fun TextComposerCaptionPreview() = ElementPreview {
|
||||||
internal fun TextComposerVoicePreview() = ElementPreview {
|
internal fun TextComposerVoicePreview() = ElementPreview {
|
||||||
PreviewColumn(
|
PreviewColumn(
|
||||||
items = persistentListOf(
|
items = persistentListOf(
|
||||||
VoiceMessageState.Recording(61.seconds, createFakeWaveform()),
|
VoiceMessageState.Recording(
|
||||||
|
duration = 61.seconds,
|
||||||
|
levels = WaveFormSamples.realisticWaveForm,
|
||||||
|
),
|
||||||
VoiceMessageState.Preview(
|
VoiceMessageState.Preview(
|
||||||
isSending = false,
|
isSending = false,
|
||||||
isPlaying = false,
|
isPlaying = false,
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 0.seconds,
|
time = 0.seconds,
|
||||||
playbackProgress = 0.0f
|
playbackProgress = 0.0f,
|
||||||
),
|
),
|
||||||
VoiceMessageState.Preview(
|
VoiceMessageState.Preview(
|
||||||
isSending = false,
|
isSending = false,
|
||||||
isPlaying = true,
|
isPlaying = true,
|
||||||
showCursor = true,
|
showCursor = true,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 3.seconds,
|
time = 3.seconds,
|
||||||
playbackProgress = 0.2f
|
playbackProgress = 0.2f,
|
||||||
),
|
),
|
||||||
VoiceMessageState.Preview(
|
VoiceMessageState.Preview(
|
||||||
isSending = true,
|
isSending = true,
|
||||||
isPlaying = false,
|
isPlaying = false,
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 61.seconds,
|
time = 61.seconds,
|
||||||
playbackProgress = 0.0f
|
playbackProgress = 0.0f,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
) { voiceMessageState ->
|
) { voiceMessageState ->
|
||||||
|
|
@ -848,12 +851,15 @@ internal fun TextComposerVoicePreview() = ElementPreview {
|
||||||
internal fun TextComposerVoiceNotEncryptedPreview() = ElementPreview {
|
internal fun TextComposerVoiceNotEncryptedPreview() = ElementPreview {
|
||||||
PreviewColumn(
|
PreviewColumn(
|
||||||
items = persistentListOf(
|
items = persistentListOf(
|
||||||
VoiceMessageState.Recording(61.seconds, createFakeWaveform()),
|
VoiceMessageState.Recording(
|
||||||
|
duration = 61.seconds,
|
||||||
|
levels = WaveFormSamples.realisticWaveForm,
|
||||||
|
),
|
||||||
VoiceMessageState.Preview(
|
VoiceMessageState.Preview(
|
||||||
isSending = false,
|
isSending = false,
|
||||||
isPlaying = false,
|
isPlaying = false,
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 0.seconds,
|
time = 0.seconds,
|
||||||
playbackProgress = 0.0f
|
playbackProgress = 0.0f
|
||||||
),
|
),
|
||||||
|
|
@ -861,7 +867,7 @@ internal fun TextComposerVoiceNotEncryptedPreview() = ElementPreview {
|
||||||
isSending = false,
|
isSending = false,
|
||||||
isPlaying = true,
|
isPlaying = true,
|
||||||
showCursor = true,
|
showCursor = true,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 3.seconds,
|
time = 3.seconds,
|
||||||
playbackProgress = 0.2f
|
playbackProgress = 0.2f
|
||||||
),
|
),
|
||||||
|
|
@ -869,7 +875,7 @@ internal fun TextComposerVoiceNotEncryptedPreview() = ElementPreview {
|
||||||
isSending = true,
|
isSending = true,
|
||||||
isPlaying = false,
|
isPlaying = false,
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
waveform = createFakeWaveform(),
|
waveform = WaveFormSamples.realisticWaveForm,
|
||||||
time = 61.seconds,
|
time = 61.seconds,
|
||||||
playbackProgress = 0.0f
|
playbackProgress = 0.0f
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
|
import io.element.android.libraries.designsystem.components.media.WaveFormSamples
|
||||||
import io.element.android.libraries.designsystem.components.media.WaveformPlaybackView
|
import io.element.android.libraries.designsystem.components.media.WaveformPlaybackView
|
||||||
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
|
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
|
|
@ -138,14 +138,18 @@ private fun PlayerButton(
|
||||||
private fun PauseIcon() = Icon(
|
private fun PauseIcon() = Icon(
|
||||||
imageVector = CompoundIcons.PauseSolid(),
|
imageVector = CompoundIcons.PauseSolid(),
|
||||||
contentDescription = stringResource(id = CommonStrings.a11y_pause),
|
contentDescription = stringResource(id = CommonStrings.a11y_pause),
|
||||||
modifier = Modifier.size(20.dp).padding(2.dp),
|
modifier = Modifier
|
||||||
|
.size(20.dp)
|
||||||
|
.padding(2.dp),
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun PlayIcon() = Icon(
|
private fun PlayIcon() = Icon(
|
||||||
imageVector = CompoundIcons.PlaySolid(),
|
imageVector = CompoundIcons.PlaySolid(),
|
||||||
contentDescription = stringResource(id = CommonStrings.a11y_play),
|
contentDescription = stringResource(id = CommonStrings.a11y_play),
|
||||||
modifier = Modifier.size(20.dp).padding(2.dp),
|
modifier = Modifier
|
||||||
|
.size(20.dp)
|
||||||
|
.padding(2.dp),
|
||||||
)
|
)
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
|
|
@ -160,7 +164,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
||||||
time = 2.seconds,
|
time = 2.seconds,
|
||||||
playbackProgress = 0.2f,
|
playbackProgress = 0.2f,
|
||||||
showCursor = true,
|
showCursor = true,
|
||||||
waveform = createFakeWaveform()
|
waveform = WaveFormSamples.longRealisticWaveForm,
|
||||||
)
|
)
|
||||||
AVoiceMessagePreview(
|
AVoiceMessagePreview(
|
||||||
isInteractive = true,
|
isInteractive = true,
|
||||||
|
|
@ -168,7 +172,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
||||||
time = 0.seconds,
|
time = 0.seconds,
|
||||||
playbackProgress = 0.0f,
|
playbackProgress = 0.0f,
|
||||||
showCursor = true,
|
showCursor = true,
|
||||||
waveform = createFakeWaveform()
|
waveform = WaveFormSamples.longRealisticWaveForm,
|
||||||
)
|
)
|
||||||
AVoiceMessagePreview(
|
AVoiceMessagePreview(
|
||||||
isInteractive = false,
|
isInteractive = false,
|
||||||
|
|
@ -176,7 +180,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
||||||
time = 789.seconds,
|
time = 789.seconds,
|
||||||
playbackProgress = 0.0f,
|
playbackProgress = 0.0f,
|
||||||
showCursor = false,
|
showCursor = false,
|
||||||
waveform = createFakeWaveform()
|
waveform = WaveFormSamples.longRealisticWaveForm,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue