From 78dc966f97803642f848c87f1b8bbf0c777b691f Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Fri, 19 Dec 2025 09:25:51 +0530 Subject: [PATCH] fix(stats): some improvements --- .../ui/statsScreen/components/FocusHistoryCalendar.kt | 7 ++++--- .../ui/statsScreen/components/HeatmapWithWeekLabels.kt | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/FocusHistoryCalendar.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/FocusHistoryCalendar.kt index 8c8a6ce..b20d31d 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/FocusHistoryCalendar.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/FocusHistoryCalendar.kt @@ -125,7 +125,7 @@ fun FocusHistoryCalendar( verticalArrangement = Arrangement.spacedBy(verticalGap), modifier = modifier .fillMaxWidth() - .background(colorScheme.surfaceContainer, shapes.largeIncreased) + .background(colorScheme.surfaceContainerLow, shapes.largeIncreased) .horizontalScroll(rememberScrollState()) .padding(internalPadding) ) { @@ -153,11 +153,12 @@ fun FocusHistoryCalendar( items.fastForEachIndexed { index, it -> val sum = remember(it) { it?.totalFocusTime() ?: 0L } val background = sum > 0 + val currentMonth = remember(it, last) { it?.date?.month == last?.date?.month } - val flatIndex = baseIndex * 7 + index // Calculate flat index + val flatIndex = baseIndex * 7 + index - val shape = remember(data, background) { + val shape = remember(data) { if (background) { val next = (data.getOrNull(flatIndex + 1)?.totalFocusTime() ?: 0) > 0 diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/HeatmapWithWeekLabels.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/HeatmapWithWeekLabels.kt index 6685ebc..84caaf1 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/HeatmapWithWeekLabels.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/components/HeatmapWithWeekLabels.kt @@ -29,8 +29,10 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyGridState import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid import androidx.compose.foundation.lazy.grid.itemsIndexed +import androidx.compose.foundation.lazy.grid.rememberLazyGridState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CornerSize import androidx.compose.foundation.shape.RoundedCornerShape @@ -83,12 +85,13 @@ fun HeatmapWithWeekLabels( data: List, averageRankList: List, modifier: Modifier = Modifier, + state: LazyGridState = rememberLazyGridState(Int.MAX_VALUE), size: Dp = HEATMAP_CELL_SIZE, gap: Dp = HEATMAP_CELL_GAP, contentPadding: PaddingValues = PaddingValues(), maxValue: Long = remember { data.fastMaxBy { it?.totalFocusTime() ?: 0 }?.totalFocusTime() ?: 0 - }, + } ) { val locale = Locale.getDefault() val shapes = shapes @@ -125,6 +128,7 @@ fun HeatmapWithWeekLabels( } } LazyHorizontalGrid( + state = state, rows = GridCells.Fixed(7), modifier = Modifier .height(size * 7 + gap * 6)