refactor: rename status to matchStatus and inline modifier call
This commit is contained in:
parent
75cf97a3a4
commit
fc2c939e0b
5 changed files with 11 additions and 12 deletions
|
@ -29,7 +29,7 @@ fun MatchDto.toDomain(): Match {
|
||||||
id = serie.id,
|
id = serie.id,
|
||||||
name = serie.fullName ?: ""
|
name = serie.fullName ?: ""
|
||||||
),
|
),
|
||||||
status = status?.toMatchStatus() ?: MatchStatus.UNKNOWN
|
matchStatus = status?.toMatchStatus() ?: MatchStatus.UNKNOWN
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@ data class Match(
|
||||||
val opponents: List<Opponent>,
|
val opponents: List<Opponent>,
|
||||||
val league: League,
|
val league: League,
|
||||||
val serie: Serie,
|
val serie: Serie,
|
||||||
val status: MatchStatus
|
val matchStatus: MatchStatus
|
||||||
)
|
)
|
|
@ -51,7 +51,7 @@ fun MatchCard(
|
||||||
Box(modifier = modifier.fillMaxWidth()) {
|
Box(modifier = modifier.fillMaxWidth()) {
|
||||||
val (leftOpponent, rightOpponent) = getOrDefaultOpponents(match.opponents)
|
val (leftOpponent, rightOpponent) = getOrDefaultOpponents(match.opponents)
|
||||||
val leagueAndSerieName = "${match.league.name} + ${match.serie.name}"
|
val leagueAndSerieName = "${match.league.name} + ${match.serie.name}"
|
||||||
val scheduleConfig = match.status.scheduleConfigFor(match.beginAt)
|
val scheduleConfig = match.matchStatus.scheduleConfigFor(match.beginAt)
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(16.dp), onClick = {
|
modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(16.dp), onClick = {
|
||||||
|
@ -61,7 +61,7 @@ fun MatchCard(
|
||||||
rightOpponentId = rightOpponent.id,
|
rightOpponentId = rightOpponent.id,
|
||||||
leagueAndSerieName = leagueAndSerieName,
|
leagueAndSerieName = leagueAndSerieName,
|
||||||
scheduleString = scheduleConfig.first,
|
scheduleString = scheduleConfig.first,
|
||||||
status = match.status
|
matchStatus = match.matchStatus
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}, colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
|
}, colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
|
||||||
|
|
|
@ -13,7 +13,7 @@ data class MatchDetailsRoute(
|
||||||
val rightOpponentId: Long,
|
val rightOpponentId: Long,
|
||||||
val leagueAndSerieName: String,
|
val leagueAndSerieName: String,
|
||||||
val scheduleString: String,
|
val scheduleString: String,
|
||||||
val status: MatchStatus
|
val matchStatus: MatchStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
fun NavGraphBuilder.matchDetailsScreen(onBackClick: () -> Unit) {
|
fun NavGraphBuilder.matchDetailsScreen(onBackClick: () -> Unit) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ fun MatchDetailsScreen(
|
||||||
value.isLoading -> LoadingIndicator()
|
value.isLoading -> LoadingIndicator()
|
||||||
value.leftTeam != null && value.rightTeam != null -> Column {
|
value.leftTeam != null && value.rightTeam != null -> Column {
|
||||||
MatchupRow(leftTeam = value.leftTeam, rightTeam = value.rightTeam)
|
MatchupRow(leftTeam = value.leftTeam, rightTeam = value.rightTeam)
|
||||||
ScheduleRow(matchDetails.scheduleString, matchDetails.status)
|
ScheduleRow(matchDetails.scheduleString, matchDetails.matchStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,6 @@ fun MatchDetailsScreen(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ScheduleRow(scheduleString: String, matchStatus: MatchStatus) {
|
fun ScheduleRow(scheduleString: String, matchStatus: MatchStatus) {
|
||||||
val modifier = if (matchStatus == MatchStatus.LIVE)
|
|
||||||
Modifier
|
|
||||||
.background(LiveRed, RoundedCornerShape(16.dp))
|
|
||||||
.padding(horizontal = 12.dp, vertical = 8.dp)
|
|
||||||
else Modifier
|
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
@ -92,7 +87,11 @@ fun ScheduleRow(scheduleString: String, matchStatus: MatchStatus) {
|
||||||
scheduleString,
|
scheduleString,
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
color = White,
|
color = White,
|
||||||
modifier = modifier
|
modifier = if (matchStatus == MatchStatus.LIVE)
|
||||||
|
Modifier
|
||||||
|
.background(LiveRed, RoundedCornerShape(16.dp))
|
||||||
|
.padding(horizontal = 12.dp, vertical = 8.dp)
|
||||||
|
else Modifier
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue