Skip to content

Commit a51fdf9

Browse files
author
Marco Romano
authored
Blink red dot while recording voice message (#1677)
Story: element-hq/element-meta#2084
1 parent 8121d1a commit a51fdf9

File tree

1 file changed

+25
-5
lines changed
  • libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components

1 file changed

+25
-5
lines changed

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/VoiceMessageRecording.kt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package io.element.android.libraries.textcomposer.components
1818

19+
import androidx.compose.animation.core.InfiniteRepeatableSpec
20+
import androidx.compose.animation.core.RepeatMode
21+
import androidx.compose.animation.core.TweenSpec
22+
import androidx.compose.animation.core.animateFloat
23+
import androidx.compose.animation.core.rememberInfiniteTransition
1924
import androidx.compose.foundation.background
2025
import androidx.compose.foundation.layout.Box
2126
import androidx.compose.foundation.layout.Row
@@ -28,8 +33,10 @@ import androidx.compose.foundation.layout.size
2833
import androidx.compose.foundation.shape.CircleShape
2934
import androidx.compose.material3.MaterialTheme
3035
import androidx.compose.runtime.Composable
36+
import androidx.compose.runtime.getValue
3137
import androidx.compose.ui.Alignment
3238
import androidx.compose.ui.Modifier
39+
import androidx.compose.ui.draw.alpha
3340
import androidx.compose.ui.unit.dp
3441
import io.element.android.libraries.designsystem.preview.ElementPreview
3542
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
@@ -83,11 +90,24 @@ internal fun VoiceMessageRecording(
8390
@Composable
8491
private fun RedRecordingDot(
8592
modifier: Modifier = Modifier,
86-
) = Box(
87-
modifier = modifier
88-
.size(8.dp)
89-
.background(color = ElementTheme.colors.textCriticalPrimary, shape = CircleShape)
90-
)
93+
) {
94+
val infiniteTransition = rememberInfiniteTransition("RedRecordingDot")
95+
val alpha by infiniteTransition.animateFloat(
96+
initialValue = 1f,
97+
targetValue = 0f,
98+
animationSpec = InfiniteRepeatableSpec(
99+
animation = TweenSpec(durationMillis = 1_000),
100+
repeatMode = RepeatMode.Reverse,
101+
),
102+
label = "RedRecordingDotAlpha",
103+
)
104+
Box(
105+
modifier = modifier
106+
.size(8.dp)
107+
.alpha(alpha)
108+
.background(color = ElementTheme.colors.textCriticalPrimary, shape = CircleShape)
109+
)
110+
}
91111

92112
@PreviewsDayNight
93113
@Composable

0 commit comments

Comments
 (0)