Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 56 additions & 38 deletions app/src/main/java/com/cornellappdev/score/components/ScoreBox.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cornellappdev.score.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -8,6 +9,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Divider
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -20,13 +22,15 @@ import androidx.compose.ui.unit.dp
import com.cornellappdev.score.model.GameData
import com.cornellappdev.score.model.TeamScore
import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.theme.GrayMedium
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.Style.metricNormal
import com.cornellappdev.score.theme.Style.metricSemibold
import com.cornellappdev.score.theme.saturatedGreen
import com.cornellappdev.score.util.emptyGameData
import com.cornellappdev.score.util.gameData
import com.cornellappdev.score.util.longGameData

@Composable
fun BoxScore(gameData: GameData) {
Expand All @@ -35,54 +39,54 @@ fun BoxScore(gameData: GameData) {
gameData.teamScores.second.scoresByPeriod.size,
4
)

Column(
Surface(
modifier = Modifier
.fillMaxWidth()
.background(Color.White, shape = RoundedCornerShape(8.dp))
.fillMaxWidth(),
shape = RoundedCornerShape(8.dp),
border = BorderStroke(width = 1.dp, color = CrimsonPrimary)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.background(CrimsonPrimary)
.padding(vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "",
modifier = Modifier.weight(1f),
color = Color.White,
textAlign = TextAlign.Center
)
repeat(maxPeriods) { period ->
Column {
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = CrimsonPrimary)
.padding(top = 6.dp, bottom = 4.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "${period + 1}",
text = "",
modifier = Modifier.weight(1f),
color = Color.White,
textAlign = TextAlign.Center
)
repeat(maxPeriods) { period ->
Text(
text = "${period + 1}",
modifier = Modifier.weight(1f),
color = Color.White,
style = bodyNormal,
textAlign = TextAlign.Center
)
}
Text(
text = "Total",
modifier = Modifier.weight(1f),
style = bodyNormal,
color = Color.White,
textAlign = TextAlign.Center
)
}
Text(
text = "Total",
modifier = Modifier.weight(1f),
style = bodyNormal,
color = Color.White,
textAlign = TextAlign.Center
TeamScoreRow(
teamScore = gameData.teamScores.first,
totalTextColor = saturatedGreen,
)
}
Divider(color = CrimsonPrimary, thickness = 1.dp)

TeamScoreRow(
teamScore = gameData.teamScores.first,
totalTextColor = saturatedGreen,
)

Divider(color = CrimsonPrimary, thickness = 1.dp)

TeamScoreRow(
teamScore = gameData.teamScores.second,
totalTextColor = Color.Black,
)
TeamScoreRow(
teamScore = gameData.teamScores.second,
totalTextColor = GrayMedium
)
}
}
}

Expand Down Expand Up @@ -136,14 +140,28 @@ fun TeamScoreRow(teamScore: TeamScore, totalTextColor: Color) {
}
}


@Preview
@Composable
private fun PreviewBoxScore() = ScorePreview {
private fun PreviewBoxScore() {
BoxScore(gameData = gameData)
}

@Preview
@Composable
private fun PreviewBoxScoreForLongGame() {
BoxScore(longGameData)
}

@Preview
@Composable
private fun PreviewBoxScoreEmpty() = ScorePreview {
BoxScore(gameData = emptyGameData())
}


@Preview
@Composable
private fun PreviewTeamScoreRow() = ScorePreview {
TeamScoreRow(gameData.teamScores.first, GrayMedium)
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/cornellappdev/score/util/TestingConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ val teamScore2 = TeamScore(
totalScore = 23
)

val longGameTeamScore1 = TeamScore(
team = team1,
scoresByPeriod = listOf(13, 14, 6, 14, 13, 2, 4, 6, 2, 2),
totalScore = 47
)
val longGameTeamScore2 = TeamScore(
team = team1,
scoresByPeriod = listOf(7, 7, 9, 0, 7, 7, 9, 0, 7, 2),
totalScore = 47
)

val longGameData = GameData(teamScores = longGameTeamScore1 to longGameTeamScore2)

val gameData = GameData(teamScores = Pair(teamScore1, teamScore2))

val scoreEvents1 = listOf(
Expand Down