16
16
17
17
package io.element.android.libraries.textcomposer.components
18
18
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
19
24
import androidx.compose.foundation.background
20
25
import androidx.compose.foundation.layout.Box
21
26
import androidx.compose.foundation.layout.Row
@@ -28,8 +33,10 @@ import androidx.compose.foundation.layout.size
28
33
import androidx.compose.foundation.shape.CircleShape
29
34
import androidx.compose.material3.MaterialTheme
30
35
import androidx.compose.runtime.Composable
36
+ import androidx.compose.runtime.getValue
31
37
import androidx.compose.ui.Alignment
32
38
import androidx.compose.ui.Modifier
39
+ import androidx.compose.ui.draw.alpha
33
40
import androidx.compose.ui.unit.dp
34
41
import io.element.android.libraries.designsystem.preview.ElementPreview
35
42
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
@@ -83,11 +90,24 @@ internal fun VoiceMessageRecording(
83
90
@Composable
84
91
private fun RedRecordingDot (
85
92
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
+ }
91
111
92
112
@PreviewsDayNight
93
113
@Composable
0 commit comments