feat(date-memories): add 'We did this' and 'Date memories' entry to DateMatchesScreen
This commit is contained in:
parent
90995cdaef
commit
e4f10551a0
|
|
@ -29,6 +29,9 @@ import androidx.compose.material3.MaterialTheme
|
|||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
|
|
@ -42,8 +45,13 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import app.closer.domain.model.DateCostLevel
|
||||
import app.closer.domain.model.DateIdea
|
||||
import app.closer.core.navigation.AppRoute
|
||||
import app.closer.domain.model.DateMatch
|
||||
import app.closer.domain.model.DateMatchSuggestion
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import app.closer.domain.model.SwipeAction
|
||||
import app.closer.ui.components.EmptyState
|
||||
import app.closer.ui.components.ErrorState
|
||||
|
|
@ -57,10 +65,17 @@ fun DateMatchesScreen(
|
|||
) {
|
||||
val state by viewModel.uiState.collectAsState()
|
||||
|
||||
// After marking a date done, open its reflection.
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.markedDateId.collect { dateId -> onNavigate(AppRoute.dateReflection(dateId)) }
|
||||
}
|
||||
|
||||
DateMatchesContent(
|
||||
state = state,
|
||||
onRetry = viewModel::retry,
|
||||
onBack = { onNavigate("back") }
|
||||
onBack = { onNavigate("back") },
|
||||
onMarkCompleted = viewModel::markCompleted,
|
||||
onMemories = { onNavigate(AppRoute.DATE_MEMORIES) }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +83,9 @@ fun DateMatchesScreen(
|
|||
private fun DateMatchesContent(
|
||||
state: DateMatchesUiState,
|
||||
onRetry: () -> Unit,
|
||||
onBack: () -> Unit
|
||||
onBack: () -> Unit,
|
||||
onMarkCompleted: (DateMatch) -> Unit = {},
|
||||
onMemories: () -> Unit = {}
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
|
@ -104,6 +121,16 @@ private fun DateMatchesContent(
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
TextButton(onClick = onMemories, contentPadding = androidx.compose.foundation.layout.PaddingValues(vertical = 4.dp)) {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.glyph_date_replay),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(18.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text("Your date memories", style = MaterialTheme.typography.labelLarge)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +176,7 @@ private fun DateMatchesContent(
|
|||
)
|
||||
}
|
||||
items(state.mutualMatches, key = { it.id }) { match ->
|
||||
MatchCard(match = match)
|
||||
MatchCard(match = match, onMarkCompleted = { onMarkCompleted(match) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,10 +246,22 @@ private fun SectionHeader(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun MatchCard(match: DateMatch) {
|
||||
private fun MatchCard(match: DateMatch, onMarkCompleted: () -> Unit = {}) {
|
||||
val idea = match.dateIdea ?: return
|
||||
IdeaCard(
|
||||
idea = idea,
|
||||
action = {
|
||||
TextButton(onClick = onMarkCompleted, modifier = Modifier.fillMaxWidth()) {
|
||||
Icon(
|
||||
imageVector = CloserGlyphs.Heart,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = Color(0xFF9B1B5A)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text("We did this", fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
},
|
||||
badge = {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(999.dp),
|
||||
|
|
@ -286,7 +325,8 @@ private fun SuggestionCard(suggestion: DateMatchSuggestion) {
|
|||
@Composable
|
||||
private fun IdeaCard(
|
||||
idea: DateIdea,
|
||||
badge: @Composable () -> Unit
|
||||
badge: @Composable () -> Unit,
|
||||
action: (@Composable () -> Unit)? = null
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
|
@ -348,6 +388,8 @@ private fun IdeaCard(
|
|||
InfoChip(label = "Premium", emphasis = true)
|
||||
}
|
||||
}
|
||||
|
||||
action?.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue