feat(home): surface couple streak count on Home dashboard
This commit is contained in:
parent
ca2a3b0431
commit
ea051bf4d3
|
|
@ -34,6 +34,7 @@ import androidx.compose.foundation.verticalScroll
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Favorite
|
||||
import androidx.compose.material.icons.filled.LocalFireDepartment
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
|
|
@ -214,6 +215,11 @@ private fun HomeContent(
|
|||
streakCount = state.streakCount
|
||||
)
|
||||
|
||||
StreakCard(
|
||||
streakCount = state.streakCount,
|
||||
partnerName = state.partnerName
|
||||
)
|
||||
|
||||
when {
|
||||
state.isLoading -> LoadingHomeCard()
|
||||
state.error != null -> ErrorHomeCard(message = state.error, onRefresh = onRefresh)
|
||||
|
|
@ -268,6 +274,76 @@ private fun HomeContent(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StreakCard(
|
||||
streakCount: Int,
|
||||
partnerName: String?,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val copy = when (streakCount) {
|
||||
0 -> "Start a new streak today"
|
||||
1 -> "1 day streak"
|
||||
else -> "$streakCount day streak"
|
||||
}
|
||||
val partnerLine = if (streakCount > 0 && !partnerName.isNullOrBlank()) "with $partnerName" else null
|
||||
|
||||
CloserCard(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(CloserRadii.FeatureCard),
|
||||
containerColor = closerCardColor(alpha = 0.92f),
|
||||
elevation = CloserElevations.Card
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(20.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(CloserRadii.Tile),
|
||||
color = CloserPalette.PinkSoft.copy(alpha = 0.28f),
|
||||
modifier = Modifier.size(52.dp)
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.LocalFireDepartment,
|
||||
contentDescription = null,
|
||||
tint = CloserPalette.PinkAccentDeep,
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
if (streakCount > 0) {
|
||||
Text(
|
||||
text = streakCount.toString(),
|
||||
style = MaterialTheme.typography.displaySmall.copy(fontWeight = FontWeight.SemiBold),
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
maxLines = 1
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = copy,
|
||||
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.SemiBold),
|
||||
color = if (streakCount > 0) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
partnerLine?.let {
|
||||
Text(
|
||||
text = it,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun HomeHeader(
|
||||
partnerName: String?,
|
||||
|
|
|
|||
Loading…
Reference in New Issue