refactor: Remove analysis for current day
This commit is contained in:
@@ -9,6 +9,7 @@ package org.nsh07.pomodoro.ui.statsScreen
|
|||||||
|
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -69,7 +70,6 @@ fun StatsScreenRoot(
|
|||||||
StatsScreen(
|
StatsScreen(
|
||||||
lastWeekSummaryChartData = viewModel.lastWeekSummaryChartData,
|
lastWeekSummaryChartData = viewModel.lastWeekSummaryChartData,
|
||||||
lastWeekSummaryAnalysisModelProducer = viewModel.lastWeekSummaryAnalysisModelProducer,
|
lastWeekSummaryAnalysisModelProducer = viewModel.lastWeekSummaryAnalysisModelProducer,
|
||||||
todayStatAnalysisModelProducer = viewModel.todayStatAnalysisModelProducer,
|
|
||||||
todayStat = todayStat,
|
todayStat = todayStat,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
)
|
)
|
||||||
@@ -80,13 +80,11 @@ fun StatsScreenRoot(
|
|||||||
fun StatsScreen(
|
fun StatsScreen(
|
||||||
lastWeekSummaryChartData: Pair<CartesianChartModelProducer, ExtraStore.Key<List<String>>>,
|
lastWeekSummaryChartData: Pair<CartesianChartModelProducer, ExtraStore.Key<List<String>>>,
|
||||||
lastWeekSummaryAnalysisModelProducer: CartesianChartModelProducer,
|
lastWeekSummaryAnalysisModelProducer: CartesianChartModelProducer,
|
||||||
todayStatAnalysisModelProducer: CartesianChartModelProducer,
|
|
||||||
todayStat: Stat?,
|
todayStat: Stat?,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
|
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
|
||||||
|
|
||||||
var todayStatExpanded by rememberSaveable { mutableStateOf(false) }
|
|
||||||
var lastWeekStatExpanded by rememberSaveable { mutableStateOf(false) }
|
var lastWeekStatExpanded by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -109,14 +107,18 @@ fun StatsScreen(
|
|||||||
scrollBehavior = scrollBehavior
|
scrollBehavior = scrollBehavior
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyColumn(horizontalAlignment = Alignment.CenterHorizontally) {
|
LazyColumn(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
|
) {
|
||||||
|
item { Spacer(Modifier) }
|
||||||
item {
|
item {
|
||||||
Text(
|
Text(
|
||||||
"Today",
|
"Today",
|
||||||
style = typography.headlineSmall,
|
style = typography.headlineSmall,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item {
|
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 {
|
item {
|
||||||
Text(
|
Text(
|
||||||
"This week",
|
"This week",
|
||||||
@@ -285,7 +254,6 @@ fun StatsScreenPreview() {
|
|||||||
StatsScreen(
|
StatsScreen(
|
||||||
Pair(modelProducer, ExtraStore.Key()),
|
Pair(modelProducer, ExtraStore.Key()),
|
||||||
modelProducer,
|
modelProducer,
|
||||||
modelProducer,
|
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class StatsViewModel(
|
|||||||
val lastWeekSummaryChartData =
|
val lastWeekSummaryChartData =
|
||||||
Pair(CartesianChartModelProducer(), ExtraStore.Key<List<String>>())
|
Pair(CartesianChartModelProducer(), ExtraStore.Key<List<String>>())
|
||||||
val lastWeekSummaryAnalysisModelProducer = CartesianChartModelProducer()
|
val lastWeekSummaryAnalysisModelProducer = CartesianChartModelProducer()
|
||||||
val todayStatAnalysisModelProducer = CartesianChartModelProducer()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
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) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
lastWeekAverageFocusTimes
|
lastWeekAverageFocusTimes
|
||||||
.collect {
|
.collect {
|
||||||
|
|||||||
Reference in New Issue
Block a user