diff --git a/AGENTS.md b/AGENTS.md index 9ee1e4cc..5b7a0ad6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1481,6 +1481,21 @@ serving, AI-estimate source); changing a number marks it `userEdited`, as a barc - **The window theme is dark** (`Theme.PulseLoop`), so cold start doesn't flash white, and predictive Back is on (`enableOnBackInvokedCallback`). +## The new look: behind a switch, one screen at a time + +**Read this before restyling a screen.** Plan and tokens: `docs/new-look-plan.md`. The owner chose +(2026-11-16) a calmer, shadcn-style look for PulseLoop only: dark only, mint kept, Inter. + +- **Its tokens and components are in `ui/calm/`.** A converted screen uses `CalmColors`, + `CalmType`, `CalmShape` and the `Calm*` components, never `PulseColors` greys or literal sizes. + Sizes stay on `PulseType.SCALE`, buttons are still `PulseButton`, text still goes through `tr()`. +- **`NewLook.on` decides, per screen.** Off by default until every screen has moved; then the + default flips and the old styling is deleted in one PR. Don't flip it early. +- **A state over time is a `StateTimeline`**, not a new chart. Its layout is `StateTimelineModel`, + which is pure and tested. +- **It departs from the design system on purpose.** Record that in the design-system repo's + `docs/divergences.md` when a session can reach it. + ## Motion: one transition, a small vocabulary - **Every navigation destination goes through `DitherTransitionBox`** (`theme/DitherTransition.kt`), diff --git a/app/src/main/assets/i18n/pt-BR.json b/app/src/main/assets/i18n/pt-BR.json index dc7b0d65..d5697c7f 100644 --- a/app/src/main/assets/i18n/pt-BR.json +++ b/app/src/main/assets/i18n/pt-BR.json @@ -286,6 +286,7 @@ "Below the typical resting range. Often fine, but worth noting if you feel faint.": "Abaixo da faixa típica em repouso. Geralmente tudo bem, mas vale atenção se você sentir tontura.", "Beta-blockers": "Betabloqueadores", "Beta-blockers lower heart rate; this is expected on that medication.": "Betabloqueadores reduzem a frequência cardíaca; isso é esperado com esse medicamento.", + "Biometrics under strain": "Biometria sob esforço", "Blood": "Sangue", "Blood Oxygen": "Oxigênio no sangue", "Blood Pressure": "Pressão arterial", @@ -631,6 +632,7 @@ "Enable Coach Check-Ins?": "Ativar check-ins do Coach?", "Enable Nutrition Tracking": "Ativar registro de nutrição", "Enable the AI Coach to change these — daily check-ins are written by the coach from your recent trends.": "Ative o Coach de IA para alterar isso — os check-ins diários são escritos pelo coach com base nas suas tendências recentes.", + "End Rest Mode": "Encerrar modo descanso", "End must be after the start.": "O fim deve ser depois do início.", "End now": "Encerrar agora", "End session": "Encerrar sessão", @@ -721,6 +723,7 @@ "Fell asleep": "Adormeceu", "Female": "Feminino", "Fever of 38 °C or higher": "Febre de 38 °C ou mais", + "Fewer steps": "Menos passos", "Fewer steps than usual": "Menos passos que o normal", "Filter models": "Filtrar modelos", "Filter, e.g. claude": "Filtrar, ex.: claude", @@ -839,6 +842,7 @@ "High fatigue": "Fadiga alta", "High fatigue score. Wellness estimate from the ring.": "Pontuação de fadiga alta. Estimativa de bem-estar do anel.", "High stress score. Wellness estimate, not a diagnosis.": "Pontuação de estresse alta. Estimativa de bem-estar, não um diagnóstico.", + "Higher": "Mais alto", "Higher risk": "Risco maior", "Hiking": "Trilha", "Hormones": "Hormônios", @@ -964,6 +968,7 @@ "Learning you · {0} of {1} nights": "Conhecendo você · {0} de {1} noites", "Learning your baseline: {0} of {1} nights. Keep wearing your ring to bed.": "Aprendendo sua linha de base: {0} de {1} noites. Continue dormindo com o anel.", "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.", "Learns your baseline": "Aprende sua linha de base", "Leave": "Sair", @@ -1027,6 +1032,7 @@ "Low fatigue — well recovered.": "Fadiga baixa — bem recuperado.", "Low stress score — relaxed.": "Estresse baixo — relaxado.", "Low systolic pressure (below 90).": "Pressão sistólica baixa (abaixo de 90).", + "Lower": "Mais baixo", "Lower is calmer": "Quanto menor, mais calmo", "Lower risk": "Risco menor", "Lowest heart rate {0} before waking": "Frequência cardíaca mais baixa {0} antes de acordar", @@ -1127,6 +1133,7 @@ "Never mind": "Deixa pra lá", "New chat": "Nova conversa", "New lab report": "Novo laudo", + "New look": "Novo visual", "Next": "Próximo", "Next day": "Próximo dia", "Next period around {0} (in {1} day{2}), from your usual {3}-day cycle.": "Próxima menstruação por volta de {0} (em {1} dia{2}), com base no seu ciclo habitual de {3} dias.", @@ -1167,6 +1174,7 @@ "No fatigue data yet — take a measurement.": "Ainda não há dados de fadiga — faça uma medição.", "No goal set · {0} is a typical day": "Sem meta definida · {0} é um dia típico", "No meals logged this week": "Nenhuma refeição registrada nesta semana", + "No night to read": "Nenhuma noite para ler", "No nights tracked in this range yet.": "Nenhuma noite registrada neste período ainda.", "No obvious signs in your biometrics of something straining your body.": "Nenhum sinal claro nos seus dados biométricos de algo sobrecarregando seu corpo.", "No other app wrote readable data in the last {0} days.": "Nenhum outro app gravou dados legíveis nos últimos {0} dias.", @@ -1230,6 +1238,7 @@ "Not this": "Não é isso", "Not yet": "Ainda não", "Notably below your typical HRV — often linked to stress, poor sleep, or strain.": "Bem abaixo da sua HRV habitual — muitas vezes ligado a estresse, sono ruim ou sobrecarga.", + "Nothing is outside your usual range.": "Nada está fora da sua faixa normal.", "Nothing logged on this day.": "Nada registrado neste dia.", "Nothing logged today yet.": "Nada registrado hoje ainda.", "Nothing logged yet": "Nada registrado ainda", @@ -1414,6 +1423,7 @@ "Ready to start the day? Take a measurement and I'll help you plan it.": "Pronto para começar o dia? Faça uma medição e eu ajudo você a planejá-lo.", "Ready · {0}": "Pronto · {0}", "Reasoning effort": "Nível de raciocínio", + "Recently": "Recentemente", "Recommended": "Recomendado", "Recompute": "Recalcular", "Reconnect last ring": "Reconectar último anel", @@ -1543,6 +1553,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.", "Searching…": "Procurando…", "See Raw Packets above.": "Veja Pacotes brutos acima.", "See Ring Events above.": "Veja Eventos do anel acima.", @@ -1593,6 +1604,8 @@ "Show fewer": "Mostrar menos", "Show fewer events": "Mostrar menos eventos", "Show key": "Mostrar chave", + "Show less": "Mostrar menos", + "Show more": "Mostrar mais", "Show more events": "Mostrar mais eventos", "Show phone-calibrated steps on Today": "Mostrar passos calibrados pelo celular em Hoje", "Show readings": "Mostrar leituras", @@ -1787,6 +1800,9 @@ "The model isn't available to download right now. Try again later.": "O modelo não está disponível para download agora. Tente mais tarde.", "The next record starts at {0}.": "O próximo registro começa às {0}.", "The previous record ends at {0}.": "O registro anterior termina às {0}.", + "The radar compares each night with your own usual. It starts after {0} nights; it has {1} so far.": "O radar compara cada noite com o seu normal. Ele começa depois de {0} noites; até agora tem {1}.", + "The radar compares last night's temperature, resting heart rate, heart rate variability, breathing and the day's activity with your own usual over the past four weeks. Several moving the wrong way together is what it looks for.": "O radar compara a temperatura, a frequência cardíaca em repouso, a variabilidade da frequência cardíaca e a respiração da última noite, e a atividade do dia, com o seu normal das últimas quatro semanas. Ele procura vários deles mudando na direção errada ao mesmo tempo.", + "The radar reads a night of sleep from your ring. Wear it to bed and it will have one.": "O radar lê uma noite de sono do seu anel. Durma com ele e ela vai aparecer aqui.", "The report covers the days so far. You'll then choose what happens to the paused Health Connect export.": "O relatório abrange os dias até agora. Depois você escolherá o que acontece com a exportação pausada para o Health Connect.", "The report printed no range for this marker.": "O laudo não trouxe faixa de referência para este marcador.", "The ring didn't come back. Keep it near the phone and try again.": "O anel não voltou. Deixe-o perto do celular e tente de novo.", @@ -1868,11 +1884,13 @@ "Trim this record, or extend it over time the ring missed. Added time counts as asleep but has no stage, so it stays out of the stage breakdown and score.": "Recorte este registro ou estenda-o sobre o tempo que o anel não registrou. O tempo adicionado conta como sono, mas não tem fase, então fica fora da divisão por fases e da pontuação.", "Trouble breathing, chest pain or a racing heart": "Falta de ar, dor no peito ou coração acelerado", "Try again": "Tentar novamente", + "Try the new look": "Experimentar o novo visual", "Turn off": "Desativar", "Turn off Drinks": "Desativar Bebidas", "Turn off Drinks?": "Desativar Bebidas?", "Turn on": "Ativar", "Turn on Bluetooth to find and connect your ring.": "Ative o Bluetooth para encontrar e conectar seu anel.", + "Turn on Rest Mode": "Ativar modo descanso", "Two hours after against two hours before, over {0} sessions. Readings during a session aren't counted: slow breathing raises HRV while it lasts.": "Duas horas depois comparadas com duas horas antes, em {0} sessões. Leituras durante a sessão não contam: a respiração lenta eleva a HRV enquanto dura.", "Two-hour 140–199 is above the typical range.": "Duas horas após: 140–199 está acima da faixa típica.", "Two-hour post-meal normal is up to 140 mg/dL.": "O normal duas horas após a refeição é até 140 mg/dL.", @@ -2257,6 +2275,8 @@ "{0} workouts a week": "{0} treinos por semana", "{0} years": "{0} anos", "{0} {1} in the last 7 days": "{0} {1} nos últimos 7 dias", + "{0} {1}, higher than your usual {2}": "{0} {1}, acima do seu normal de {2}", + "{0} {1}, lower than your usual {2}": "{0} {1}, abaixo do seu normal de {2}", "{0} · ring {1} · {2} {3}": "{0} · anel {1} · {2} {3}", "{0} · the lab's range is {1}": "{0} · a faixa do laboratório é {1}", "{0} · {1}": "{0} · {1}", diff --git a/app/src/main/assets/licenses/inter-ofl.txt b/app/src/main/assets/licenses/inter-ofl.txt new file mode 100644 index 00000000..9b2ca37b --- /dev/null +++ b/app/src/main/assets/licenses/inter-ofl.txt @@ -0,0 +1,92 @@ +Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION AND CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/src/main/java/com/pulseloop/PulseLoopApplication.kt b/app/src/main/java/com/pulseloop/PulseLoopApplication.kt index f1b7d03c..0890ac32 100644 --- a/app/src/main/java/com/pulseloop/PulseLoopApplication.kt +++ b/app/src/main/java/com/pulseloop/PulseLoopApplication.kt @@ -31,6 +31,7 @@ class PulseLoopApplication : Application() { // so a Bedtime flag left on under a switched-off schedule is cleared rather than reread. com.pulseloop.settings.QuietHoursPrefs.migrateIndependentBedtime(this) com.pulseloop.service.DrinkPrefs.init(this) + com.pulseloop.ui.calm.NewLook.load(this) com.pulseloop.service.Postpartum.init(this) com.pulseloop.service.LabPrefs.init(this) com.pulseloop.ui.theme.FairyMode.init(this) diff --git a/app/src/main/java/com/pulseloop/service/HealthInsights.kt b/app/src/main/java/com/pulseloop/service/HealthInsights.kt index d0b58be6..f2bb6034 100644 --- a/app/src/main/java/com/pulseloop/service/HealthInsights.kt +++ b/app/src/main/java/com/pulseloop/service/HealthInsights.kt @@ -182,6 +182,17 @@ object SymptomRadar { } } + /** + * The radar for each of the last [days] days, oldest first, by running [compute] as of each + * day: the "Recently" timeline. A day with no night recorded is absent, not "no signs". + * Pure: the nights already carry everything [compute] reads. + */ + fun history(nights: List, today: LocalDate, days: Int): List> = + (days - 1 downTo 0).mapNotNull { back -> + val d = today.minusDays(back.toLong()) + compute(nights, d)?.let { d to it } + } + /** Today's radar: "major" only when the night before also showed signs. */ fun compute(nights: List, today: LocalDate): Result? { val sorted = nights.sortedBy { it.day } diff --git a/app/src/main/java/com/pulseloop/service/HealthInsightsRepository.kt b/app/src/main/java/com/pulseloop/service/HealthInsightsRepository.kt index 83026579..4856e24e 100644 --- a/app/src/main/java/com/pulseloop/service/HealthInsightsRepository.kt +++ b/app/src/main/java/com/pulseloop/service/HealthInsightsRepository.kt @@ -130,9 +130,13 @@ object HealthInsightsRepository { val workoutWindows: List, /** Today's cardio load against the user's quiet waking HR; null until 3 days of data. */ val cardioLoad: CardioLoad.Result? = null, + /** The radar as of each recent day, oldest first: the "Recently" timeline. */ + val radarHistory: List> = emptyList(), ) private const val DAY = 86_400_000L + /** Five weeks, as the timeline shows. */ + const val RADAR_HISTORY_DAYS = 35 suspend fun load(db: PulseLoopDatabase, now: Long = System.currentTimeMillis(), zone: ZoneId = ZoneId.systemDefault()): Snapshot { val inputs = ReadinessRepository.loadInputs(db, now, zone) @@ -159,6 +163,7 @@ object HealthInsightsRepository { ) } val radar = SymptomRadar.compute(radarNights, today) + val radarHistory = SymptomRadar.history(radarNights, today, RADAR_HISTORY_DAYS) // Stress: today's daytime readings, and 14 days for resilience. val stressRows = db.measurementDao().rangeReal(MeasurementKind.STRESS.name, start(today.minusDays(14)), now) @@ -253,7 +258,7 @@ object HealthInsightsRepository { CardioLoad.compute(hr29, { t -> nightRanges.any { t in it } }, today, zone, profile?.age) }.getOrNull() - return Snapshot(nights, need, debt, radar, todayStress, resilience, bodyClock, cardio, areas, habits, hrToday, sleepWindows, workoutWindows, cardioLoad) + return Snapshot(nights, need, debt, radar, todayStress, resilience, bodyClock, cardio, areas, habits, hrToday, sleepWindows, workoutWindows, cardioLoad, radarHistory) } /** Sleep need, debt and body clock: what the Sleep tab shows under last night. */ diff --git a/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt b/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt index 5491de4d..3a63ff4b 100644 --- a/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt +++ b/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt @@ -901,6 +901,7 @@ fun PulseLoopApp() { onBack = { navController.popBackStack() }, onBreathe = { navController.navigate("breathe") }, onWhatChanged = { navController.navigate("what_changed") }, + onRadar = { navController.navigate("radar") }, onCycle = { navController.navigate("cycle") }, onMeds = { navController.navigate("meds") }, onPostpartum = { navController.navigate("postpartum") }, @@ -940,6 +941,9 @@ fun PulseLoopApp() { paddedComposable("cycle") { com.pulseloop.ui.screens.CycleScreen(onBack = { navController.popBackStack() }) } + paddedComposable("radar") { + com.pulseloop.ui.screens.SymptomRadarScreen(onBack = { navController.popBackStack() }) + } paddedComposable("what_changed") { com.pulseloop.ui.screens.WhatChangedScreen(onBack = { navController.popBackStack() }) } diff --git a/app/src/main/java/com/pulseloop/ui/calm/CalmComponents.kt b/app/src/main/java/com/pulseloop/ui/calm/CalmComponents.kt new file mode 100644 index 00000000..08907f3c --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/calm/CalmComponents.kt @@ -0,0 +1,195 @@ +package com.pulseloop.ui.calm + +import androidx.compose.animation.animateContentSize +import androidx.compose.foundation.BorderStroke +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.ColumnScope +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.selection.selectable +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.KeyboardArrowDown +import androidx.compose.material.icons.filled.KeyboardArrowUp +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +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.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import com.pulseloop.ui.components.Chevron +import com.pulseloop.ui.components.PulseButton +import com.pulseloop.ui.components.PulseButtonStyle +import com.pulseloop.ui.i18n.tr + +/** A pushed screen's bar in the new look: back arrow, an Inter title, optional actions. */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun CalmTopBar(title: String, onBack: () -> Unit, actions: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit = {}) { + CenterAlignedTopAppBar( + title = { Text(title, style = CalmType.title, color = CalmColors.text, maxLines = 1, overflow = TextOverflow.Ellipsis) }, + navigationIcon = { + IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = tr("Back"), tint = CalmColors.text) } + }, + actions = actions, + colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = CalmColors.page), + ) +} + +/** A card: the slightly lighter surface with one hairline border, nothing else. */ +@Composable +fun CalmCard(modifier: Modifier = Modifier, onClick: (() -> Unit)? = null, content: @Composable ColumnScope.() -> Unit) { + val shape = RoundedCornerShape(CalmShape.radius) + Column( + modifier + .fillMaxWidth() + .clip(shape) + .background(CalmColors.card) + .border(1.dp, CalmColors.border, shape) + .then(if (onClick != null) Modifier.clickable(role = Role.Button, onClick = onClick) else Modifier) + .padding(20.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + content = content, + ) +} + +/** A section: room above, a title, then its content. */ +@Composable +fun CalmSection(title: String, modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) { + Column(modifier.fillMaxWidth().padding(top = CalmShape.sectionGap), verticalArrangement = Arrangement.spacedBy(16.dp)) { + Text(title, style = CalmType.sectionTitle, color = CalmColors.text) + content() + } +} + +/** Text that shows [collapsedLines] lines and a "Show more" link, so an explanation never pushes the screen down. */ +@Composable +fun ExpandableText(text: String, collapsedLines: Int = 3, modifier: Modifier = Modifier) { + var expanded by rememberSaveable(text) { mutableStateOf(false) } + var overflows by remember(text) { mutableStateOf(false) } + Column(modifier.animateContentSize(), verticalArrangement = Arrangement.spacedBy(12.dp)) { + Text( + text, style = CalmType.body, color = CalmColors.textSecondary, + maxLines = if (expanded) Int.MAX_VALUE else collapsedLines, + overflow = TextOverflow.Ellipsis, + onTextLayout = { if (!expanded) overflows = it.hasVisualOverflow }, + ) + if (overflows || expanded) { + Row( + Modifier.heightIn(min = 48.dp).clickable(role = Role.Button) { expanded = !expanded }, + verticalAlignment = Alignment.CenterVertically, + ) { + Text(if (expanded) tr("Show less") else tr("Show more"), style = CalmType.title, color = CalmColors.text) + Spacer(Modifier.width(4.dp)) + Icon(if (expanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown, null, tint = CalmColors.text, modifier = Modifier.size(20.dp)) + } + } + } +} + +/** Text tabs with an underline under the selected one ("Yesterday · Today"). */ +@Composable +fun UnderlineTabs(items: List, selected: Int, onSelect: (Int) -> Unit, modifier: Modifier = Modifier) { + Row(modifier.fillMaxWidth()) { + items.forEachIndexed { i, label -> + val on = i == selected + Column( + Modifier.weight(1f).heightIn(min = 48.dp) + .selectable(selected = on, role = Role.Tab, onClick = { onSelect(i) }), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Bottom, + ) { + Text(label, style = CalmType.title, color = if (on) CalmColors.text else CalmColors.textMuted, modifier = Modifier.padding(bottom = 10.dp)) + Box(Modifier.fillMaxWidth(0.6f).height(2.dp).background(if (on) CalmColors.text else Color.Transparent)) + } + } + } +} + +/** + * A scale of states with the current one marked, like "No signs · Minor signs · Major signs": + * every option is visible, so the user sees where they sit and what the others would be. + */ +@Composable +fun LevelScale(names: List, colors: List, current: Int, modifier: Modifier = Modifier) { + Row(modifier.fillMaxWidth()) { + names.forEachIndexed { i, name -> + val on = i == current + Column(Modifier.weight(1f), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(10.dp)) { + Box(Modifier.size(44.dp), contentAlignment = Alignment.Center) { + if (on) Box(Modifier.size(44.dp).clip(CircleShape).background(colors[i].copy(alpha = 0.25f))) + Box(Modifier.size(if (on) 28.dp else 24.dp).clip(CircleShape).background(if (on) colors[i] else colors[i].copy(alpha = 0.45f))) + } + Text(name, style = CalmType.bodySmall, color = if (on) CalmColors.text else CalmColors.textMuted, textAlign = TextAlign.Center) + } + } + } +} + +/** A small rounded label, for a state on a row ("Higher"). */ +@Composable +fun CalmBadge(text: String, modifier: Modifier = Modifier) { + Text( + text, style = CalmType.label, color = CalmColors.text, + modifier = modifier.clip(RoundedCornerShape(8.dp)).background(CalmColors.cardRaised).padding(horizontal = 10.dp, vertical = 6.dp), + ) +} + +/** One metric on a card: a small-caps name, the value large, a badge and an optional arrow. */ +@Composable +fun CalmMetricRow(name: String, value: String, unit: String, badge: String?, detail: String? = null, onClick: (() -> Unit)? = null) { + CalmCard(onClick = onClick) { + Text(name.uppercase(), style = CalmType.eyebrow, color = CalmColors.textSecondary) + Row(verticalAlignment = Alignment.CenterVertically) { + Row(Modifier.weight(1f), verticalAlignment = Alignment.Bottom) { + Text(value, style = CalmType.value, color = CalmColors.text) + if (unit.isNotEmpty()) Text(" $unit", style = CalmType.bodySmall, color = CalmColors.textSecondary, modifier = Modifier.padding(bottom = 3.dp)) + } + if (badge != null) CalmBadge(badge) + if (onClick != null) { Spacer(Modifier.width(8.dp)); Chevron(tint = CalmColors.textSecondary) } + } + if (detail != null) Text(detail, style = CalmType.bodySmall, color = CalmColors.textMuted) + } +} + +/** + * The new look's secondary action: a [PulseButton] (so its height and press rules hold) with the + * card radius and the hairline border, instead of Material's pill and mint outline. + */ +@Composable +fun CalmOutlinedButton(text: String, onClick: () -> Unit, modifier: Modifier = Modifier) { + PulseButton( + PulseButtonStyle.Outlined, onClick = onClick, modifier = modifier.fillMaxWidth(), + shape = RoundedCornerShape(CalmShape.radius), + border = BorderStroke(1.dp, CalmColors.border), + colors = ButtonDefaults.outlinedButtonColors(contentColor = CalmColors.text), + ) { Text(text, style = CalmType.title) } +} diff --git a/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt b/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt new file mode 100644 index 00000000..892599ac --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/calm/CalmTheme.kt @@ -0,0 +1,64 @@ +package com.pulseloop.ui.calm + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.em +import androidx.compose.ui.unit.sp +import com.pulseloop.R +import com.pulseloop.ui.theme.PulseColors + +/** + * The new look's tokens: shadcn's dark neutrals (near-black page, a slightly lighter card, one + * hairline border, two greys of secondary text), Inter, one 12dp radius and wide gaps. Mint stays + * the one accent, read from [PulseColors] so Fairy mode still turns it pink. + * + * PulseLoop-only, by the owner's choice (2026-11-16): it departs from the Gabriel Design System's + * pulseloop layer (Ubuntu Mono, 8dp radius, dither) on purpose. The departure is recorded in + * docs/new-look-plan.md, and moves to the design-system repo's divergences list. + */ +object CalmColors { + val page = Color(0xFF0A0A0B) + val card = Color(0xFF161618) + val cardRaised = Color(0xFF1E1E21) + val border = Color(0xFF27272A) + val text = Color(0xFFFAFAFA) + /** Secondary text: 7.0:1 on [card]. */ + val textSecondary = Color(0xFFA1A1AA) + /** Tertiary text: 5.3:1 on [card] (4.9:1 on [cardRaised]), so it still carries meaning at 12sp. */ + val textMuted = Color(0xFF8B8B94) + val accent: Color get() = PulseColors.accent + val onAccent: Color get() = PulseColors.onAccent +} + +object CalmShape { + val radius = 12.dp + val gutter = 20.dp + /** Between sections: the room that lets one idea end before the next starts. */ + val sectionGap = 40.dp +} + +/** Inter in four weights. */ +val Inter = FontFamily( + Font(R.font.inter_regular, FontWeight.Normal), + Font(R.font.inter_medium, FontWeight.Medium), + Font(R.font.inter_semibold, FontWeight.SemiBold), + Font(R.font.inter_bold, FontWeight.Bold), +) + +/** Sizes stay on PulseType.SCALE (PulseTypeScaleTest). */ +object CalmType { + /** The one statement a screen leads with ("Minor signs"). */ + val display = TextStyle(fontFamily = Inter, fontSize = 32.sp, fontWeight = FontWeight.SemiBold, lineHeight = 1.15.em, letterSpacing = (-0.02).em) + val sectionTitle = TextStyle(fontFamily = Inter, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, lineHeight = 1.3.em, letterSpacing = (-0.01).em) + 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) + 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) +} diff --git a/app/src/main/java/com/pulseloop/ui/calm/NewLook.kt b/app/src/main/java/com/pulseloop/ui/calm/NewLook.kt new file mode 100644 index 00000000..e73c8219 --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/calm/NewLook.kt @@ -0,0 +1,30 @@ +package com.pulseloop.ui.calm + +import android.content.Context +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue + +/** + * The switch between the current look and the new calmer one (docs/new-look-plan.md). Screens + * move over one per release; until every screen has, the new look is off by default and turned + * on from the Debug screen. It is a display preference about this phone, not the user's data, so + * it stays out of the backup archive. + */ +object NewLook { + private const val PREFS = "new_look" + private const val KEY = "on" + + /** Compose state, so flipping it redraws every screen that reads it. */ + var on by mutableStateOf(false) + private set + + fun load(c: Context) { + on = c.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean(KEY, false) + } + + fun set(c: Context, value: Boolean) { + c.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY, value).apply() + on = value + } +} diff --git a/app/src/main/java/com/pulseloop/ui/calm/StateTimeline.kt b/app/src/main/java/com/pulseloop/ui/calm/StateTimeline.kt new file mode 100644 index 00000000..e095f83e --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/calm/StateTimeline.kt @@ -0,0 +1,199 @@ +package com.pulseloop.ui.calm + +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.gestures.detectHorizontalDragGestures +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.CornerRadius +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.PathEffect +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.semantics.CustomAccessibilityAction +import androidx.compose.ui.semantics.LiveRegionMode +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.customActions +import androidx.compose.ui.semantics.liveRegion +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.drawText +import androidx.compose.ui.text.rememberTextMeasurer +import androidx.compose.ui.unit.dp +import com.pulseloop.ui.i18n.tr +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +/** + * The run-and-step layout behind [StateTimeline], kept pure so it can be tested: consecutive days + * at the same level join into one run, a day with no value breaks a run, and two runs that touch + * are joined by a step. + */ +object StateTimelineModel { + /** Days [start]..[end] (inclusive indices) all at [level]. */ + data class Run(val level: Int, val start: Int, val end: Int) + + fun runs(levels: List): List { + val out = mutableListOf() + var i = 0 + while (i < levels.size) { + val l = levels[i] + if (l == null) { i++; continue } + var j = i + while (j + 1 < levels.size && levels[j + 1] == l) j++ + out += Run(l, i, j) + i = j + 1 + } + return out + } + + /** Pairs of runs that touch (no empty day between), where the line steps up or down. */ + fun steps(runs: List): List> = + runs.zipWithNext().filter { (a, b) -> b.start == a.end + 1 && a.level != b.level } + + /** The last day with a value: where the selection starts. */ + fun lastIndex(levels: List): Int = levels.indexOfLast { it != null } +} + +/** + * A state over time, one lane per level, like a symptom or readiness history: each day sits on + * its level, runs of the same level join into a bar, a change of level is drawn as a step, and a + * tapped day shows its date and level above the chart. + * + * [days] and [levels] line up, oldest first; a null level is a day with nothing to show. + * [levelNames] and [levelColors] are indexed by level, lowest first (drawn at the bottom). + */ +@Composable +fun StateTimeline( + days: List, + levels: List, + levelNames: List, + levelColors: List, + selectedLabel: (LocalDate, String) -> String, + modifier: Modifier = Modifier, +) { + val measurer = rememberTextMeasurer() + var selected by remember(levels) { mutableIntStateOf(StateTimelineModel.lastIndex(levels)) } + val runs = remember(levels) { StateTimelineModel.runs(levels) } + val steps = remember(runs) { StateTimelineModel.steps(runs) } + val tickFmt = remember { DateTimeFormatter.ofPattern("d MMM") } + val labelStyle = CalmType.label.copy(color = CalmColors.textSecondary) + val tooltipStyle = CalmType.label.copy(color = CalmColors.page) + val tickStyle = CalmType.label.copy(color = CalmColors.textMuted) + val summary = levelNames.indices.joinToString(", ") { l -> "${levels.count { it == l }} ${levelNames[l]}" } + val description = if (selected in days.indices && levels.getOrNull(selected) != null) + summary + ". " + selectedLabel(days[selected], levelNames[levels[selected]!!]) else summary + // The label column fits the longest level name at the user's font size, so a longer + // translation or a larger font never runs off the edge. + val density = LocalDensity.current + val labelColPx = remember(levelNames, density) { + levelNames.maxOfOrNull { measurer.measure(it, labelStyle).size.width }?.toFloat()?.plus(with(density) { 12.dp.toPx() }) ?: 0f + } + val withValue = remember(levels) { levels.indices.filter { levels[it] != null } } + /** The day with a value nearest to [x] across the chart. */ + fun dayAt(x: Float, width: Float): Int? { + val step = (width - labelColPx) / days.size.coerceAtLeast(1) + val i = (x / step).toInt().coerceIn(0, (days.size - 1).coerceAtLeast(0)) + return withValue.minByOrNull { kotlin.math.abs(it - i) } + } + fun move(by: Int): Boolean { + val pos = withValue.indexOf(selected) + val next = withValue.getOrNull(pos + by) ?: return false + selected = next + return true + } + + Box( + modifier + .fillMaxWidth() + .height((48 + 56 * levelNames.size + 28).dp) + // A day is a few dp wide, so TalkBack steps through them with actions instead. + .semantics { + contentDescription = description + liveRegion = LiveRegionMode.Polite + customActions = listOf( + CustomAccessibilityAction(tr("Previous day")) { move(-1) }, + CustomAccessibilityAction(tr("Next day")) { move(1) }, + ) + }, + ) { + Canvas( + Modifier.fillMaxWidth().height((48 + 56 * levelNames.size + 28).dp) + .pointerInput(levels, labelColPx) { + // Snap to the nearest day that has a value, so a tap never selects nothing. + detectTapGestures { pos -> dayAt(pos.x, size.width.toFloat())?.let { selected = it } } + } + .pointerInput(levels, labelColPx) { + // Days are narrow: sliding a finger along the chart is the reliable way to pick one. + detectHorizontalDragGestures { change, _ -> + dayAt(change.position.x, size.width.toFloat())?.let { selected = it } + } + }, + ) { + if (days.isEmpty()) return@Canvas + val top = 48.dp.toPx() + val laneH = 56.dp.toPx() + val chartW = size.width - labelColPx + val step = chartW / days.size + val bar = 10.dp.toPx() + fun x(i: Int) = step * i + step / 2 + fun y(level: Int) = top + laneH * (levelNames.size - 1 - level) + laneH / 2 + + // Lanes: a hairline and the level's name at the right edge. + levelNames.forEachIndexed { l, name -> + val ly = y(l) + laneH / 2 + drawLine(CalmColors.border, Offset(0f, ly), Offset(chartW, ly), strokeWidth = 1.dp.toPx()) + val t = measurer.measure(name, labelStyle) + drawText(t, topLeft = Offset(chartW + 8.dp.toPx(), y(l) - t.size.height / 2f)) + } + // Steps first, so the bars sit on top of them. + steps.forEach { (a, b) -> + val sx = (x(a.end) + x(b.start)) / 2 + drawLine(CalmColors.cardRaised, Offset(sx, y(a.level)), Offset(sx, y(b.level)), strokeWidth = bar * 0.6f, cap = StrokeCap.Round) + } + runs.forEach { r -> + val left = x(r.start) - step / 2 + 1.dp.toPx() + val right = x(r.end) + step / 2 - 1.dp.toPx() + drawRoundRect( + color = levelColors[r.level], + topLeft = Offset(left, y(r.level) - bar / 2), + size = Size((right - left).coerceAtLeast(bar), bar), + cornerRadius = CornerRadius(bar / 2, bar / 2), + ) + } + // Weekly date ticks, newest at the right. + for (i in days.indices.reversed() step 7) { + val t = measurer.measure(days[i].format(tickFmt), tickStyle) + val tx = (x(i) - t.size.width / 2f).coerceIn(0f, chartW - t.size.width) + drawText(t, topLeft = Offset(tx, top + laneH * levelNames.size + 8.dp.toPx())) + } + // The selected day: a guide line, a dot on its level and the date above. + val sl = levels.getOrNull(selected) + if (sl != null) { + val sx = x(selected) + drawLine( + CalmColors.textSecondary, Offset(sx, top - 6.dp.toPx()), Offset(sx, top + laneH * levelNames.size), + strokeWidth = 1.dp.toPx(), pathEffect = PathEffect.dashPathEffect(floatArrayOf(3.dp.toPx(), 3.dp.toPx())), + ) + drawCircle(CalmColors.page, radius = bar, center = Offset(sx, y(sl))) + drawCircle(levelColors[sl], radius = bar * 0.7f, center = Offset(sx, y(sl))) + val t = measurer.measure(selectedLabel(days[selected], levelNames[sl]), tooltipStyle) + val padH = 12.dp.toPx(); val padV = 6.dp.toPx() + val w = t.size.width + padH * 2; val h = t.size.height + padV * 2 + val left = (sx - w / 2).coerceIn(0f, size.width - w) + drawRoundRect(CalmColors.text, Offset(left, 0f), Size(w, h), CornerRadius(h / 2, h / 2)) + drawText(t, topLeft = Offset(left + padH, padV)) + } + } + } +} 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 12a0c5d7..c019736c 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt @@ -207,6 +207,24 @@ fun DebugScreen(viewModel: DiagnosticsViewModel, onBack: () -> Unit = {}) { } } + // ── New look ──────────────────────────────────────────────── + // Off until every screen has moved over (docs/new-look-plan.md). + item { + val ctx = LocalContext.current + DebugCard(tr("New look")) { + Row( + Modifier.switchRow(checked = com.pulseloop.ui.calm.NewLook.on, onCheckedChange = { com.pulseloop.ui.calm.NewLook.set(ctx, it) }), + verticalAlignment = Alignment.CenterVertically, + ) { + 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) + } + Switch(checked = com.pulseloop.ui.calm.NewLook.on, onCheckedChange = null) + } + } + } + // ── App Info ──────────────────────────────────────────────── item { DebugCard(tr("App Info")) { 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 38b90ee6..b0b14e46 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt @@ -189,7 +189,7 @@ private fun Sparkline(values: List, color: Color, modifier: Modifier = M @OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class) @Composable -fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () -> Unit = {}, onCycle: () -> Unit = {}, onMeds: () -> Unit = {}, onPostpartum: () -> Unit = {}, onLabReports: () -> Unit = {}) { +fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () -> Unit = {}, onRadar: () -> Unit = {}, onCycle: () -> Unit = {}, onMeds: () -> Unit = {}, onPostpartum: () -> Unit = {}, onLabReports: () -> Unit = {}) { val context = LocalContext.current val db = remember { PulseLoopDatabase.getInstance(context) } var refresh by remember { mutableIntStateOf(0) } @@ -252,7 +252,9 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () // Programs (cycle, meds, postpartum) live on Today and in "+ Log" now, and the // day's sleep, heart and stress detail on their own tabs. item { - RadarSection(s.radar, restUntil) { days -> + // The new look gives the radar its own screen; this row is its door. + if (com.pulseloop.ui.calm.NewLook.on) RadarEntryRow(s.radar, restUntil, onRadar) + else RadarSection(s.radar, restUntil) { days -> RestMode.set(context, days); restUntil = RestMode.until(context) } } @@ -292,6 +294,24 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () @Composable private fun MyHealthLink(title: String, subtitle: String, onClick: () -> Unit) = MyHealthEntryCard(title, subtitle, onClick) +@Composable +private fun RadarEntryRow(r: SymptomRadar.Result?, restUntil: java.time.LocalDate?, onOpen: () -> Unit) { + val line = 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 "" + Row( + Modifier.fillMaxWidth().heightIn(min = 56.dp).clickable(role = androidx.compose.ui.semantics.Role.Button, onClick = onOpen).padding(vertical = 8.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Column(Modifier.weight(1f)) { + Text(tr("Symptom Radar"), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(line, fontSize = 14.sp, color = PulseColors.textSecondary) + } + com.pulseloop.ui.components.Chevron() + } +} + @Composable private fun RadarSection(r: SymptomRadar.Result?, restUntil: java.time.LocalDate?, onRest: (Int?) -> Unit) { // Open only when it has something to say; otherwise one line with Rest Mode's state. diff --git a/app/src/main/java/com/pulseloop/ui/screens/SymptomRadarScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/SymptomRadarScreen.kt new file mode 100644 index 00000000..9f578854 --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/screens/SymptomRadarScreen.kt @@ -0,0 +1,224 @@ +package com.pulseloop.ui.screens + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +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.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.produceState +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp +import com.pulseloop.data.PulseLoopDatabase +import com.pulseloop.service.HealthInsightsRepository +import com.pulseloop.service.RestMode +import com.pulseloop.service.SymptomRadar +import com.pulseloop.ui.calm.CalmBadge +import com.pulseloop.ui.calm.CalmCard +import com.pulseloop.ui.calm.CalmColors +import com.pulseloop.ui.calm.CalmOutlinedButton +import com.pulseloop.ui.calm.CalmSection +import com.pulseloop.ui.calm.CalmShape +import com.pulseloop.ui.calm.CalmTopBar +import com.pulseloop.ui.calm.CalmType +import com.pulseloop.ui.calm.ExpandableText +import com.pulseloop.ui.calm.LevelScale +import com.pulseloop.ui.calm.StateTimeline +import com.pulseloop.ui.calm.UnderlineTabs +import com.pulseloop.ui.components.PulseButton +import com.pulseloop.ui.components.PulseButtonStyle +import com.pulseloop.ui.i18n.tr +import com.pulseloop.ui.i18n.trf +import com.pulseloop.ui.theme.PulseColors +import java.time.LocalDate +import java.time.format.DateTimeFormatter +import kotlinx.coroutines.delay + +/** + * Symptom Radar on its own screen, the first in the new look: one statement, the scale it sits + * on, what is under strain, and how the last five weeks went. Opened from My Health. + */ +@Composable +fun SymptomRadarScreen(onBack: () -> Unit) { + val context = LocalContext.current + val db = remember { PulseLoopDatabase.getInstance(context) } + var refresh by remember { mutableIntStateOf(0) } + var loadFailed by remember { mutableStateOf(false) } + val snap by produceState(null, refresh) { + loadFailed = false + value = runCatching { HealthInsightsRepository.load(db) }.onFailure { loadFailed = true }.getOrNull() + } + var restUntil by remember { mutableStateOf(RestMode.until(context)) } + // 1 = Today, 0 = Yesterday. + var tab by rememberSaveable { mutableIntStateOf(1) } + + Column(Modifier.fillMaxSize().background(CalmColors.page)) { + CalmTopBar(tr("Symptom Radar"), onBack) + LazyColumn( + // Tab content caps at 720dp on wide windows, as the rest of the app does. + Modifier.fillMaxSize().wrapContentWidth().widthIn(max = 720.dp).fillMaxWidth(), + contentPadding = PaddingValues(start = CalmShape.gutter, end = CalmShape.gutter, bottom = 48.dp), + ) { + val s = snap + if (s == null) { + item { + if (loadFailed) { + Column(Modifier.padding(top = 24.dp)) { + Text(tr("Couldn't load your health history."), style = CalmType.body, color = CalmColors.text) + PulseButton(PulseButtonStyle.Text, onClick = { refresh++ }) { Text(tr("Try again")) } + } + } else { + // Only after a moment, so a quick read doesn't flash a line before the screen. + var slow by remember { mutableStateOf(false) } + LaunchedEffect(Unit) { delay(400); slow = true } + if (slow) Text(tr("Reading your history…"), style = CalmType.bodySmall, color = CalmColors.textMuted, modifier = Modifier.padding(top = 24.dp)) + } + } + return@LazyColumn + } + val today = LocalDate.now() + val result = if (tab == 1) s.radar else s.radarHistory.firstOrNull { it.first == today.minusDays(1) }?.second + // No night that day is not the same as a short baseline: say which it is. + val noNight = result == null + val learning = noNight || result!!.baselineNights < SymptomRadar.MIN_BASELINE + + item { UnderlineTabs(listOf(tr("Yesterday"), tr("Today")), tab, { tab = it }, Modifier.padding(bottom = 24.dp)) } + + if (noNight) { + item { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { + Text(tr("No night to read"), style = CalmType.display, color = CalmColors.text) + Text(tr("The radar reads a night of sleep from your ring. Wear it to bed and it will have one."), style = CalmType.body, color = CalmColors.textSecondary) + } + } + } else if (learning) { + item { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { + Text(tr("Learning your normal"), style = CalmType.display, color = CalmColors.text) + Text( + trf("The radar compares each night with your own usual. It starts after {0} nights; it has {1} so far.", + SymptomRadar.MIN_BASELINE, result!!.baselineNights), + style = CalmType.body, color = CalmColors.textSecondary, + ) + } + } + } else { + val r = result!! + item { + Column(verticalArrangement = Arrangement.spacedBy(16.dp)) { + Text(r.level.label, style = CalmType.display, color = CalmColors.text) + ExpandableText( + r.level.summary + " " + tr("The radar compares last night's temperature, resting heart rate, heart rate variability, breathing and the day's activity with your own usual over the past four weeks. Several moving the wrong way together is what it looks for."), + collapsedLines = 2, + ) + Spacer(Modifier.height(8.dp)) + LevelScale(SymptomRadar.Level.entries.map { it.label }, LEVEL_COLORS, r.level.ordinal) + } + } + } + + item { + Column(Modifier.padding(top = 32.dp)) { + RestModeAction(restUntil) { days -> RestMode.set(context, days); restUntil = RestMode.until(context) } + } + } + + if (!learning) { + val r = result!! + val flagged = r.flagged + item { + CalmSection(tr("Biometrics under strain")) { + if (flagged.isEmpty()) { + Text(tr("Nothing is outside your usual range."), style = CalmType.body, color = CalmColors.textSecondary) + } else flagged.forEach { sig -> + CalmCard { + Row(verticalAlignment = Alignment.CenterVertically) { + Text(sig.metric.title, style = CalmType.title, color = CalmColors.text, modifier = Modifier.weight(1f)) + CalmBadge(signalBadge(sig)) + } + Text(signalDetail(sig), style = CalmType.bodySmall, color = CalmColors.textSecondary) + } + } + } + } + } + + if (s.radarHistory.any { it.second.baselineNights >= SymptomRadar.MIN_BASELINE }) item { + CalmSection(tr("Recently")) { + val days = (SYMPTOM_HISTORY_DAYS - 1 downTo 0).map { today.minusDays(it.toLong()) } + val byDay = s.radarHistory.filter { it.second.baselineNights >= SymptomRadar.MIN_BASELINE }.toMap() + val fmt = remember { DateTimeFormatter.ofPattern("EEE d MMM") } + StateTimeline( + days = days, + levels = days.map { byDay[it]?.level?.ordinal }, + levelNames = SymptomRadar.Level.entries.map { it.label }, + levelColors = LEVEL_COLORS, + selectedLabel = { d, name -> "${d.format(fmt)} · $name" }, + modifier = Modifier.fillMaxWidth(), + ) + } + } + + item { + Text( + tr("Not a diagnosis. Rest, fluids and an easier day help; see a doctor if you feel unwell."), + style = CalmType.bodySmall, color = CalmColors.textMuted, + modifier = Modifier.padding(top = CalmShape.sectionGap), + ) + } + } + } +} + +private const val SYMPTOM_HISTORY_DAYS = HealthInsightsRepository.RADAR_HISTORY_DAYS + +private val LEVEL_COLORS get() = listOf(PulseColors.info, PulseColors.warning, PulseColors.danger) + +@Composable +private fun RestModeAction(restUntil: LocalDate?, onRest: (Int?) -> Unit) { + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { + CalmOutlinedButton(if (restUntil != null) tr("End Rest Mode") else tr("Turn on Rest Mode"), onClick = { onRest(if (restUntil != null) null else 3) }) + Text( + restUntil?.let { trf("On until {0}: activity nudges paused, the coach eases off.", it.format(DateTimeFormatter.ofPattern("EEE d MMM"))) } + ?: tr("Feeling unwell? Pause activity nudges for 3 days."), + style = CalmType.bodySmall, color = CalmColors.textMuted, + ) + } +} + +/** + * "Inactivity" flags fewer steps, so a plain "Lower" beside it would read as less inactive: + * the badge names the direction of the measured value. + */ +private fun signalBadge(sig: SymptomRadar.Signal): String = when { + sig.metric == SymptomRadar.Metric.INACTIVE -> tr("Fewer steps") + sig.value > sig.usual -> tr("Higher") + else -> tr("Lower") +} + +/** The value against the usual, in the app's language (Signal.detail is English-only). */ +private fun signalDetail(sig: SymptomRadar.Signal): String { + val steps = sig.metric == SymptomRadar.Metric.INACTIVE + fun fmt(v: Double) = if (steps) "%,d".format(kotlin.math.round(v).toInt()) else "%.1f".format(v) + val unit = if (steps) tr("steps") else sig.metric.unit + return if (sig.value > sig.usual) trf("{0} {1}, higher than your usual {2}", fmt(sig.value), unit, fmt(sig.usual)) + else trf("{0} {1}, lower than your usual {2}", fmt(sig.value), unit, fmt(sig.usual)) +} diff --git a/app/src/main/res/font/inter_bold.ttf b/app/src/main/res/font/inter_bold.ttf new file mode 100644 index 00000000..9fb9b751 Binary files /dev/null and b/app/src/main/res/font/inter_bold.ttf differ diff --git a/app/src/main/res/font/inter_medium.ttf b/app/src/main/res/font/inter_medium.ttf new file mode 100644 index 00000000..458cd060 Binary files /dev/null and b/app/src/main/res/font/inter_medium.ttf differ diff --git a/app/src/main/res/font/inter_regular.ttf b/app/src/main/res/font/inter_regular.ttf new file mode 100644 index 00000000..b7aaca8d Binary files /dev/null and b/app/src/main/res/font/inter_regular.ttf differ diff --git a/app/src/main/res/font/inter_semibold.ttf b/app/src/main/res/font/inter_semibold.ttf new file mode 100644 index 00000000..47f8ab1d Binary files /dev/null and b/app/src/main/res/font/inter_semibold.ttf differ diff --git a/app/src/test/java/com/pulseloop/service/HealthInsightsTest.kt b/app/src/test/java/com/pulseloop/service/HealthInsightsTest.kt index bb885ea3..d0c7c0d8 100644 --- a/app/src/test/java/com/pulseloop/service/HealthInsightsTest.kt +++ b/app/src/test/java/com/pulseloop/service/HealthInsightsTest.kt @@ -124,6 +124,21 @@ class HealthInsightsTest { assertTrue(r.signals.isEmpty()) } + @Test + fun `the radar's history runs oldest first, skips days with no night, and never reads ahead`() { + val nights = baseline() + strained(today) + val h = SymptomRadar.history(nights, today, 3) + // The day before yesterday and yesterday are baseline nights; today is strained. + assertEquals(listOf(today.minusDays(2), today.minusDays(1), today), h.map { it.first }) + assertEquals(SymptomRadar.Level.NONE, h[1].second.level) + assertEquals(SymptomRadar.Level.MINOR, h[2].second.level) + // Yesterday's result is what compute gives as of yesterday: today's strained night is not in it. + assertEquals(SymptomRadar.compute(nights, today.minusDays(1)), h[1].second) + + val gap = SymptomRadar.history(nights.filter { it.day != today.minusDays(1) }, today, 3) + assertEquals(listOf(today.minusDays(2), today), gap.map { it.first }) + } + // ── Stress ─────────────────────────────────────────────────────────────────────────────── @Test diff --git a/app/src/test/java/com/pulseloop/ui/calm/StateTimelineModelTest.kt b/app/src/test/java/com/pulseloop/ui/calm/StateTimelineModelTest.kt new file mode 100644 index 00000000..3872ba7c --- /dev/null +++ b/app/src/test/java/com/pulseloop/ui/calm/StateTimelineModelTest.kt @@ -0,0 +1,27 @@ +package com.pulseloop.ui.calm + +import com.pulseloop.ui.calm.StateTimelineModel.Run +import org.junit.Assert.assertEquals +import org.junit.Test + +class StateTimelineModelTest { + @Test + fun `days at the same level join into one run, and an empty day breaks it`() { + val runs = StateTimelineModel.runs(listOf(0, 0, 1, 1, null, 1, 2)) + assertEquals(listOf(Run(0, 0, 1), Run(1, 2, 3), Run(1, 5, 5), Run(2, 6, 6)), runs) + } + + @Test + fun `a step joins only runs that touch`() { + val runs = StateTimelineModel.runs(listOf(0, 0, 1, 1, null, 1, 2)) + // 0→1 touch (day 1 to day 2), 1→1 across a gap is no step, 1→2 touch. + assertEquals(listOf(Run(0, 0, 1) to Run(1, 2, 3), Run(1, 5, 5) to Run(2, 6, 6)), StateTimelineModel.steps(runs)) + } + + @Test + fun `the selection starts on the last day with a value`() { + assertEquals(2, StateTimelineModel.lastIndex(listOf(0, null, 1, null))) + assertEquals(-1, StateTimelineModel.lastIndex(listOf(null, null))) + assertEquals(emptyList(), StateTimelineModel.runs(emptyList())) + } +} diff --git a/audits/2026-11-16-new-look-foundation-radar.md b/audits/2026-11-16-new-look-foundation-radar.md new file mode 100644 index 00000000..d370ef12 --- /dev/null +++ b/audits/2026-11-16-new-look-foundation-radar.md @@ -0,0 +1,135 @@ +# Audit: new look foundation and Symptom Radar screen (2.16.5) + +Date: 2026-11-16 · PR: see the PR linking this file · Auditor: Claude Code (ux-user-flows, graphic-design-fundamentals and less-is-more applied by hand from their SKILL.md files; impeccable run with the skill loaded) + +## Scope + +- **New look foundation, behind Debug → New look (off by default).** Tokens in `ui/calm/CalmTheme.kt`: + page `#0A0A0B`, card `#161618`, one `#27272A` hairline border, text `#FAFAFA` / `#A1A1AA` / + `#8B8B94`, mint accent from `PulseColors`, 12dp radius, 20dp gutter, 40dp section gap, Inter 4.1 + (OFL). Components: `CalmTopBar`, `CalmCard`, `CalmSection`, `ExpandableText`, `UnderlineTabs`, + `LevelScale`, `CalmBadge`, `CalmMetricRow`, `StateTimeline`. +- **Symptom Radar gets its own screen** (route `radar`). With the new look on, My Health shows + one row ("Symptom Radar · Minor signs") that opens it, in place of the inline section. With it + off, nothing changes. +- **"Recently" timeline:** the last 35 days, each computed as of that day (`SymptomRadar.history`). +- Departure from the Gabriel Design System (font, radius, no dither) is deliberate and recorded in + `docs/new-look-plan.md`; it moves to the design-system repo's `docs/divergences.md`. + +## ux-user-flows (§13 flow review checklist) + +Flow: My Health → Symptom Radar row → Radar screen (Today tab) → [Yesterday tab] → [Show more] → +[Turn on Rest Mode] → [tap a day on Recently] → Back. + +| # | Question | Result | +|---|---|---| +| 1 | Job | "Is something straining my body, and has it been building?" | +| 2 | Entries | One: the My Health row. The header's radar line already opens What changed; unchanged. | +| 3 | Happy path | Open → read the headline. One tap from My Health. | +| 4 | Branches | Today / Yesterday; no night that day; baseline under 14 nights; no flagged signal. | +| 5 | States | Loading (line after 400 ms), load failed (retry), no night, learning (n of 14), result, Rest Mode on/off. | +| 6 | Errors | Load failure says so and offers Try again. | +| 7 | Control | Back at any time; Rest Mode turns off from the same button. | +| 8 | Progress and resume | Tab survives rotation (`rememberSaveable`). | +| 9 | Memory | Rest Mode state is the existing `RestMode` preference. | +| 10 | Exits | Back to My Health. | +| 11 | Conventions | Underline tabs and the timeline follow Oura's pattern the owner pointed to. | +| 12 | Speed | Same single repository read My Health already does. | +| 13 | Accessibility | Tabs carry `Role.Tab`; the timeline has a content description summarising counts per level and the selected day. | +| 14 | Ethics | "Not a diagnosis…" stays on the screen, unchanged wording. | +| 15 | Evidence | The owner's Oura screenshot and request (2026-11-16). | + +Issues: important — a day with no recorded night first read as "Learning your normal: 0 nights". +Fixed: it now says "No night to read" and why. + +## graphic-design-fundamentals (§13 checklist) + +| # | Question | Result | +|---|---|---| +| 1 | Brief | One statement, the scale it sits on, the cause, the history; nothing else. | +| 2 | Concept | Calm: near-black, one border, wide gaps, a single type family. | +| 3 | Hierarchy | 32sp headline → 16sp explanation (2 lines, expandable) → scale → 20sp section titles. | +| 4 | Contrast | Text 17.3:1, secondary 7.0:1, muted 5.3:1 on card (4.9:1 on cardRaised). | +| 5 | Alignment and grid | One 20dp gutter; every block left-aligned to it. | +| 6 | Spacing | 40dp between sections, 16dp inside; the timeline gets its own section. | +| 7 | Typography | Inter in four weights; sizes 12/14/16/20/28/32 only, all on `PulseType.SCALE`. | +| 8 | Colour | Mint only on Fairy/accent paths; levels use info / warning / danger, the existing semantic colours. | +| 9 | Consistency | The scale, the timeline lanes and the headline name the levels with the same labels. | +| 10 | Simplicity | Five "Normal" rows are gone: only flagged signals are listed. | +| 11 | Real-size test | pt-BR "Sinais fortes" fits the 96dp lane-label column at 12sp; the headline wraps. | +| 12 | Accessibility and ergonomics | Tabs, "Show more" and the Rest Mode button are at least 48dp tall; the button 52dp. | +| 13 | Production | Inter 4.1 static TTFs (four files), licence shipped in `assets/licenses/`. | + +## impeccable (audit, native / Android) + +Run with the vendored skill loaded (`impeccable context`, `audit.native.md`, `critique.md`, `polish.md`, +`craft-floor.md`, `android.md`). No PRODUCT.md or DESIGN.md exists, so the code and +`docs/new-look-plan.md` were the context. No Android SDK or emulator in this environment: the pass is +from source and the canvas mock, not device screenshots. The device check (dark, font scale 1.3, +TalkBack) is owed on the release build. + +### Audit, before → after the polish pass + +| # | Dimension | Before | After | Key finding | +|---|---|---|---|---| +| 1 | Accessibility | 2 | 3 | Timeline days were tap-only and ~7dp wide; label column fixed at 96dp clipped at large font scale. Now: drag to scrub, TalkBack "Previous day / Next day" actions with a polite live region, column measured from the labels. | +| 2 | Performance | 4 | 4 | One repository read, 35 pure computes, one Canvas. | +| 3 | Appearance & theming | 3 | 4 | Rest Mode was Material's pill with the mint outline, off the new look. Now `CalmOutlinedButton` (12dp radius, hairline border, still a `PulseButton`). | +| 4 | Platform conformance | 4 | 4 | M3 top bar, system Back, Material button underneath. | +| 5 | Adaptivity | 2 | 3 | No width cap: on a tablet the text ran 1000dp+ wide. Now capped at 720dp and centred like the tabs. | +| | **Total** | **15/20** | **18/20** | | + +### Critique (design review only; detector not applicable, native platform) + +| # | Heuristic | Score | Key issue | +|---|---|---|---| +| 1 | Visibility of status | 3 | Headline and scale say the level; the timeline's selected day is shown. | +| 2 | Match real world | 3 | "Inactivity · Lower" read as *less* inactive: fixed to "Fewer steps". | +| 3 | User control | 3 | Rest Mode is reversible from the same button. | +| 4 | Consistency | 3 | Signal detail was English-only beside translated text: now `trf`, pt-BR added. | +| 5 | Error prevention | 3 | No destructive action on the screen. | +| 6 | Recognition | 4 | Every level visible on the scale and the lanes. | +| 7 | Flexibility | 2 | Tabs and timeline don't talk: picking Yesterday doesn't select it on the chart (P3, NL-3). | +| 8 | Minimalist | 3 | Only flagged signals; explanation folded to two lines. | +| 9 | Error recovery | 3 | Load failure says so and retries. | +| 10 | Help | 3 | Explanation and the not-a-diagnosis line are on the screen. | +| | **Total** | **30/40** | Good | + +Design specificity: the lanes-and-steps timeline and the three-dot scale are the radar's own +shapes, not generic cards. The rest is deliberately quiet (Operate mode). + +Priority issues found and fixed: [P1] timeline unusable with TalkBack and hard to aim; +[P1] "Inactivity · Lower" contradicts itself; [P2] untranslated signal detail; [P2] off-look pill +button; [P2] no width cap. Left: [P3] NL-3 tab ↔ timeline selection; [P3] temperature shown in °C +regardless of unit setting (pre-existing, the radar's own model). + +## less-is-more + +| Element | Question (1–5) | Kept / moved / merged / removed, and where | +|---|---|---| +| Five per-metric "Normal" rows | 4 (can it be cut?) | Removed; "Nothing is outside your usual range." when none is flagged. | +| Rest Mode switch row | 2 (right form?) | Now one outlined button with its state in the label. | +| Long explanation | 3 (does it need to show now?) | Two lines, "Show more" for the rest. | +| Timeline | 1 (does it earn its place?) | Kept: it is the feature the owner asked for, and it replaces guessing from today alone. | + +| Dimension | 0–4 | +|---|---| +| Elements per screen, compared with before | My Health: a section becomes one row (−) | +| Duplicates left | 0 | +| Text to read when tired | 4 | +| Taps on the common actions (must not rise) | Reading the radar unchanged (one tap, My Health). Rest Mode from My Health rises 1→2 with the new look on; its main door, Today's Rest Mode line, is unchanged at 1. | + +## Evidence + +- No change to the design-system tokens (`GTokens.kt`), so `drift.py` doesn't apply; the new + tokens are this app's, recorded in `docs/new-look-plan.md`. +- Contrast computed with the WCAG formula (values above). +- Tests: `StateTimelineModelTest`; `HealthInsightsTest` radar history case. +- pt-BR missing-key check: no new key missing. +- Design canvas: see the PR description. + +## Verdict + +Merge. NL-1 (per-day TalkBack) and NL-2 (width cap) were fixed in the impeccable polish pass. Carried +forward: NL-3 tab ↔ timeline selection; the on-device check; the divergence to be recorded in the +design-system repo. diff --git a/docs/new-look-plan.md b/docs/new-look-plan.md new file mode 100644 index 00000000..53dbb988 --- /dev/null +++ b/docs/new-look-plan.md @@ -0,0 +1,55 @@ +# New look: plan and tokens + +Owner's decisions (2026-11-16): **PulseLoop only, dark only, keep mint, use Inter.** The goal is a +calmer app in the spirit of shadcn/ui and Oura: near-black surfaces, one hairline border, wide +gaps, one statement per screen, detail on tap, and a timeline for states over time (Oura's +Symptom Radar "Recently" chart). + +## How it ships + +- **Our own components, shadcn's style, on Material 3.** No shadcn-compose dependency: the + primitives are small, and owning them keeps `PulseButton`, `tr()` and the type-scale test in + force. They live in `ui/calm/`. +- **Behind a switch, screen by screen, on `main`.** `NewLook.on` (Debug → New look, off by + default, not archived). A converted screen reads it; an unconverted one ignores it. No + long-lived branch: each step is a normal PR and release. +- **Order:** 1 foundation + Symptom Radar (this PR) → 2 Today → 3 Vitals → 4 Sleep, Activity → + 5 Nutrition, My Health, Readiness → 6 Settings and the rest → 7 flip the default on and delete + the old styling. + +## Tokens (`ui/calm/CalmTheme.kt`) + +| Token | Value | Note | +|---|---|---| +| page | `#0A0A0B` | | +| card | `#161618` | one 1dp `border` `#27272A`, no shadow | +| cardRaised | `#1E1E21` | badges, pressed rows | +| text | `#FAFAFA` | 17.3:1 on card | +| textSecondary | `#A1A1AA` | 7.0:1 on card | +| textMuted | `#8B8B94` | 5.3:1 on card, 4.9:1 on cardRaised | +| accent | `PulseColors.accent` | mint; Fairy mode still turns it pink | +| radius | 12dp | | +| gutter | 20dp | | +| section gap | 40dp | | +| type | Inter 4.1 (OFL, `assets/licenses/inter-ofl.txt`) | sizes stay on `PulseType.SCALE` | + +## Components + +`CalmTopBar`, `CalmCard`, `CalmSection`, `ExpandableText` ("Show more"), `UnderlineTabs`, +`LevelScale` (every state visible, the current one marked), `CalmBadge`, `CalmMetricRow`, and +`StateTimeline` (one lane per level, runs joined into bars, steps between touching runs, tap a +day for its date and level; layout in the pure, tested `StateTimelineModel`). + +## Departure from the design system + +This leaves the Gabriel Design System's `pulseloop` layer (Ubuntu Mono, 8dp radius, dither +wipe) on purpose. It belongs in that repo's `docs/divergences.md` with this plan; this session +couldn't reach that repo, so it is recorded here until it is moved there. + +## Screens done + +- **Symptom Radar** (`ui/screens/SymptomRadarScreen.kt`, route `radar`): Yesterday / Today tabs, + the level as the headline, an expandable explanation, the three-level scale, Rest Mode, the + 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.