diff --git a/PRODUCT.md b/PRODUCT.md new file mode 100644 index 00000000..81d53b44 --- /dev/null +++ b/PRODUCT.md @@ -0,0 +1,69 @@ +# Product + + + +## Platform + +android + +## Users + +Mainly the owner and his family, each wearing an inexpensive smart ring (Colmi, R100, SR08, +Ale-Hop and similar). Public users on GitHub are welcome but secondary: they report rings and +bugs, and their reports have shaped much of the ring code. + +They check the app in a hurry, one-handed: in the morning to see how the night went and whether +to push or rest, and in the evening to log the day. The answer has to be on the first screen. + +## Product Purpose + +Give a budget ring Oura-level insight: readiness, sleep, vitals, symptom radar, trends, and a +coach that reads the data. Success is a morning glance that says something true and useful about +the person, without the vendor's app and without a subscription. + +## Positioning + +Oura-level insight from a cheap ring. It works with many inexpensive rings by speaking each +vendor's own protocol, needs no subscription and no account, keeps the data on the phone, is open +source, and says plainly what the ring measured and what the app estimated. + +## Operating Context + +- The ring syncs over Bluetooth about every 30 minutes in the background, and on opening the app. +- Data can also come from Health Connect, and goes out to it and to Strava. +- A coach (the user's own API key, or an on-device model) reads the data and answers questions. +- The owner reviews screens on a Claude Design canvas and in released APKs on his phone. + +## Capabilities and Constraints + +- **English and Brazilian Portuguese** for every string; layouts must survive the longer + Portuguese (owner's confirmation, 2026-11-16). +- **One-handed and glanceable**: the important answer first, detail on tap (owner's + confirmation, 2026-11-16). +- **Never a diagnosis**: estimates are labelled as estimates, nothing names a condition, and + safety text keeps its plain wording (AGENTS.md: lab reports, postpartum, derived stress). +- Ring hardware differs: a metric the app shows must say when this ring doesn't measure it. +- Undecided: whether public users ever become a primary audience. + +## Brand Commitments + +- The name PulseLoop, the mint accent, and Fairy mode (the brand turns pink for Tatá's profile, + never announced). +- The visual system is recorded in `docs/new-look-plan.md` (new look, in progress) and the Gabriel + Design System's `pulseloop` layer (current look). + +## Evidence on Hand + +- Real ring captures and reports in the GitHub issues (#29, #58, #59, #63, #68, #73 and others). +- No testimonials, customer counts or benchmarks exist; don't invent any. + +## Product Principles + +1. The ring's own data, shown honestly: measured and estimated are never confused. +2. The morning answer first; detail on tap. +3. Nothing leaves the phone unless the person sends it. +4. Works with the ring people already own, by matching each vendor's app. + +## Accessibility & Inclusion + +Two languages, TalkBack, and large font scales: no clipped text at 1.3×. 48dp targets. diff --git a/app/src/main/assets/i18n/pt-BR.json b/app/src/main/assets/i18n/pt-BR.json index d5697c7f..5e1e5de6 100644 --- a/app/src/main/assets/i18n/pt-BR.json +++ b/app/src/main/assets/i18n/pt-BR.json @@ -970,6 +970,7 @@ "Learning your dry nights: {0} of {1}. Then PulseLoop shows what each drink does to your sleep.": "Aprendendo suas noites sem álcool: {0} de {1}. Depois o PulseLoop mostra o que cada bebida faz com seu sono.", "Learning your normal": "Aprendendo o seu normal", "Learning your normal: {0} of {1} nights.": "Aprendendo seu normal: {0} de {1} noites.", + "Learning: {0} of {1} nights": "Aprendendo: {0} de {1} noites", "Learns your baseline": "Aprende sua linha de base", "Leave": "Sair", "Leave max tokens blank to let the server decide. Raise the timeout for a large model on CPU — a slow reply is not retried.": "Deixe o máximo de tokens em branco para o servidor decidir. Aumente o tempo limite para um modelo grande em CPU — uma resposta lenta não é repetida.", @@ -1413,6 +1414,7 @@ "Range low": "Faixa mínima", "Raw Packets": "Pacotes brutos", "Re-analyze": "Reanalisar", + "Read more": "Ler mais", "Readiness": "Prontidão", "Readiness is estimated by PulseLoop from your ring's sleep, heart rate, HRV and activity, compared with your own recent nights. It is not a medical measurement.": "A Prontidão é estimada pelo PulseLoop a partir do sono, da frequência cardíaca, da HRV e da atividade medidos pelo anel, comparados com suas próprias noites recentes. Não é uma medida médica.", "Reading (mg/dL)": "Medição (mg/dL)", @@ -1553,7 +1555,7 @@ "Score {0} out of 100": "Pontuação {0} de 100", "Scores are PulseLoop estimates from ring data compared with the user's own baseline, not medical measurements.": "As pontuações são estimativas do PulseLoop a partir dos dados do anel comparados com a linha de base do próprio usuário, não medidas médicas.", "Screens in bed": "Telas na cama", - "Screens that have moved to it so far: Symptom Radar.": "Telas que já usam o novo visual: Radar de sintomas.", + "Screens that have moved to it so far: Today, Symptom Radar.": "Telas que já usam o novo visual: Hoje, Radar de sintomas.", "Searching…": "Procurando…", "See Raw Packets above.": "Veja Pacotes brutos acima.", "See Ring Events above.": "Veja Eventos do anel acima.", @@ -2192,6 +2194,7 @@ "{0} % same stage": "{0} % no mesmo estágio", "{0} (Tailscale)": "{0} (Tailscale)", "{0} / week": "{0} / semana", + "{0} asleep": "{0} dormindo", "{0} asleep · woke {1} times · longest stretch {2}": "{0} dormindo · acordou {1} vezes · maior trecho {2}", "{0} at {1}.": "{0} às {1}.", "{0} awake during the night": "{0} acordado durante a noite", diff --git a/app/src/main/java/com/pulseloop/ui/calm/CalmSparkline.kt b/app/src/main/java/com/pulseloop/ui/calm/CalmSparkline.kt new file mode 100644 index 00000000..ec324849 --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/calm/CalmSparkline.kt @@ -0,0 +1,47 @@ +package com.pulseloop.ui.calm + +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.graphics.StrokeJoin +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.unit.dp + +/** + * A small trend line for a row: the shape of the recent readings, nothing else. No axes and no + * labels, because the value beside it is the number; TalkBack skips it for the same reason. + * Draws nothing below two readings. + */ +@Composable +fun CalmSparkline(values: List, color: Color, modifier: Modifier = Modifier.size(88.dp, 32.dp)) { + // The newest readings only: a day of five-minute samples is more line than 88dp can show. + val points = remember(values) { values.takeLast(MAX_POINTS) } + if (points.size < 2) return + Canvas(modifier.clearAndSetSemantics { }) { + val inset = 4.dp.toPx() + val w = size.width - inset * 2 + val h = size.height - inset * 2 + val min = points.min() + val span = (points.max() - min).takeIf { it > 0 } ?: 1.0 + fun at(i: Int) = Offset( + inset + w * i / (points.size - 1), + inset + h - (h * ((points[i] - min) / span)).toFloat(), + ) + val path = Path().apply { + moveTo(at(0).x, at(0).y) + for (i in 1 until points.size) lineTo(at(i).x, at(i).y) + } + drawPath(path, color.copy(alpha = 0.8f), style = Stroke(width = 2.dp.toPx(), cap = StrokeCap.Round, join = StrokeJoin.Round)) + // The newest reading, so the eye lands where the value beside it comes from. + drawCircle(color, radius = 3.dp.toPx(), center = at(points.size - 1)) + } +} + +private const val MAX_POINTS = 60 diff --git a/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt b/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt index 892599ac..f87fe17a 100644 --- a/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt +++ b/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt @@ -57,8 +57,36 @@ object CalmType { val title = TextStyle(fontFamily = Inter, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, lineHeight = 1.35.em) val body = TextStyle(fontFamily = Inter, fontSize = 16.sp, lineHeight = 1.5.em) val bodySmall = TextStyle(fontFamily = Inter, fontSize = 14.sp, lineHeight = 1.5.em) + /** A screen's one headline number (Today's readiness). 40 is the top of the scale. */ + val score = TextStyle(fontFamily = Inter, fontSize = 40.sp, fontWeight = FontWeight.SemiBold, lineHeight = 1.05.em, letterSpacing = (-0.02).em) val value = TextStyle(fontFamily = Inter, fontSize = 28.sp, fontWeight = FontWeight.SemiBold, lineHeight = 1.1.em) val label = TextStyle(fontFamily = Inter, fontSize = 12.sp, fontWeight = FontWeight.Medium, lineHeight = 1.3.em) /** The small capitals over a card ("RESPIRATORY RATE"). */ val eyebrow = TextStyle(fontFamily = Inter, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 0.08.em, lineHeight = 1.3.em) } + +/** + * Runs [content] with Inter as the text family: Material's whole type scale and the ambient text + * style. A converted screen still reuses some shared pieces (a program chip, the bedtime card); + * inside this scope their text comes out in Inter too, so the screen keeps one family. Text that + * names its own family explicitly (PulseType's styles) is unchanged until its piece is converted. + */ +@androidx.compose.runtime.Composable +fun CalmTypography(content: @androidx.compose.runtime.Composable () -> Unit) { + val t = androidx.compose.material3.MaterialTheme.typography + fun TextStyle.inter() = copy(fontFamily = Inter) + val typography = t.copy( + displayLarge = t.displayLarge.inter(), displayMedium = t.displayMedium.inter(), displaySmall = t.displaySmall.inter(), + headlineLarge = t.headlineLarge.inter(), headlineMedium = t.headlineMedium.inter(), headlineSmall = t.headlineSmall.inter(), + titleLarge = t.titleLarge.inter(), titleMedium = t.titleMedium.inter(), titleSmall = t.titleSmall.inter(), + bodyLarge = t.bodyLarge.inter(), bodyMedium = t.bodyMedium.inter(), bodySmall = t.bodySmall.inter(), + labelLarge = t.labelLarge.inter(), labelMedium = t.labelMedium.inter(), labelSmall = t.labelSmall.inter(), + ) + androidx.compose.material3.MaterialTheme( + colorScheme = androidx.compose.material3.MaterialTheme.colorScheme, + shapes = androidx.compose.material3.MaterialTheme.shapes, + typography = typography, + ) { + androidx.compose.material3.ProvideTextStyle(androidx.compose.material3.LocalTextStyle.current.inter(), content) + } +} diff --git a/app/src/main/java/com/pulseloop/ui/screens/CalmToday.kt b/app/src/main/java/com/pulseloop/ui/screens/CalmToday.kt new file mode 100644 index 00000000..eee26fc6 --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/screens/CalmToday.kt @@ -0,0 +1,330 @@ +package com.pulseloop.ui.screens + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import com.pulseloop.service.Readiness +import com.pulseloop.service.ReadinessCopy +import com.pulseloop.ui.calm.CalmCard +import com.pulseloop.ui.calm.CalmColors +import com.pulseloop.ui.calm.CalmShape +import com.pulseloop.ui.calm.CalmSparkline +import com.pulseloop.ui.calm.CalmType +import com.pulseloop.ui.components.Chevron +import com.pulseloop.ui.components.PulseButton +import com.pulseloop.ui.components.PulseButtonStyle +import com.pulseloop.ui.components.toColor +import com.pulseloop.ui.i18n.tr +import com.pulseloop.ui.i18n.trf + +// Today in the new look (docs/new-look-plan.md, "Today"). Readiness leads as one statement, Sleep +// and Activity follow as the two scores that feed it, and every other card the user kept is one +// row: its name, the value, its verdict and a small trend. Detail is a tap away, as before. + +/** + * Readiness as the screen's statement: the number, its band and the one sentence that explains + * it. Holds its height while loading, so the rows below never jump when it arrives. + */ +@Composable +internal fun CalmReadinessHero(readiness: Readiness.Result?, loaded: Boolean, onOpen: () -> Unit) { + val score = readiness as? Readiness.Result.Score + val (headline, headlineColor) = when (readiness) { + is Readiness.Result.Score -> readiness.band.label to bandColor(readiness.band) + is Readiness.Result.Learning -> trf("Learning: {0} of {1} nights", readiness.nightsCollected, readiness.nightsNeeded) to CalmColors.text + Readiness.Result.NoSleep -> tr("No sleep yet") to CalmColors.text + is Readiness.Result.Withheld -> tr("Not measured") to CalmColors.text + null -> (if (loaded) tr("No data") else " ") to CalmColors.text + } + Column( + Modifier.fillMaxWidth().clip(RoundedCornerShape(CalmShape.radius)) + .clickable(role = Role.Button, onClickLabel = tr("Readiness"), onClick = onOpen) + .padding(vertical = 8.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(tr("Readiness"), style = CalmType.title, color = CalmColors.textSecondary) + Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(12.dp)) { + if (score != null) Text("${score.value}", style = CalmType.score, color = CalmColors.text) + Text( + headline, + style = if (score != null) CalmType.sectionTitle else CalmType.display, + color = headlineColor, + modifier = if (score != null) Modifier.padding(bottom = 4.dp) else Modifier, + ) + } + Text( + readiness?.let { ReadinessCopy.headline(it) } ?: " ", + style = CalmType.body, color = CalmColors.textSecondary, + ) + } +} + +/** One score that feeds readiness: Sleep or Activity, as a row with its number on the right. */ +internal data class CalmScore( + val name: String, + val value: Int?, + val detail: String?, + val loaded: Boolean, + val onOpen: () -> Unit, +) + +/** Sleep and Activity in one card, divided by a hairline: two answers to "why this readiness?". */ +@Composable +internal fun CalmScoresCard(scores: List) { + if (scores.isEmpty()) return + val shape = RoundedCornerShape(CalmShape.radius) + Column( + Modifier.fillMaxWidth().clip(shape).background(CalmColors.card).border(1.dp, CalmColors.border, shape), + ) { + scores.forEachIndexed { i, s -> + if (i > 0) Box(Modifier.fillMaxWidth().padding(horizontal = 20.dp).height(1.dp).background(CalmColors.border)) + CalmScoreRow(s) + } + } +} + +@Composable +private fun CalmScoreRow(s: CalmScore) { + val band = s.value?.let { Readiness.Band.of(it) } + Row( + Modifier.fillMaxWidth().heightIn(min = 72.dp) + .clickable(role = Role.Button, onClick = s.onOpen) + .padding(horizontal = 20.dp, vertical = 16.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp), + ) { + Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) { + Text(s.name, style = CalmType.title, color = CalmColors.text) + val detail = when { + band != null && s.detail != null -> "${band.label} · ${s.detail}" + band != null -> band.label + s.detail != null -> s.detail + s.loaded -> tr("No data") + else -> " " + } + Text(detail, style = CalmType.bodySmall, color = CalmColors.textSecondary, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + Text( + s.value?.toString() ?: if (s.loaded) "—" else "", + style = CalmType.value, + color = band?.let { bandColor(it) } ?: CalmColors.textMuted, + ) + Chevron(tint = CalmColors.textSecondary) + } +} + +/** + * One card the user kept, as a row: name and verdict on top, the value and its recent trend + * underneath. A tap opens the same detail screen the tile did. + */ +@Composable +internal fun CalmTodayRow( + name: String, + accent: Color, + value: String?, + unit: String? = null, + status: String? = null, + statusColor: Color = CalmColors.textSecondary, + note: String? = null, + noteColor: Color = CalmColors.textMuted, + trend: List = emptyList(), + onOpen: () -> Unit, + modifier: Modifier = Modifier, + action: (@Composable () -> Unit)? = null, +) { + CalmCard(modifier, onClick = onOpen) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + // The metric's own colour, as the old tiles had it, so a card is found by colour too. + Box(Modifier.size(8.dp).clip(CircleShape).background(accent)) + Text(name, style = CalmType.bodySmall, color = CalmColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + if (status != null) Text(status, style = CalmType.label, color = statusColor, maxLines = 1) + } + Row(verticalAlignment = Alignment.Bottom) { + Row( + Modifier.weight(1f).semantics(mergeDescendants = true) { }, + verticalAlignment = Alignment.Bottom, + ) { + Text(value ?: "—", style = CalmType.value, color = if (value != null) CalmColors.text else CalmColors.textMuted, maxLines = 1) + if (value != null && unit != null) { + Spacer(Modifier.width(4.dp)) + Text(unit, style = CalmType.bodySmall, color = CalmColors.textSecondary, maxLines = 1, modifier = Modifier.padding(bottom = 3.dp)) + } + } + CalmSparkline(trend, accent) + } + if (note != null) Text(note, style = CalmType.bodySmall, color = noteColor, maxLines = 2, overflow = TextOverflow.Ellipsis) + action?.invoke() + } +} + +/** A quiet in-row action ("+ Log meal"): a text PulseButton, so it keeps its 48dp target. */ +@Composable +internal fun CalmRowAction(label: String, onClick: () -> Unit) { + PulseButton(PulseButtonStyle.Text, onClick = onClick, contentPadding = PaddingValues(horizontal = 0.dp), modifier = Modifier.heightIn(min = 48.dp)) { + Text(label, style = CalmType.title, color = CalmColors.accent) + } +} + +/** The coach's brief (or the unusual-night alert) as one calm block above the scores. */ +@Composable +internal fun CalmGlance(alert: String?, insight: String?, insightPending: Boolean, onAlert: () -> Unit, onInsight: () -> Unit) { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { + if (alert != null) { + CalmCard(onClick = onAlert) { + Text(alert, style = CalmType.body, color = CalmColors.text, maxLines = 3, overflow = TextOverflow.Ellipsis) + } + } + when { + insight != null -> Text( + insight, style = CalmType.body, color = CalmColors.textSecondary, maxLines = 3, overflow = TextOverflow.Ellipsis, + modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(CalmShape.radius)) + .clickable(role = Role.Button, onClickLabel = tr("Read more"), onClick = onInsight) + .semantics { contentDescription = insight }, + ) + // Holds the brief's space while the coach writes it, so nothing below jumps. + insightPending -> Spacer(Modifier.height(48.dp)) + } + } +} + +/** Which row a Today card becomes in the new look, and where a tap on it goes. */ +@Composable +internal fun CalmTodayCardRow( + card: com.pulseloop.ui.dashboard.DashboardCard, + cards: Map, + vitals: com.pulseloop.ui.viewmodels.VitalsViewModel.VitalsState, + sleep: com.pulseloop.ui.viewmodels.SleepViewModel.SleepState, + state: com.pulseloop.ui.viewmodels.TodayViewModel.TodayState, + food: FoodTotals?, + foodLoaded: Boolean, + drinks: com.pulseloop.service.DrinksRepository.Snapshot?, + drinksLoaded: Boolean, + stepFactor: Double?, + units: com.pulseloop.settings.UnitSystem, + open: (String) -> Unit, + onLogMeal: () -> Unit, + onAddDrink: () -> Unit, +) { + val m = Modifier.fillMaxWidth() + @Composable + fun VitalRow(kind: com.pulseloop.service.MetricKind, route: String) { + val c = cards.getValue(kind) + val empty = c.latestValue == null + CalmTodayRow( + name = c.title, + accent = com.pulseloop.ui.components.ZonePalette.accent(c.metric), + value = if (empty) null else c.valueText, + unit = c.unitText, + status = if (empty) null else c.statusText, + statusColor = c.statusToken.toColor(), + // Issue #103 / #67: an estimate says so wherever it is shown. + note = when { + empty -> c.statusText + c.isEstimated -> tr("Estimated from heart rate") + else -> null + }, + noteColor = if (c.isEstimated && !empty) com.pulseloop.ui.theme.PulseColors.warning else CalmColors.textMuted, + trend = c.samples.map { it.value }, + onOpen = { open(route) }, + modifier = m, + ) + } + when (card) { + com.pulseloop.ui.dashboard.DashboardCard.SLEEP -> { + val night = sleep.lastNight + CalmTodayRow( + name = tr("Sleep"), accent = com.pulseloop.ui.theme.PulseColors.sleep, + value = night?.let { com.pulseloop.util.Formats.hoursMinutes(it.totalMinutes) }, + note = if (night == null) tr("No sleep recorded") else null, + onOpen = { open("sleep") }, modifier = m, + ) + } + com.pulseloop.ui.dashboard.DashboardCard.ACTIVITY -> { + val steps = state.steps?.let { s -> stepFactor?.let { (s * it).toInt() } ?: s } + CalmTodayRow( + name = tr("Activity"), accent = com.pulseloop.ui.theme.PulseColors.steps, + value = steps?.let { com.pulseloop.util.Formats.count(it) }, unit = tr("steps"), + trend = state.steps7d.map { it.toDouble() }, + onOpen = { open("activity") }, modifier = m, + ) + } + com.pulseloop.ui.dashboard.DashboardCard.NUTRITION -> { + val goal = food?.goalKcal?.takeIf { it > 0 } + CalmTodayRow( + name = tr("Nutrition"), accent = com.pulseloop.ui.theme.PulseColors.calories, + value = if (foodLoaded) com.pulseloop.util.Formats.count((food?.kcal ?: 0.0).toInt()) else null, + unit = tr("kcal"), + status = goal?.let { trf("of {0}", com.pulseloop.util.Formats.count(it.toInt())) }, + note = when { + !foodLoaded -> null + food != null && food.meals > 0 -> trf("P {0} · C {1} · F {2} g", food.proteinG.toInt(), food.carbsG.toInt(), food.fatG.toInt()) + else -> tr("Nothing logged yet") + }, + onOpen = { open("nutrition") }, modifier = m, + // Today's one-tap meal log stays: taps on a common action never rise. + action = { CalmRowAction(tr("+ Log meal"), onLogMeal) }, + ) + } + com.pulseloop.ui.dashboard.DashboardCard.DRINKS -> { + val week = drinks?.week + val limit = drinks?.weeklyLimit ?: com.pulseloop.service.DrinkPrefs.weeklyLimit + val total = week?.standardDrinks ?: 0.0 + fun std(v: Double) = if (v % 1.0 == 0.0) "${v.toInt()}" else "%.1f".format(v) + CalmTodayRow( + name = tr("Drinks"), accent = com.pulseloop.ui.theme.PulseColors.drinks, + value = if (drinksLoaded) std(total) else null, + status = trf("of {0} this week", std(limit)), + statusColor = if (limit > 0 && total > limit) com.pulseloop.ui.theme.PulseColors.warning else CalmColors.textSecondary, + note = trf("{0} of {1} dry days", week?.dryDays ?: 0, drinks?.dryDaysTarget ?: com.pulseloop.service.DrinkPrefs.dryDaysTarget), + onOpen = { open("drinks") }, modifier = m, + action = { CalmRowAction("+ ${com.pulseloop.service.DrinkPrefs.lastType.label}", onAddDrink) }, + ) + } + com.pulseloop.ui.dashboard.DashboardCard.HEART_RATE -> VitalRow(com.pulseloop.service.MetricKind.HEART_RATE, "vitals/hr") + com.pulseloop.ui.dashboard.DashboardCard.SPO2 -> VitalRow(com.pulseloop.service.MetricKind.SPO2, "vitals/spo2") + com.pulseloop.ui.dashboard.DashboardCard.HRV -> VitalRow(com.pulseloop.service.MetricKind.HRV, "vitals/hrv") + com.pulseloop.ui.dashboard.DashboardCard.TEMPERATURE -> VitalRow(com.pulseloop.service.MetricKind.TEMPERATURE, "vitals/temp") + com.pulseloop.ui.dashboard.DashboardCard.STRESS -> VitalRow(com.pulseloop.service.MetricKind.STRESS, "vitals/stress") + com.pulseloop.ui.dashboard.DashboardCard.FATIGUE -> VitalRow(com.pulseloop.service.MetricKind.FATIGUE, "vitals/fatigue") + com.pulseloop.ui.dashboard.DashboardCard.GLUCOSE -> VitalRow(com.pulseloop.service.MetricKind.GLUCOSE, "vitals/glucose") + com.pulseloop.ui.dashboard.DashboardCard.BLOOD_PRESSURE -> { + val c = cards.getValue(com.pulseloop.service.MetricKind.BLOOD_PRESSURE) + val sys = vitals.bpSystolic + val dia = vitals.bpDiastolic + CalmTodayRow( + name = c.title, accent = com.pulseloop.ui.theme.PulseColors.bloodPressure, + value = if (sys != null && dia != null) "$sys/$dia" else null, + unit = c.unitText, + status = if (sys != null && dia != null) c.statusText else null, + statusColor = c.statusToken.toColor(), + note = if (sys == null || dia == null) tr("No reading") else null, + trend = c.samples.map { it.value }, + onOpen = { open("vitals/bp") }, modifier = m, + ) + } + } +} diff --git a/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt index c019736c..42ae76ce 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt @@ -218,7 +218,7 @@ fun DebugScreen(viewModel: DiagnosticsViewModel, onBack: () -> Unit = {}) { ) { Column(Modifier.weight(1f)) { Text(tr("Try the new look"), style = MaterialTheme.typography.bodyMedium) - Text(tr("Screens that have moved to it so far: Symptom Radar."), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) + Text(tr("Screens that have moved to it so far: Today, Symptom Radar."), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) } Switch(checked = com.pulseloop.ui.calm.NewLook.on, onCheckedChange = null) } 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 c308d75b..89ff8973 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt @@ -5,6 +5,7 @@ import com.pulseloop.ui.i18n.trf import com.pulseloop.ui.i18n.tr import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.ui.draw.clip import com.pulseloop.ui.theme.dither @@ -219,7 +220,134 @@ fun TodayScreen( } Box(Modifier.fillMaxSize().pullRefresh(pullRefreshState)) { - androidx.compose.foundation.lazy.LazyColumn( + if (com.pulseloop.ui.calm.NewLook.on) com.pulseloop.ui.calm.CalmTypography { androidx.compose.foundation.lazy.LazyColumn( + // The new look (docs/new-look-plan.md, "Today"): one statement, its two scores, then one + // row per card. Content caps at 720dp on wide windows, like the tab content elsewhere. + modifier = Modifier.fillMaxSize().background(com.pulseloop.ui.calm.CalmColors.page) + .wrapContentWidth().widthIn(max = 720.dp).fillMaxWidth(), + contentPadding = PaddingValues( + start = com.pulseloop.ui.calm.CalmShape.gutter, end = com.pulseloop.ui.calm.CalmShape.gutter, + top = 16.dp + topBarPadding, bottom = 16.dp + bottomBarPadding, + ), + verticalArrangement = Arrangement.spacedBy(12.dp), + ) { + item { CalmReadinessHero(readiness, readinessLoad.loaded) { navController?.navigate("readiness") } } + item { + val alert = guidance?.offSignals?.takeIf { com.pulseloop.service.VitalsCheck.shouldAlert(it) } + val summary = state.coachSummary + CalmGlance( + alert = alert?.let { tr("Unusual last night: ") + it.joinToString(", ") { s -> s.title.lowercase() } }, + insight = if (coachEnabled && summary != null) listOf(summary.title, summary.body).filter { it.isNotBlank() }.joinToString(". ") + else if (readinessLoad.loaded && readiness == null) hero.summary else null, + insightPending = coachEnabled && summary == null && !readinessLoad.loaded, + onAlert = { navController?.navigate("readiness") }, + onInsight = { briefSheet = true }, + ) + } + // Sleep and Activity are the scores readiness is built from, so they sit right under it + // instead of in the list. Customize cards still decides whether each one shows; while + // editing they join the list below, so they can be hidden like any other card. + if (!editState.editing) item { + val stepsNow = state.steps?.let { s -> stepFactor?.let { (s * it).toInt() } ?: s } + CalmScoresCard(buildList { + if (DashboardCard.SLEEP in visibleOrdered) add(CalmScore( + name = tr("Sleep"), + value = sleep.score?.score ?: sleep.lastNight?.score, + detail = sleep.lastNight?.let { trf("{0} asleep", Formats.hoursMinutes(it.totalMinutes)) }, + loaded = sleepLoaded, + onOpen = { navController?.navigate("sleep") }, + )) + if (DashboardCard.ACTIVITY in visibleOrdered) add(CalmScore( + name = tr("Activity"), + value = activityScore?.value, + detail = stepsNow?.let { (if (stepFactor != null) "≈ " else "") + trf("{0} steps", Formats.count(it)) }, + loaded = activityLoad.loaded, + onOpen = { navController?.navigate("activity_score") }, + )) + }) + } + accuracyOpen?.let { c -> item { AccuracyCheckBanner(c) { navController?.navigate("settings/accuracy-check") } } } + item { DetectedActivityLine { navController?.navigate("activity") { launchSingleTop = true } } } + item { + ProgramsRow( + db = db, + onCycle = { navController?.navigate("cycle") }, + onMeds = { navController?.navigate("meds") }, + onPostpartum = { navController?.navigate("postpartum") }, + ) + } + item { + val unusual = guidance?.offSignals?.let { com.pulseloop.service.VitalsCheck.shouldAlert(it) } == true + RestModeLine(offerIt = unusual) + } + // Time-of-day cards: the evening ones still earn their place. Last night's card only + // shows to add what the Sleep row can't (what last night's drinks did to the night). + TodayMoments.at( + hour = java.time.LocalTime.now().hour, + hasSleep = sleep.lastNight != null && drinks?.morningAfter != null, + mealsToday = if (DashboardCard.NUTRITION in visibleOrdered) -1 else mealsToday ?: -1, + hasBedtime = guidance?.bedtime != null, + ).forEach { moment -> + when (moment) { + TodayMoments.Moment.LAST_NIGHT -> sleep.lastNight?.let { night -> + item { + LastNightCard( + durationText = Formats.hoursMinutes(night.totalMinutes), + score = sleep.score?.score ?: night.score, + window = null, + onOpen = { navController?.navigate("sleep") }, + drinksLine = drinks?.morningAfter?.let { com.pulseloop.service.DrinksRepository.morningAfterLine(it) }, + onDrinks = { navController?.navigate("drinks") }, + drinksOnly = true, + ) + } + } + TodayMoments.Moment.FOOD -> item { + FoodCard(db = db, burned = state.calories, onOpen = { navController?.navigate("nutrition") }, onLog = { start -> navController?.navigate("nutrition/$start") }) + } + TodayMoments.Moment.TONIGHT -> guidance?.let { g -> g.bedtime?.let { b -> item { TonightCard(b, g.sleepGoalMinutes) } } } + TodayMoments.Moment.TAG_DAY -> item { + JournalTagsCard( + db, java.time.LocalDate.now(), tr("Tag your day"), + tags = com.pulseloop.service.JournalInsights.Tag.entries.take(6), + allowYesterday = true, + ) { + Text( + tr("See what affects you"), + style = com.pulseloop.ui.calm.CalmType.title, color = com.pulseloop.ui.calm.CalmColors.accent, + modifier = Modifier.heightIn(min = 48.dp).clickable(role = Role.Button) { navController?.navigate("journal") } + .wrapContentHeight(Alignment.CenterVertically), + ) + } + } + } + } + // One row per card the user kept, in their order. Same loading rule as the grid: no + // rows until vitals and sleep have loaded, so nothing reads "No data" while it's read. + val listed = if (vitalsLoaded && sleepLoaded) visibleOrdered.filter { + editState.editing || (it != DashboardCard.SLEEP && it != DashboardCard.ACTIVITY) + } else emptyList() + items(listed.size, key = { listed[it].name }) { i -> + val card = listed[i] + EditableCard(editState, card, Modifier.fillMaxWidth()) { + CalmTodayCardRow(card, cards, vitals, sleep, state, food, foodLoaded, drinks, drinksLoaded, stepFactor, units, + open = { route -> navController?.navigate(route) }, + onLogMeal = { openLog(LogStep.MEAL) }, + onAddDrink = { + scope.launch { + com.pulseloop.service.DrinksRepository.log(db, com.pulseloop.service.DrinkPrefs.lastType) + drinkTick++ + } + }, + ) + } + } + if (editState.editing) { + item { HiddenMetricsTray(hiddenCards) { editState.setHidden(it, false) } } + } + item { CustomizeCardsFooter(editState) } + item { Spacer(Modifier.height(64.dp)) } + } } else androidx.compose.foundation.lazy.LazyColumn( modifier = Modifier.fillMaxSize(), contentPadding = PaddingValues( start = 16.dp, end = 16.dp, @@ -759,8 +887,15 @@ private fun DetectedActivityLine(onOpen: () -> Unit) { .format(java.time.format.DateTimeFormatter.ofPattern(if (is24) "EEE HH:mm" else "EEE h:mm a")) } Row( - Modifier.fillMaxWidth().heightIn(min = 48.dp).clip(androidx.compose.foundation.shape.RoundedCornerShape(8.dp)) - .background(PulseColors.card).clickable(role = Role.Button, onClickLabel = tr("Review"), onClick = onOpen) + Modifier.fillMaxWidth().heightIn(min = 48.dp) + .then( + if (com.pulseloop.ui.calm.NewLook.on) { + val shape = androidx.compose.foundation.shape.RoundedCornerShape(com.pulseloop.ui.calm.CalmShape.radius) + Modifier.clip(shape).background(com.pulseloop.ui.calm.CalmColors.card) + .border(1.dp, com.pulseloop.ui.calm.CalmColors.border, shape) + } else Modifier.clip(androidx.compose.foundation.shape.RoundedCornerShape(8.dp)).background(PulseColors.card), + ) + .clickable(role = Role.Button, onClickLabel = tr("Review"), onClick = onOpen) .padding(horizontal = 16.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp), diff --git a/audits/2026-11-16-new-look-today.md b/audits/2026-11-16-new-look-today.md new file mode 100644 index 00000000..4b701c41 --- /dev/null +++ b/audits/2026-11-16-new-look-today.md @@ -0,0 +1,123 @@ +# Audit: Today in the new look (2.16.7) + +Date: 2026-11-16 · PR: see the PR linking this file · Auditor: Claude Code. impeccable was run with +the skill loaded (context, `audit.native.md`, `critique.md`, `craft-floor.md`, `android.md`, +`init.md`, `new-work.md`); ux-user-flows, graphic-design-fundamentals and less-is-more were applied +by hand from their SKILL.md files. + +## Scope + +Today, behind Debug → New look (off by default). The owner chose an Oura-style restructure over a +restyle (2026-11-16): readiness as the lead statement, Sleep and Activity as two score rows under +it, and every other card as a single-column row with a small trend line. Context work done first: +`PRODUCT.md` written with the owner (impeccable init: users, positioning, constraints). + +## ux-user-flows (§13 flow review checklist) + +Flow: open app → Today: read readiness (statement + sentence) → [why?] Sleep / Activity row → +detail screen; or scan the rows → tap one → its detail; log a meal / drink from its row; Customize +cards → edit the list → Done. + +| # | Question | Result | +|---|---|---| +| 1 | Job | "Am I ready today, and is anything off?" in one glance, then the why. | +| 2 | Entries | App launch and the Today tab; unchanged. | +| 3 | Happy path | The answer is the first thing read, no tap. | +| 4 | Branches | Score / learning / no sleep / not measured / loading; coach on or off; alert or not; edit mode. | +| 5 | States | Loading holds the hero's height and shows no rows until vitals and sleep have loaded (no "No data" flash); empty rows say why ("No reading", "Nothing logged yet"). | +| 6 | Errors | Readiness failure reads "No data"; rows fall back to their own empty text. | +| 7 | Control | Pull to refresh, Customize cards, and every row opens its detail. | +| 8 | Progress and resume | Learning shows "Learning: n of 14 nights". | +| 9 | Memory | Card order and hidden cards from Customize, unchanged. | +| 10 | Exits | Tabs and the header, unchanged. | +| 11 | Conventions | Rows match Symptom Radar's cards; Oura's order the owner asked for. | +| 12 | Speed | Same loads as before; no new queries. | +| 13 | Accessibility | Rows are buttons; value and unit merge; sparkline hidden from TalkBack; band word beside every coloured number. | +| 14 | Ethics | Estimates keep their label (#103, #67); readiness copy unchanged. | +| 15 | Evidence | The owner's choice in this session and the Oura screenshot that started the redesign. | + +Issues: polish — while editing, Sleep and Activity move from the top card into the list so they +can be hidden; the preview differs from the result for those two (NL-5). Their position in the +Customize order no longer applies outside editing. + +## impeccable + +### Audit (native, from source; no emulator in this environment) + +| # | Dimension | Score | Key finding | +|---|---|---|---| +| 1 | Accessibility | 3 | Targets ≥48dp, colour never alone. Device check at font scale 1.3 and TalkBack is owed. | +| 2 | Performance | 4 | LazyColumn with stable keys; sparklines capped at 60 points; no extra reads. | +| 3 | Appearance & theming | 3 | New tokens throughout the new rows; reused pieces still old-styled (NL-4). | +| 4 | Platform conformance | 4 | Pull-to-refresh, system Back in edit mode, Material buttons underneath. | +| 5 | Adaptivity | 4 | Single column caps at 720dp, centred; no grid to stretch. | +| | **Total** | **18/20** | | + +### Critique (design review only; detector not applicable, native platform) + +| # | Heuristic | Score | Key issue | +|---|---|---|---| +| 1 | Visibility of status | 4 | Readiness, its band and its reason lead the screen. | +| 2 | Match real world | 3 | "Learning: 3 of 14 nights" says what the app waits for. | +| 3 | User control | 3 | Customize cards kept; Sleep/Activity order fixed at the top. | +| 4 | Consistency | 2 | Reused old-styled pieces sit between new rows (NL-4). | +| 5 | Error prevention | 3 | Loading never shows "No data" for data still being read. | +| 6 | Recognition | 4 | Each row keeps its metric's colour dot and name. | +| 7 | Flexibility | 3 | One-tap logging stays on its rows. | +| 8 | Minimalist | 3 | Score rings and tile chrome gone; the list is longer to scroll (owner's trade). | +| 9 | Error recovery | 3 | Empty rows name what's missing. | +| 10 | Help | 3 | The readiness sentence explains the number. | +| | **Total** | **31/40** | Good | + +Design specificity: the lead is this product's own answer (readiness built from sleep and +activity, shown in that order), not a generic dashboard. Priority issues: [P2] NL-4 old-styled +pieces inside the new Today, to convert with their own screens; [P3] NL-5 edit-mode preview. +No P0 or P1. + +## graphic-design-fundamentals (§13 checklist) + +| # | Question | Result | +|---|---|---| +| 1 | Brief | One statement first, its causes second, everything else as rows. | +| 2 | Concept | Oura's order in the new look: number, word, reason. | +| 3 | Hierarchy | 40sp number → 20sp band word → 16sp sentence → 28sp row values. | +| 4 | Contrast | Same tokens as Symptom Radar (text 17.3:1, secondary 7.0:1, muted 5.3:1 on card). | +| 5 | Alignment and grid | One 20dp gutter; every row left-aligned to it. | +| 6 | Spacing | 12dp between rows; rows pad 20dp. | +| 7 | Typography | Inter only on the tab (`CalmTypography`); sizes on the scale. | +| 8 | Colour | Mint only on the in-row log actions; band and zone colours for meaning, with words. | +| 9 | Consistency | Rows reuse Symptom Radar's card. Fails for the old-styled pieces (NL-4). | +| 10 | Simplicity | Three rings and nine tile designs become one row pattern. | +| 11 | Real-size test | pt-BR "Aprendendo: 3 de 14 noites" wraps under the 32sp style; row names ellipsise. | +| 12 | Accessibility and ergonomics | 48dp targets; the lead needs no tap. | +| 13 | Production | No new assets; one 40sp style added to the calm scale. | + +## less-is-more + +| Element | Question (1–5) | Kept / moved / merged / removed, and where | +|---|---|---| +| Three score rings | 4 (weak for the goal) | Merged: readiness is the statement, the other two are rows. | +| Sleep and Activity tiles | 2 (duplicate) | Merged into the score rows; not repeated in the list. | +| Last night card | 2 (duplicate) | Only when it adds last night's drinks, as before. | +| Tile eyebrows (caps labels) | 4 | Removed: sentence-case names. | +| "+ Log meal" / "+ drink" | 1 (helps now) | Kept on their rows. | + +| Dimension | 0–4 | +|---|---| +| Elements per screen, compared with before | Fewer kinds of element; more rows to scroll | +| Duplicates left | 0 | +| Text to read when tired | 4 | +| Taps on the common actions (must not rise) | Unchanged: log meal 1, add drink 1, readiness 1, sleep 1 | + +## Evidence + +- pt-BR missing-key check: none missing. +- No device or emulator here: on-device check (dark, font scale 1.3, TalkBack, pt-BR) owed on the + release build. +- Design canvas: not reachable from this session (the canvas tools disconnected); see the PR. + +## Verdict + +Merge (behind the switch). Carried forward: NL-3 tab ↔ timeline selection (radar), NL-4 old-styled +pieces inside the new Today, NL-5 edit-mode preview of Sleep/Activity, the Today board on the +canvas, the on-device check. diff --git a/docs/new-look-plan.md b/docs/new-look-plan.md index 53dbb988..ed62c56e 100644 --- a/docs/new-look-plan.md +++ b/docs/new-look-plan.md @@ -53,3 +53,21 @@ couldn't reach that repo, so it is recorded here until it is moved there. biometrics under strain, and "Recently": the last 35 days as a timeline (`SymptomRadar.history`, computed as of each day, so a day never reads nights after it). With the new look on, My Health shows one row that opens it instead of the inline section. +- **Today** (`ui/screens/CalmToday.kt`, wired in `TodayScreen` behind the switch). The owner chose + an Oura-style restructure (2026-11-16), not a restyle of the grid: + - Readiness leads as one statement: the number (`CalmType.score`, 40sp), its band and the + sentence that explains it. Tap opens Readiness. + - Sleep and Activity follow as two score rows in one card (number coloured by band, the band's + word beside it, so colour is never the only signal). Customize cards still decides whether + each shows; while editing they join the list below so they can be hidden. + - The coach's brief or the unusual-night alert, then the one-line pieces (detected workout, + programs, Rest Mode) and the evening cards, as before. + - Every other card is one full-width row: name and verdict, the value, and a small trend line + (`CalmSparkline`, the last 60 readings, hidden from TalkBack because the value says it). + Nutrition and Drinks keep their one-tap "+ Log meal" / "+ drink" so no common action gains + a tap. Estimates keep their "Estimated from heart rate" note. + - `CalmTypography` gives the whole tab Inter, including the shared pieces not yet converted. + +Still in the old style inside the new Today (convert with their own screens): the program chips, +Rest Mode line, bedtime, food and tag cards, the accuracy-check banner and the Customize controls. +