refactor(home): extract pending cards -> components/HomePendingCards.kt
Step 4/9. Verbatim move (section public, card-view private). compileDebugKotlin green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
07c810c9a1
commit
88460922c3
|
|
@ -94,6 +94,7 @@ import app.closer.ui.home.components.HomeActionColors
|
||||||
import app.closer.ui.home.components.HomeGlyphIcon
|
import app.closer.ui.home.components.HomeGlyphIcon
|
||||||
import app.closer.ui.home.components.HomePill
|
import app.closer.ui.home.components.HomePill
|
||||||
import app.closer.ui.home.components.LoadingHomeCard
|
import app.closer.ui.home.components.LoadingHomeCard
|
||||||
|
import app.closer.ui.home.components.WaitingForYouSection
|
||||||
import app.closer.ui.home.components.actionColors
|
import app.closer.ui.home.components.actionColors
|
||||||
import app.closer.ui.home.components.homeActionGlyph
|
import app.closer.ui.home.components.homeActionGlyph
|
||||||
import app.closer.ui.home.components.homePrimaryArt
|
import app.closer.ui.home.components.homePrimaryArt
|
||||||
|
|
@ -1314,94 +1315,6 @@ private fun MomentCueCard() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun WaitingForYouSection(
|
|
||||||
actions: List<PendingActionCard>,
|
|
||||||
onAction: (PendingActionCard) -> Unit,
|
|
||||||
onJoinGame: () -> Unit
|
|
||||||
) {
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
|
||||||
Text(
|
|
||||||
text = "Also waiting",
|
|
||||||
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold),
|
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
actions.take(3).forEach { card ->
|
|
||||||
PendingActionCardView(
|
|
||||||
card = card,
|
|
||||||
onClick = {
|
|
||||||
if (card.target == HomeActionTarget.Game) onJoinGame() else onAction(card)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun PendingActionCardView(
|
|
||||||
card: PendingActionCard,
|
|
||||||
onClick: () -> Unit
|
|
||||||
) {
|
|
||||||
val colors = HomeActionTone.Pending.actionColors()
|
|
||||||
|
|
||||||
CloserClickableCard(
|
|
||||||
onClick = onClick,
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
shape = RoundedCornerShape(CloserRadii.Card),
|
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
|
||||||
elevation = CloserElevations.Card
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(16.dp),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(13.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(40.dp)
|
|
||||||
.background(colors.soft, RoundedCornerShape(CloserRadii.Button)),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
HomeGlyphIcon(
|
|
||||||
resId = homeActionGlyph(card.target),
|
|
||||||
contentDescription = null,
|
|
||||||
tint = colors.deep,
|
|
||||||
modifier = Modifier.size(20.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(2.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = card.title,
|
|
||||||
style = MaterialTheme.typography.titleSmall.copy(fontWeight = FontWeight.SemiBold),
|
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
card.subtitle?.let { subtitle ->
|
|
||||||
Text(
|
|
||||||
text = subtitle,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
maxLines = 2,
|
|
||||||
overflow = TextOverflow.Ellipsis
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HomeGlyphIcon(
|
|
||||||
resId = R.drawable.glyph_forward,
|
|
||||||
contentDescription = "Open",
|
|
||||||
tint = colors.deep,
|
|
||||||
modifier = Modifier.size(20.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreenPreview() {
|
fun HomeScreenPreview() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package app.closer.ui.home.components
|
||||||
|
|
||||||
|
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.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
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.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import app.closer.R
|
||||||
|
import app.closer.ui.components.CloserClickableCard
|
||||||
|
import app.closer.ui.components.CloserElevations
|
||||||
|
import app.closer.ui.components.CloserRadii
|
||||||
|
import app.closer.ui.home.HomeActionTarget
|
||||||
|
import app.closer.ui.home.HomeActionTone
|
||||||
|
import app.closer.ui.home.PendingActionCard
|
||||||
|
|
||||||
|
/** Home's "Also waiting" pending-action list. Extracted from HomeScreen.kt. */
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WaitingForYouSection(
|
||||||
|
actions: List<PendingActionCard>,
|
||||||
|
onAction: (PendingActionCard) -> Unit,
|
||||||
|
onJoinGame: () -> Unit
|
||||||
|
) {
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
|
Text(
|
||||||
|
text = "Also waiting",
|
||||||
|
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold),
|
||||||
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
|
)
|
||||||
|
actions.take(3).forEach { card ->
|
||||||
|
PendingActionCardView(
|
||||||
|
card = card,
|
||||||
|
onClick = {
|
||||||
|
if (card.target == HomeActionTarget.Game) onJoinGame() else onAction(card)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun PendingActionCardView(
|
||||||
|
card: PendingActionCard,
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
|
val colors = HomeActionTone.Pending.actionColors()
|
||||||
|
|
||||||
|
CloserClickableCard(
|
||||||
|
onClick = onClick,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(CloserRadii.Card),
|
||||||
|
containerColor = MaterialTheme.colorScheme.surface,
|
||||||
|
elevation = CloserElevations.Card
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(13.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(40.dp)
|
||||||
|
.background(colors.soft, RoundedCornerShape(CloserRadii.Button)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
HomeGlyphIcon(
|
||||||
|
resId = homeActionGlyph(card.target),
|
||||||
|
contentDescription = null,
|
||||||
|
tint = colors.deep,
|
||||||
|
modifier = Modifier.size(20.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(2.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = card.title,
|
||||||
|
style = MaterialTheme.typography.titleSmall.copy(fontWeight = FontWeight.SemiBold),
|
||||||
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
card.subtitle?.let { subtitle ->
|
||||||
|
Text(
|
||||||
|
text = subtitle,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
maxLines = 2,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HomeGlyphIcon(
|
||||||
|
resId = R.drawable.glyph_forward,
|
||||||
|
contentDescription = "Open",
|
||||||
|
tint = colors.deep,
|
||||||
|
modifier = Modifier.size(20.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue