From 1fac1daf6bd3cbdcdc1b00e5933d7e06666bfd2d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 00:49:07 +0000 Subject: [PATCH] Today and My Health: one open section each, the rest folded Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w --- AGENTS.md | 4 ++ app/src/main/assets/i18n/pt-BR.json | 10 ++++ .../com/pulseloop/ui/screens/MyHealthUi.kt | 52 ++++++++++++++++--- .../com/pulseloop/ui/screens/TodayGlance.kt | 35 ------------- .../com/pulseloop/ui/screens/TodayScreen.kt | 35 ++++++++----- 5 files changed, 81 insertions(+), 55 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3a4e61c8..33f98c74 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1111,6 +1111,10 @@ clutter came from ignoring one of them: - **Inside a screen, summary first, detail on tap.** A screen leads with one summary and its primary action; everything else is a row that opens. A new section added inline at full weight is how My Health became a wall. +- **One open section per screen.** Today shows two rows of tiles and folds the rest behind "Show + all metrics"; My Health keeps health areas open and folds Trends, Habits and Stress into + closed sections (`Section(summary = …)`), and the radar to one line unless it flags something. + A new card should usually be a closed section, not another open one. - **Repeat a figure only when the question differs.** Last night's sleep on Today (am I okay?) and on Sleep (why?) is fine; the same sleep three times on Today is not. The alcohol-clearance card on Postpartum stays even though Drinks has one: "can I feed now?" is asked on that screen. diff --git a/app/src/main/assets/i18n/pt-BR.json b/app/src/main/assets/i18n/pt-BR.json index 8e2c8ec5..57f4555d 100644 --- a/app/src/main/assets/i18n/pt-BR.json +++ b/app/src/main/assets/i18n/pt-BR.json @@ -56,6 +56,7 @@ "3 or 4": "3 ou 4", "3-question check": "Verificação de 3 perguntas", "30 g": "30 g", + "30-day averages": "Médias de 30 dias", "4 or more times a week": "4 ou mais vezes por semana", "4 tbsp (100 g)": "4 colheres de sopa (100 g)", "5 or 6": "5 ou 6", @@ -270,6 +271,7 @@ "Breathe": "Respirar", "Breathe in": "Inspire", "Breathe out": "Expire", + "Breathing sessions and how you recover": "Sessões de respiração e como você se recupera", "Breathing sessions this week": "Sessões de respiração nesta semana", "Bring it on": "Manda ver", "Building a picture from your data": "Montando um retrato a partir dos seus dados", @@ -653,6 +655,7 @@ "HRV trending up": "HRV em alta", "HRV usually takes {0} night{1} to come back.": "A HRV geralmente leva {0} noite{1} para se recuperar.", "HRV {0}% {1} your dry nights": "HRV {0}% {1} que nas suas noites sem álcool", + "Habits & routines": "Hábitos e rotinas", "Habits & routines · 30-day averages": "Hábitos e rotinas · médias de 30 dias", "Hard workout": "Treino intenso", "Health Connect": "Health Connect", @@ -1199,12 +1202,14 @@ "Resetting ring…": "Redefinindo o anel…", "Resetting…": "Redefinindo…", "Resilience": "Resiliência", + "Resilience {0}": "Resiliência {0}", "Resilience {0} over {1} days": "Resiliência {0} em {1} dias", "Resources": "Recursos", "Respiratory rate": "Frequência respiratória", "Response format": "Formato da resposta", "Rest": "Descanso", "Rest Mode": "Modo descanso", + "Rest Mode on": "Modo Descanso ativo", "Rest Mode on until {0}": "Modo Descanso ativo até {0}", "Rest days let your body adapt to training. One or two easier days a week is enough for most people.": "Dias de descanso permitem que o corpo se adapte ao treino. Um ou dois dias mais leves por semana bastam para a maioria das pessoas.", "Restfulness": "Tranquilidade", @@ -1304,7 +1309,9 @@ "Show": "Mostrar", "Show ({0})": "Mostrar ({0})", "Show activity records": "Mostrar registros de atividade", + "Show all metrics ({0} more)": "Mostrar todas as métricas (mais {0})", "Show connection details": "Mostrar detalhes da conexão", + "Show fewer": "Mostrar menos", "Show fewer events": "Mostrar menos eventos", "Show key": "Mostrar chave", "Show more events": "Mostrar mais eventos", @@ -1340,6 +1347,7 @@ "Sleep synced": "Sono sincronizado", "Sleep tracking": "Monitoramento do sono", "Sleep {0} a night": "Dormir {0} por noite", + "Sleep, steps, heart and more, from a week to a year": "Sono, passos, coração e mais, de uma semana a um ano", "Sleeping less this week": "Dormindo menos nesta semana", "Sleeping more this week": "Dormindo mais nesta semana", "Slightly below": "Um pouco abaixo", @@ -1736,6 +1744,7 @@ "above": "acima", "any meal": "qualquer refeição", "avg {0} bpm": "média {0} bpm", + "bed {0}": "deitar {0}", "below": "abaixo", "daily calories": "calorias diárias", "daily calories {0} kcal": "calorias diárias {0} kcal", @@ -1770,6 +1779,7 @@ "steps {0} a day": "passos {0} por dia", "unknown error": "erro desconhecido", "up": "a mais", + "up {0}": "acordar {0}", "workout": "treino", "workouts": "treinos", "workouts a week": "treinos por semana", diff --git a/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt b/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt index 7571bd11..f675106c 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt @@ -88,13 +88,37 @@ import kotlin.math.roundToInt */ @Composable -internal fun Section(title: String, content: @Composable ColumnScope.() -> Unit) { +internal fun Section( + title: String, + /** + * Set for a section that starts closed: the card shows its title and this one-line summary, + * and opens in place on tap. Leave null for one that is always open. + */ + summary: String? = null, + content: @Composable ColumnScope.() -> Unit, +) { + var open by androidx.compose.runtime.saveable.rememberSaveable(title) { mutableStateOf(summary == null) } + val collapsible = summary != null Column( Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card).padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp), content = { - Text(title.uppercase(), fontSize = 11.sp, letterSpacing = 1.6.sp, color = PulseColors.textMuted) - content() + if (collapsible) { + Row( + Modifier.fillMaxWidth().heightIn(min = 40.dp).clickable(role = Role.Button) { open = !open }, + verticalAlignment = Alignment.CenterVertically, + ) { + Column(Modifier.weight(1f)) { + Text(title, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + if (!open) Text(summary!!, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + Text(if (open) "⌃" else "⌄", fontSize = 18.sp, color = PulseColors.textMuted) + } + if (open) content() + } else { + Text(title.uppercase(), fontSize = 11.sp, letterSpacing = 1.6.sp, color = PulseColors.textMuted) + content() + } }, ) } @@ -231,7 +255,13 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () @Composable private fun RadarSection(r: SymptomRadar.Result?, restUntil: java.time.LocalDate?, onRest: (Int?) -> Unit) { - Section(tr("Symptom Radar")) { + // Open only when it has something to say; otherwise one line with Rest Mode's state. + val flagged = r != null && r.baselineNights >= SymptomRadar.MIN_BASELINE && r.level != SymptomRadar.Level.NONE + val quiet = when { + r == null || r.baselineNights < SymptomRadar.MIN_BASELINE -> trf("Learning your normal: {0} of {1} nights.", r?.baselineNights ?: 0, SymptomRadar.MIN_BASELINE) + else -> r.level.label + } + if (restUntil != null) " · " + tr("Rest Mode on") else "" + Section(tr("Symptom Radar"), summary = if (flagged) null else quiet) { if (r == null || r.baselineNights < SymptomRadar.MIN_BASELINE) { Text(trf("Learning your normal: {0} of {1} nights.", r?.baselineNights ?: 0, SymptomRadar.MIN_BASELINE), fontSize = 13.sp, color = PulseColors.textSecondary) } else { @@ -287,7 +317,7 @@ internal fun SleepBalanceSection(s: HealthInsightsRepository.SleepBalance) { @Composable private fun StressSection(s: HealthInsightsRepository.Snapshot, onBreathe: () -> Unit) { val context = LocalContext.current - Section(tr("Stress & breathing")) { + Section(tr("Stress & breathing"), summary = s.resilience?.let { trf("Resilience {0}", it.level.label.lowercase()) } ?: tr("Breathing sessions and how you recover")) { s.resilience?.let { Fact(tr("Resilience"), it.level.label, trf("Daytime recovery against stress, and how well nights restore you ({0} days)", it.daysUsed)) } val sessions = remember { MindfulSessions.all(context) } val week = sessions.filter { it.startAt >= System.currentTimeMillis() - 7 * 86_400_000L } @@ -340,7 +370,15 @@ fun HeartRateContextChart(samples: List, sleep: List, wo @Composable private fun HabitsSection(h: HealthInsightsRepository.Habits, cardio: com.pulseloop.service.CardioCapacity?) { - Section(tr("Habits & routines · 30-day averages")) { + Section( + tr("Habits & routines"), + summary = listOfNotNull( + h.bedtime?.let { trf("bed {0}", it) }, + h.wake?.let { trf("up {0}", it) }, + h.steps?.let { trf("{0} steps", "%,d".format(it)) }, + ).joinToString(" · ").ifBlank { tr("30-day averages") }, + ) { + Text(tr("30-day averages"), fontSize = 12.sp, color = PulseColors.textMuted) h.bedtime?.let { Fact(tr("Bedtime"), it) } h.wake?.let { Fact(tr("Wake-up"), it) } h.sleepMin?.let { Fact(tr("Sleep"), SleepFormat.duration(it)) } @@ -371,7 +409,7 @@ private fun TrendsSection(db: PulseLoopDatabase) { val p = period value = TrendLoad(m, p, runCatching { Trends.aggregate(HealthInsightsRepository.daily(db, m, p.days), p) }.getOrNull()) } - Section(tr("Trends")) { + Section(tr("Trends"), summary = tr("Sleep, steps, heart and more, from a week to a year")) { Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).selectableGroup(), horizontalArrangement = Arrangement.spacedBy(6.dp)) { TrendMetric.entries.forEach { m -> val on = m == metric diff --git a/app/src/main/java/com/pulseloop/ui/screens/TodayGlance.kt b/app/src/main/java/com/pulseloop/ui/screens/TodayGlance.kt index eb75f6da..a91bba51 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/TodayGlance.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/TodayGlance.kt @@ -127,41 +127,6 @@ fun TodayGlance( } } -/** Meal · Drink · Measure · Workout — Today's shortcuts; the "+ Log" button holds the rest. */ -@Composable -fun QuickLogRow(onMeal: () -> Unit, onDrink: () -> Unit, onMeasure: () -> Unit, onWorkout: () -> Unit) { - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - QuickChip(tr("Meal"), Icons.Filled.Restaurant, PulseColors.calories, Modifier.weight(1f), onMeal) - QuickChip(tr("Drink"), Icons.Filled.LocalBar, PulseColors.drinks, Modifier.weight(1f), onDrink) - QuickChip(tr("Measure"), Icons.Filled.FavoriteBorder, PulseColors.heartRate, Modifier.weight(1f), onMeasure) - QuickChip(tr("Workout"), Icons.Filled.DirectionsRun, PulseColors.steps, Modifier.weight(1f), onWorkout) - } -} - -@Composable -private fun QuickChip(label: String, icon: ImageVector, tint: Color, modifier: Modifier, onClick: () -> Unit) { - val shape = RoundedCornerShape(8.dp) - Column( - modifier - .clip(shape) - .background(PulseColors.card) - .border(1.dp, PulseColors.borderSubtle, shape) - .clickable(onClick = onClick) - .padding(vertical = 10.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(4.dp), - ) { - Icon(icon, null, Modifier.size(20.dp), tint = tint) - Text( - label, fontSize = 12.sp, color = PulseColors.textPrimary, - // Four equal chips: a long translated label ("Refeição", a voice's rewrite) ellipsises - // inside its quarter rather than clipping mid-letter. - maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier.padding(horizontal = 4.dp), - ) - } -} - /** Morning moment: last night in one card. */ @Composable fun LastNightCard( diff --git a/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt index 2cc2e3ac..224996d9 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt @@ -109,6 +109,7 @@ fun TodayScreen( val vitalsLoaded = vitalsViewModel == null || vitals.loaded val guidance = rememberGuidance(db, listOf(state.lastUpdated, sleep.lastNight?.id, sleep.lastNight?.updatedAt)) var briefSheet by remember { mutableStateOf(false) } + var showAllTiles by androidx.compose.runtime.saveable.rememberSaveable { mutableStateOf(false) } // The "+ Log" sheet is app-wide (PulseLoopApp); Today's shortcuts open it at a step, and // its closing is what refreshes the food and drinks numbers here. val logOpen by com.pulseloop.ui.LaunchRequests.openLog.collectAsState() @@ -271,18 +272,8 @@ fun TodayScreen( ) } - // Act: one tap to log, then at most two cards chosen by the time of day. - item { - QuickLogRow( - onMeal = { openLog(LogStep.MEAL) }, - onDrink = { openLog(LogStep.DRINK) }, - onMeasure = { navController?.navigate("vitals") }, - onWorkout = { - com.pulseloop.ui.LaunchRequests.openWorkoutPicker.value = true - navController?.navigate("activity") - }, - ) - } + // Logging is the "+ Log" button on every tab; a second row of shortcuts here only + // added another band to scroll past. Then at most two cards chosen by the time of day. item { ProgramsRow( db = db, @@ -369,7 +360,10 @@ fun TodayScreen( // No tiles until vitals and sleep have loaded: before that every supports* flag is // false (the HRV/temperature tiles appear later and reflow the grid) and the tiles // say "No sleep recorded" / "No data" for data that is merely still being read. - val rows = if (vitalsLoaded && sleepLoaded) visibleOrdered.chunked(columns) else emptyList() + // Two rows of tiles, the user's first choices, and the rest behind one tap: twelve tiles + // at equal weight turned Today into a wall. Editing shows them all. + val shown = if (editState.editing || showAllTiles) visibleOrdered else visibleOrdered.take(columns * 2) + val rows = if (vitalsLoaded && sleepLoaded) shown.chunked(columns) else emptyList() // Keyed by the cards in the row so a reorder in edit mode moves rows rather than // recomposing every row in place. items(rows.size, key = { rows[it].joinToString("|") { card -> card.name } }) { rowIndex -> @@ -391,6 +385,21 @@ fun TodayScreen( } } + val more = visibleOrdered.size - columns * 2 + if (!editState.editing && more > 0 && vitalsLoaded && sleepLoaded) { + item { + Text( + if (showAllTiles) tr("Show fewer") else trf("Show all metrics ({0} more)", more), + fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, + textAlign = androidx.compose.ui.text.style.TextAlign.Center, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 48.dp) + .clickable(role = Role.Button) { showAllTiles = !showAllTiles } + .wrapContentHeight(Alignment.CenterVertically), + ) + } + } if (editState.editing) { item { HiddenMetricsTray(hiddenCards) { editState.setHidden(it, false) } } }