refactor: Remove analysis for current day

This commit is contained in:
Nishant Mishra
2025-07-12 20:41:38 +05:30
parent 1c2db6d9ea
commit ee0c69e01f
2 changed files with 7 additions and 55 deletions

View File

@@ -9,6 +9,7 @@ package org.nsh07.pomodoro.ui.statsScreen
import androidx.compose.animation.core.animateFloatAsState
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
@@ -69,7 +70,6 @@ fun StatsScreenRoot(
StatsScreen(
lastWeekSummaryChartData = viewModel.lastWeekSummaryChartData,
lastWeekSummaryAnalysisModelProducer = viewModel.lastWeekSummaryAnalysisModelProducer,
todayStatAnalysisModelProducer = viewModel.todayStatAnalysisModelProducer,
todayStat = todayStat,
modifier = modifier
)
@@ -80,13 +80,11 @@ fun StatsScreenRoot(
fun StatsScreen(
lastWeekSummaryChartData: Pair<CartesianChartModelProducer, ExtraStore.Key<List<String>>>,
lastWeekSummaryAnalysisModelProducer: CartesianChartModelProducer,
todayStatAnalysisModelProducer: CartesianChartModelProducer,
todayStat: Stat?,
modifier: Modifier = Modifier
) {
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
var todayStatExpanded by rememberSaveable { mutableStateOf(false) }
var lastWeekStatExpanded by rememberSaveable { mutableStateOf(false) }
Column(
@@ -109,14 +107,18 @@ fun StatsScreen(
scrollBehavior = scrollBehavior
)
LazyColumn(horizontalAlignment = Alignment.CenterHorizontally) {
LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
item { Spacer(Modifier) }
item {
Text(
"Today",
style = typography.headlineSmall,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.padding(horizontal = 16.dp)
)
}
item {
@@ -177,39 +179,6 @@ fun StatsScreen(
}
}
}
item {
val iconRotation by animateFloatAsState(
if (todayStatExpanded) 180f else 0f,
animationSpec = motionScheme.defaultSpatialSpec()
)
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth()
) {
Spacer(Modifier.height(2.dp))
FilledTonalIconToggleButton(
checked = todayStatExpanded,
onCheckedChange = { todayStatExpanded = it },
shapes = IconButtonDefaults.toggleableShapes(),
modifier = Modifier
.padding(horizontal = 16.dp)
.width(52.dp)
.align(Alignment.End)
) {
Icon(
painterResource(R.drawable.arrow_down),
"More info",
modifier = Modifier.rotate(iconRotation)
)
}
ProductivityGraph(
todayStatExpanded,
todayStatAnalysisModelProducer,
Modifier.padding(horizontal = 32.dp)
)
}
Spacer(Modifier.height(16.dp))
}
item {
Text(
"This week",
@@ -285,7 +254,6 @@ fun StatsScreenPreview() {
StatsScreen(
Pair(modelProducer, ExtraStore.Key()),
modelProducer,
modelProducer,
null
)
}

View File

@@ -35,7 +35,6 @@ class StatsViewModel(
val lastWeekSummaryChartData =
Pair(CartesianChartModelProducer(), ExtraStore.Key<List<String>>())
val lastWeekSummaryAnalysisModelProducer = CartesianChartModelProducer()
val todayStatAnalysisModelProducer = CartesianChartModelProducer()
init {
viewModelScope.launch(Dispatchers.IO) {
@@ -51,21 +50,6 @@ class StatsViewModel(
}
}
}
viewModelScope.launch(Dispatchers.IO) {
todayStat
.collect {
todayStatAnalysisModelProducer.runTransaction {
columnSeries {
series(
it?.focusTimeQ1 ?: 0,
it?.focusTimeQ2 ?: 0,
it?.focusTimeQ3 ?: 0,
it?.focusTimeQ4 ?: 0
)
}
}
}
}
viewModelScope.launch(Dispatchers.IO) {
lastWeekAverageFocusTimes
.collect {