@@ -23,14 +23,38 @@ import androidx.compose.ui.text.style.TextDecoration
23
23
import androidx.compose.ui.text.style.TextOverflow
24
24
import androidx.compose.ui.unit.dp
25
25
import androidx.compose.ui.unit.sp
26
+ import com.sunkensplashstudios.VRCRoboScout.AllianceColor
26
27
import com.sunkensplashstudios.VRCRoboScout.Match
27
28
import com.sunkensplashstudios.VRCRoboScout.Team
28
29
import com.sunkensplashstudios.VRCRoboScout.ui.theme.allianceBlue
29
30
import com.sunkensplashstudios.VRCRoboScout.ui.theme.allianceRed
30
31
31
32
@Composable
32
33
fun MatchesView (matchList : List <Match >, team : Team ? = null) {
34
+
33
35
val timeFormat = java.text.SimpleDateFormat (" h:mm a" , java.util.Locale .getDefault())
36
+
37
+ fun determineColor (match : Match , team : Team ? , defaultColor : Color ): Color {
38
+ if (match.completed()) {
39
+ return if (team != null ) {
40
+ if (match.winningAlliance() == null ) {
41
+ Color .Yellow
42
+ } else if (match.winningAlliance() == AllianceColor .RED && match.redAlliance.members.find { member -> member.team.id == team.id } != null ) {
43
+ Color .Green
44
+ } else if (match.winningAlliance() == AllianceColor .BLUE && match.blueAlliance.members.find { member -> member.team.id == team.id } != null ) {
45
+ Color .Green
46
+ } else {
47
+ Color .Red
48
+ }
49
+ } else {
50
+ defaultColor
51
+ }
52
+ }
53
+ else {
54
+ return defaultColor
55
+ }
56
+ }
57
+
34
58
Column (
35
59
modifier = Modifier .verticalScroll(rememberScrollState())
36
60
) {
@@ -58,7 +82,7 @@ fun MatchesView(matchList: List<Match>, team: Team? = null) {
58
82
text = match.shortName,
59
83
fontSize = 16 .sp,
60
84
fontWeight = FontWeight .Bold ,
61
- color = MaterialTheme .colorScheme.onSurface
85
+ color = determineColor(match, team, MaterialTheme .colorScheme.onSurface)
62
86
)
63
87
Text (
64
88
text = match.startedDate?.let { timeFormat.format(it) }
0 commit comments