fix(game-history): disable replay on unsupported game types, clean up session title/route
This commit is contained in:
parent
755077c7ba
commit
58be8ed021
|
|
@ -128,7 +128,7 @@ fun GameHistoryScreen(
|
||||||
items(state.sessions, key = { it.id }) { session ->
|
items(state.sessions, key = { it.id }) { session ->
|
||||||
WheelSessionCard(
|
WheelSessionCard(
|
||||||
session = session,
|
session = session,
|
||||||
onClick = { onNavigate(sessionReplayRoute(session)) }
|
onClick = sessionReplayRoute(session)?.let { route -> { onNavigate(route) } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +152,11 @@ fun GameHistoryScreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun WheelSessionCard(session: QuestionSession, onClick: () -> Unit = {}) {
|
private fun WheelSessionCard(session: QuestionSession, onClick: (() -> Unit)?) {
|
||||||
|
val replayable = onClick != null
|
||||||
Card(
|
Card(
|
||||||
onClick = onClick,
|
onClick = onClick ?: {},
|
||||||
|
enabled = replayable,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
shape = RoundedCornerShape(20.dp),
|
shape = RoundedCornerShape(20.dp),
|
||||||
colors = CardDefaults.cardColors(containerColor = closerCardColor(alpha = 0.88f)),
|
colors = CardDefaults.cardColors(containerColor = closerCardColor(alpha = 0.88f)),
|
||||||
|
|
@ -173,7 +175,7 @@ private fun WheelSessionCard(session: QuestionSession, onClick: () -> Unit = {})
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "${session.questionIds.size} questions",
|
text = if (replayable) "${session.questionIds.size} questions" else "Replay not available",
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
@ -282,14 +284,16 @@ private fun sessionTitle(session: QuestionSession): String = when (session.gameT
|
||||||
GameType.THIS_OR_THAT -> "This or That"
|
GameType.THIS_OR_THAT -> "This or That"
|
||||||
GameType.HOW_WELL -> "How Well Do You Know Me"
|
GameType.HOW_WELL -> "How Well Do You Know Me"
|
||||||
GameType.DESIRE_SYNC -> "Desire Sync"
|
GameType.DESIRE_SYNC -> "Desire Sync"
|
||||||
else -> session.categoryId.displayCategoryName().ifBlank { "Spin Wheel" }
|
GameType.WHEEL -> session.categoryId.displayCategoryName().ifBlank { "Spin Wheel" }
|
||||||
|
else -> "Game Session"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sessionReplayRoute(session: QuestionSession): String = when (session.gameType) {
|
private fun sessionReplayRoute(session: QuestionSession): String? = when (session.gameType) {
|
||||||
GameType.THIS_OR_THAT -> AppRoute.thisOrThatReplay(session.id)
|
GameType.THIS_OR_THAT -> AppRoute.thisOrThatReplay(session.id)
|
||||||
GameType.HOW_WELL -> AppRoute.howWellReplay(session.id)
|
GameType.HOW_WELL -> AppRoute.howWellReplay(session.id)
|
||||||
GameType.DESIRE_SYNC -> AppRoute.desireSyncReplay(session.id)
|
GameType.DESIRE_SYNC -> AppRoute.desireSyncReplay(session.id)
|
||||||
else -> AppRoute.wheelComplete(session.id)
|
GameType.WHEEL -> AppRoute.wheelComplete(session.id)
|
||||||
|
else -> null // no replay screen for this game type
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue