1
1
package com.jdamcd.arrivals.desktop
2
2
3
+ import androidx.compose.animation.core.LinearEasing
4
+ import androidx.compose.animation.core.RepeatMode
5
+ import androidx.compose.animation.core.animateFloat
6
+ import androidx.compose.animation.core.infiniteRepeatable
7
+ import androidx.compose.animation.core.rememberInfiniteTransition
8
+ import androidx.compose.animation.core.tween
3
9
import androidx.compose.foundation.background
4
10
import androidx.compose.foundation.layout.Arrangement
5
11
import androidx.compose.foundation.layout.Box
@@ -11,6 +17,7 @@ import androidx.compose.foundation.layout.padding
11
17
import androidx.compose.material.CircularProgressIndicator
12
18
import androidx.compose.material.Text
13
19
import androidx.compose.runtime.Composable
20
+ import androidx.compose.runtime.getValue
14
21
import androidx.compose.ui.Alignment
15
22
import androidx.compose.ui.Modifier
16
23
import androidx.compose.ui.text.TextStyle
@@ -19,7 +26,7 @@ import androidx.compose.ui.unit.sp
19
26
import com.jdamcd.arrivals.Arrival
20
27
21
28
@Composable
22
- fun ArrivalsList (
29
+ fun ArrivalsView (
23
30
state : ArrivalsState
24
31
) {
25
32
Column (
@@ -93,7 +100,11 @@ fun ArrivalRow(arrival: Arrival) {
93
100
modifier = Modifier .fillMaxWidth()
94
101
) {
95
102
LedText (arrival.destination)
96
- LedText (arrival.time)
103
+ if (arrival.secondsToStop < 60 ) {
104
+ FlashingLedText (arrival.time)
105
+ } else {
106
+ LedText (arrival.time)
107
+ }
97
108
}
98
109
}
99
110
@@ -108,3 +119,24 @@ fun LedText(string: String) {
108
119
)
109
120
)
110
121
}
122
+
123
+ @Composable
124
+ fun FlashingLedText (string : String ) {
125
+ val infiniteTransition = rememberInfiniteTransition()
126
+ val alpha by infiniteTransition.animateFloat(
127
+ initialValue = 0f ,
128
+ targetValue = 1f ,
129
+ animationSpec = infiniteRepeatable(
130
+ animation = tween(durationMillis = 750 , easing = LinearEasing ),
131
+ repeatMode = RepeatMode .Reverse
132
+ )
133
+ )
134
+ Text (
135
+ text = string,
136
+ color = LedYellow .copy(alpha = alpha),
137
+ style = TextStyle (
138
+ fontFamily = LurFontFamily ,
139
+ fontSize = 52 .sp
140
+ )
141
+ )
142
+ }
0 commit comments