generated from AdamMc331/AndroidAppTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a swiss stage row item to demonstrate how a team preformed. (#443
- Loading branch information
Showing
14 changed files
with
343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...in/kotlin/com/adammcneilly/pocketleague/core/displaymodels/SwissTeamResultDisplayModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.adammcneilly.pocketleague.core.displaymodels | ||
|
||
/** | ||
* User friendly explanation of how a [team] preformed in a Swiss stage. | ||
* | ||
* @property[team] The team information for the players in this swiss result. | ||
* @property[overline] Describes if the team is qualified or eliminated. Should be empty if neither of those. | ||
* @property[subtitle] States how the team preformed in the swiss stage, with match and game records and game differential. | ||
* example: 3-0 | 9-0 | +9 | ||
*/ | ||
data class SwissTeamResultDisplayModel( | ||
val team: TeamOverviewDisplayModel, | ||
val overline: String, | ||
val subtitle: String, | ||
) |
28 changes: 28 additions & 0 deletions
28
...ommonMain/kotlin/com/adammcneilly/pocketleague/shared/ui/swiss/SwissTeamResultListCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.adammcneilly.pocketleague.shared.ui.swiss | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.adammcneilly.pocketleague.core.displaymodels.SwissTeamResultDisplayModel | ||
import com.adammcneilly.pocketleague.shared.ui.components.ListItemDividerCard | ||
|
||
/** | ||
* [ListItemDividerCard] implementation for a set of [teamResults]. | ||
*/ | ||
@Composable | ||
fun SwissTeamResultListCard( | ||
teamResults: List<SwissTeamResultDisplayModel>, | ||
modifier: Modifier = Modifier, | ||
) { | ||
ListItemDividerCard( | ||
items = teamResults, | ||
modifier = modifier, | ||
) { teamResult -> | ||
SwissTeamResultListItem( | ||
displayModel = teamResult, | ||
modifier = Modifier | ||
.padding(8.dp), | ||
) | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...ommonMain/kotlin/com/adammcneilly/pocketleague/shared/ui/swiss/SwissTeamResultListItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.adammcneilly.pocketleague.shared.ui.swiss | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import com.adammcneilly.pocketleague.core.displaymodels.SwissTeamResultDisplayModel | ||
import com.adammcneilly.pocketleague.shared.ui.components.CircleTeamLogo | ||
import com.adammcneilly.pocketleague.shared.ui.theme.PocketLeagueTheme | ||
|
||
/** | ||
* User friendly representation of a [SwissTeamResultDisplayModel]. | ||
*/ | ||
@Composable | ||
fun SwissTeamResultListItem( | ||
displayModel: SwissTeamResultDisplayModel, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val colorToUse = if (displayModel.overline == "Qualified") { | ||
Color.Green | ||
} else { | ||
Color.Red | ||
} | ||
|
||
Row( | ||
modifier = Modifier | ||
.height(IntrinsicSize.Min), | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.background(color = colorToUse) | ||
.width(4.dp) | ||
.fillMaxHeight(), | ||
) | ||
|
||
Row( | ||
modifier = modifier, | ||
horizontalArrangement = Arrangement.spacedBy(PocketLeagueTheme.sizes.listItemSpacing), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
CircleTeamLogo( | ||
displayModel = displayModel.team, | ||
modifier = Modifier | ||
.size(36.dp), | ||
) | ||
|
||
Column( | ||
modifier = Modifier | ||
.weight(1F), | ||
) { | ||
// Text( | ||
// text = displayModel.overline, | ||
// style = MaterialTheme.typography.labelSmall, | ||
// fontWeight = FontWeight.Bold, | ||
// ) | ||
|
||
Text( | ||
text = displayModel.team.name, | ||
style = MaterialTheme.typography.bodyLarge, | ||
) | ||
|
||
Text( | ||
text = displayModel.subtitle, | ||
style = MaterialTheme.typography.bodySmall, | ||
) | ||
} | ||
} | ||
} | ||
} |
142 changes: 142 additions & 0 deletions
142
...lin/com/adammcneilly/pocketleague/shared/ui/swiss/SwissTeamResultListCardPaparazziTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package com.adammcneilly.pocketleague.shared.ui.swiss | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.ui.unit.dp | ||
import app.cash.paparazzi.Paparazzi | ||
import com.adammcneilly.pocketleague.core.displaymodels.SwissTeamResultDisplayModel | ||
import com.adammcneilly.pocketleague.core.displaymodels.test.TestDisplayModel | ||
import com.adammcneilly.pocketleague.shared.ui.snapshotScreen | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import org.junit.Rule | ||
import org.junit.runner.RunWith | ||
import kotlin.test.Test | ||
|
||
@RunWith(TestParameterInjector::class) | ||
class SwissTeamResultListCardPaparazziTest { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@TestParameter | ||
val useDarkTheme: Boolean = false | ||
|
||
@Test | ||
fun render() { | ||
val displayModels = testDisplayModels() | ||
|
||
paparazzi.snapshotScreen( | ||
useDarkTheme = useDarkTheme, | ||
screenPaddingDp = 0, | ||
) { | ||
LazyColumn( | ||
contentPadding = PaddingValues(16.dp), | ||
) { | ||
item { | ||
SwissTeamResultListCard(displayModels) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Suppress("LongMethod") | ||
private fun testDisplayModels() = | ||
listOf( | ||
makeResult( | ||
teamName = "G2 Esports", | ||
overline = "Qualified", | ||
subtitle = "3-0 | 12-3 | +9", | ||
), | ||
makeResult( | ||
teamName = "Team Falcons", | ||
overline = "Qualified", | ||
subtitle = "3-0 | 12-5 | +7", | ||
), | ||
makeResult( | ||
teamName = "KRÜ Esports", | ||
overline = "Qualified", | ||
subtitle = "3-1 | 14-8 | +6", | ||
), | ||
makeResult( | ||
teamName = "Spacestation Gaming", | ||
overline = "Qualified", | ||
subtitle = "3-0 | 15-9 | +6", | ||
), | ||
makeResult( | ||
teamName = "Complexity Gaming", | ||
overline = "Qualified", | ||
subtitle = "3-0 | 12-7 | +5", | ||
), | ||
makeResult( | ||
teamName = "Moist Esports", | ||
overline = "Qualified", | ||
subtitle = "3-2 | 16-10 | +6", | ||
), | ||
makeResult( | ||
teamName = "Twisted Minds", | ||
overline = "Qualified", | ||
subtitle = "3-2 | 15-11 | +4", | ||
), | ||
makeResult( | ||
teamName = "Team Secret", | ||
overline = "Qualified", | ||
subtitle = "3-2 | 14-12 | +2", | ||
), | ||
makeResult( | ||
teamName = "PWR", | ||
overline = "Eliminated", | ||
subtitle = "2-3 | 13-13 | 0", | ||
), | ||
makeResult( | ||
teamName = "G1", | ||
overline = "Eliminated", | ||
subtitle = "2-3 | 13-13 | 0", | ||
), | ||
makeResult( | ||
teamName = "Elevate", | ||
overline = "Eliminated", | ||
subtitle = "2-3 | 10-16 | -6", | ||
), | ||
makeResult( | ||
teamName = "Pioneers", | ||
overline = "Eliminated", | ||
subtitle = "1-3 | 8-12 | -4", | ||
), | ||
makeResult( | ||
teamName = "Oxygen Esports", | ||
overline = "Eliminated", | ||
subtitle = "1-3 | 10-14 | -4", | ||
), | ||
makeResult( | ||
teamName = "Limitless", | ||
overline = "Eliminated", | ||
subtitle = "1-3 | 4-12 | -8", | ||
), | ||
makeResult( | ||
teamName = "Valiant", | ||
overline = "Eliminated", | ||
subtitle = "0-3 | 1-12 | -11", | ||
), | ||
makeResult( | ||
teamName = "Gaimin Gladiators", | ||
overline = "Eliminated", | ||
subtitle = "0-3 | 0-12 | -12", | ||
), | ||
) | ||
|
||
private fun makeResult( | ||
teamName: String, | ||
overline: String, | ||
subtitle: String, | ||
): SwissTeamResultDisplayModel { | ||
val team = TestDisplayModel.g2.copy( | ||
name = teamName, | ||
) | ||
|
||
return SwissTeamResultDisplayModel( | ||
team = team, | ||
overline = overline, | ||
subtitle = subtitle, | ||
) | ||
} |
57 changes: 57 additions & 0 deletions
57
...lin/com/adammcneilly/pocketleague/shared/ui/swiss/SwissTeamResultListItemPaparazziTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.adammcneilly.pocketleague.shared.ui.swiss | ||
|
||
import app.cash.paparazzi.Paparazzi | ||
import com.adammcneilly.pocketleague.core.displaymodels.test.TestDisplayModel.eliminatedSwiss | ||
import com.adammcneilly.pocketleague.core.displaymodels.test.TestDisplayModel.inProgressSwiss | ||
import com.adammcneilly.pocketleague.core.displaymodels.test.TestDisplayModel.qualifiedSwiss | ||
import com.adammcneilly.pocketleague.shared.ui.snapshotScreen | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import org.junit.Rule | ||
import org.junit.runner.RunWith | ||
import kotlin.test.Test | ||
|
||
@RunWith(TestParameterInjector::class) | ||
class SwissTeamResultListItemPaparazziTest { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@TestParameter | ||
val useDarkTheme: Boolean = false | ||
|
||
@Test | ||
fun renderQualified() { | ||
paparazzi.snapshotScreen( | ||
useDarkTheme = useDarkTheme, | ||
screenPaddingDp = 0, | ||
) { | ||
SwissTeamResultListItem( | ||
displayModel = qualifiedSwiss, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun renderInProgress() { | ||
paparazzi.snapshotScreen( | ||
useDarkTheme = useDarkTheme, | ||
screenPaddingDp = 0, | ||
) { | ||
SwissTeamResultListItem( | ||
displayModel = inProgressSwiss, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun renderEliminated() { | ||
paparazzi.snapshotScreen( | ||
useDarkTheme = useDarkTheme, | ||
screenPaddingDp = 0, | ||
) { | ||
SwissTeamResultListItem( | ||
displayModel = eliminatedSwiss, | ||
) | ||
} | ||
} | ||
} |
Binary file added
BIN
+75.4 KB
...ed.ui.swiss_SwissTeamResultListCardPaparazziTest_render[useDarkTheme=false].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.3 KB
...red.ui.swiss_SwissTeamResultListCardPaparazziTest_render[useDarkTheme=true].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...s_SwissTeamResultListItemPaparazziTest_renderEliminated[useDarkTheme=false].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
...ss_SwissTeamResultListItemPaparazziTest_renderEliminated[useDarkTheme=true].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...s_SwissTeamResultListItemPaparazziTest_renderInProgress[useDarkTheme=false].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
...ss_SwissTeamResultListItemPaparazziTest_renderInProgress[useDarkTheme=true].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...ss_SwissTeamResultListItemPaparazziTest_renderQualified[useDarkTheme=false].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
...iss_SwissTeamResultListItemPaparazziTest_renderQualified[useDarkTheme=true].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.