refactor(home): extract loading/error/empty -> components/HomeStateCards.kt
Step 2/9. Verbatim move, public entries. compileDebugKotlin green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
5f39194c00
commit
18ad31506e
|
|
@ -87,9 +87,12 @@ import androidx.compose.material3.SnackbarHost
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import app.closer.R
|
import app.closer.R
|
||||||
|
import app.closer.ui.home.components.EmptyHomeContent
|
||||||
|
import app.closer.ui.home.components.ErrorHomeCard
|
||||||
import app.closer.ui.home.components.HomeActionColors
|
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.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
|
||||||
|
|
@ -1485,64 +1488,6 @@ private fun PendingActionCardView(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun LoadingHomeCard() {
|
|
||||||
LoadingState(message = "Opening your dashboard")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun ErrorHomeCard(
|
|
||||||
message: String,
|
|
||||||
onRefresh: () -> Unit
|
|
||||||
) {
|
|
||||||
ErrorState(
|
|
||||||
title = "Home paused",
|
|
||||||
message = message,
|
|
||||||
retryLabel = "Retry",
|
|
||||||
onRetry = onRefresh
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun EmptyHomeContent(
|
|
||||||
dailyQuestion: Question?,
|
|
||||||
onDailyQuestion: () -> Unit,
|
|
||||||
onPacks: () -> Unit
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
|
||||||
) {
|
|
||||||
CloserCard(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
shape = RoundedCornerShape(CloserRadii.Card),
|
|
||||||
containerColor = closerCardColor(alpha = 0.82f),
|
|
||||||
elevation = CloserElevations.Card
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.padding(18.dp),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "You're all caught up",
|
|
||||||
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold),
|
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "Nothing needs your attention right now. Come back later or explore a pack together.",
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
CloserActionButton(
|
|
||||||
label = "Browse packs",
|
|
||||||
onClick = onPacks,
|
|
||||||
style = CloserButtonStyle.Secondary
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreenPreview() {
|
fun HomeScreenPreview() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
package app.closer.ui.home.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
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.Modifier
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import app.closer.domain.model.Question
|
||||||
|
import app.closer.ui.components.CloserActionButton
|
||||||
|
import app.closer.ui.components.CloserButtonStyle
|
||||||
|
import app.closer.ui.components.CloserCard
|
||||||
|
import app.closer.ui.components.CloserElevations
|
||||||
|
import app.closer.ui.components.CloserRadii
|
||||||
|
import app.closer.ui.components.ErrorState
|
||||||
|
import app.closer.ui.components.LoadingState
|
||||||
|
import app.closer.ui.theme.closerCardColor
|
||||||
|
|
||||||
|
/** Home's loading / error / all-caught-up states. Extracted from HomeScreen.kt. */
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LoadingHomeCard() {
|
||||||
|
LoadingState(message = "Opening your dashboard")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ErrorHomeCard(
|
||||||
|
message: String,
|
||||||
|
onRefresh: () -> Unit
|
||||||
|
) {
|
||||||
|
ErrorState(
|
||||||
|
title = "Home paused",
|
||||||
|
message = message,
|
||||||
|
retryLabel = "Retry",
|
||||||
|
onRetry = onRefresh
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun EmptyHomeContent(
|
||||||
|
dailyQuestion: Question?,
|
||||||
|
onDailyQuestion: () -> Unit,
|
||||||
|
onPacks: () -> Unit
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
CloserCard(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(CloserRadii.Card),
|
||||||
|
containerColor = closerCardColor(alpha = 0.82f),
|
||||||
|
elevation = CloserElevations.Card
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(18.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "You're all caught up",
|
||||||
|
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold),
|
||||||
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Nothing needs your attention right now. Come back later or explore a pack together.",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
CloserActionButton(
|
||||||
|
label = "Browse packs",
|
||||||
|
onClick = onPacks,
|
||||||
|
style = CloserButtonStyle.Secondary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue