From 9b50e9914c9f789562d0d6ac7d0669a8b3160d9c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 31 Oct 2026 13:41:13 +0000 Subject: [PATCH 1/2] Audit fixes: chrome, type scale, colour roles, touch targets, adaptivity From the impeccable + graphic-design audit of v2.11.51: - Landscape keeps a compact header (Settings and the ring were unreachable); from 600dp the tabs move to a NavigationRail and tab content caps at 720dp. - Ring pill opens Ring & sync with a 48dp target; the gear opens Settings. - Dark window theme (no white flash on launch); predictive Back on. - Type scale (PulseType): 12sp floor, one eyebrow style, sizes snapped to 12/14/16/20/24/28/32/40 in the main screens, guarded by PulseTypeScaleTest. - Gauge verdict on Today moves under the ring at 12sp (was ~7sp). - "+ Log meal", Undo and the My Health section toggle are real 48dp buttons; tappable cards announce themselves as buttons; sparklines speak a trend. - Colour roles: success has its own green, REM is cyan, connecting is amber, deep sleep lifted to 3.3:1 on the card. - One card radius (8dp), one calorie unit (kcal), no per-tab titles, one Material segmented control, CenterAlignedTopAppBar on My Health/Readiness. - Readiness is the larger centre ring on Today. - Activity's Record is tonal (one filled accent per screen); Nutrition logs from one row; "TAP TO EDIT GOALS" removed. - Nutrition scrolls under the glass like the other tabs; blur only on tabs; My Health is a LazyColumn; RingArtView holds still under Remove animations. - Untranslated strings wrapped in tr() with pt-BR entries; "Vitais" tab label. Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w --- AGENTS.md | 20 ++ app/src/main/AndroidManifest.xml | 4 +- app/src/main/assets/i18n/pt-BR.json | 16 +- .../java/com/pulseloop/ui/PulseLoopApp.kt | 84 ++++++-- .../com/pulseloop/ui/components/AppChrome.kt | 72 ++++--- .../com/pulseloop/ui/components/Charts.kt | 6 +- .../pulseloop/ui/components/PulseSegmented.kt | 47 +++++ .../pulseloop/ui/components/RingArtView.kt | 6 +- .../com/pulseloop/ui/components/TodayTiles.kt | 91 ++++---- .../com/pulseloop/ui/components/VitalCard.kt | 40 ++-- .../pulseloop/ui/components/VitalRingGauge.kt | 6 +- .../pulseloop/ui/components/ZoneLineChart.kt | 6 +- .../pulseloop/ui/screens/ActivityScreen.kt | 138 +++++------- .../java/com/pulseloop/ui/screens/LogSheet.kt | 34 ++- .../com/pulseloop/ui/screens/MyHealthUi.kt | 198 +++++++++--------- .../pulseloop/ui/screens/NutritionScreen.kt | 72 +++---- .../com/pulseloop/ui/screens/ReadinessUi.kt | 84 ++++---- .../java/com/pulseloop/ui/screens/Screens.kt | 99 +++------ .../com/pulseloop/ui/screens/SleepScreen.kt | 85 +++----- .../com/pulseloop/ui/screens/TodayScreen.kt | 81 ++++--- .../com/pulseloop/ui/theme/PulseColors.kt | 15 +- .../java/com/pulseloop/ui/theme/PulseType.kt | 39 ++++ app/src/main/res/values/themes.xml | 12 ++ .../pulseloop/ui/theme/PulseTypeScaleTest.kt | 48 +++++ 24 files changed, 741 insertions(+), 562 deletions(-) create mode 100644 app/src/main/java/com/pulseloop/ui/components/PulseSegmented.kt create mode 100644 app/src/main/java/com/pulseloop/ui/theme/PulseType.kt create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/test/java/com/pulseloop/ui/theme/PulseTypeScaleTest.kt diff --git a/AGENTS.md b/AGENTS.md index 5715bd4f..d6eab171 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1236,6 +1236,26 @@ clutter came from ignoring one of them: - **A goal saved anywhere goes through `GoalSync.afterManualSave`** — it is what stops the field following the coach, sends the step goal to the ring and republishes the widget. +## Type, colour and chrome: one of each role (audit, v2.11.52) + +- **Type sizes come from `PulseType.SCALE`** (12, 14, 16, 20, 24, 28, 32, 40). 12sp is the floor + for anything that carries meaning; `PulseTypeScaleTest` fails on any other inline size in the + main screens. The tracked caps label over a card or section is `PulseType.eyebrow` (12sp, + 1sp tracking, `textSecondary`) everywhere — don't hand-roll another letter-spacing. +- **Mint is the brand and the thing to tap, nothing else.** `success` (good, in range, + connected) is its own green, REM is cyan, connecting is amber. The readiness ring keeps the + brand colour on purpose: it is the headline score. +- **One card radius: 8dp.** Tiles and vital cards used to be 20/30dp. +- **One filled accent per screen**: the Actions button. A screen's own primary action is a tonal + button (Activity's Record). +- **Landscape keeps the header** (compact, one row): it is the only route to Settings and the + ring. From 600dp the tabs move to a `NavigationRail` and tab content caps at 720dp. +- **The ring pill opens the ring's screen** (`settings/wearable`); the gear opens Settings. +- **Tabs have no title of their own**: the tab bar names the screen. Pushed screens use + `CenterAlignedTopAppBar`, and a row's trailing arrow is `Chevron()`, never a "›" glyph. +- **The window theme is dark** (`Theme.PulseLoop`), so cold start doesn't flash white, and + predictive Back is on (`enableOnBackInvokedCallback`). + ## Motion: one transition, a small vocabulary - **Every navigation destination goes through `DitherTransitionBox`** (`theme/DitherTransition.kt`), diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c0b754bd..85b994ae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -103,7 +103,9 @@ android:networkSecurityConfig="@xml/network_security_config" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" - android:theme="@android:style/Theme.Material.Light.NoActionBar"> + android:theme="@style/Theme.PulseLoop" + android:enableOnBackInvokedCallback="true" + tools:targetApi="tiramisu"> = 600 val tabRoutes = remember(tabs) { tabs.map { it.route }.toSet() } // The header's health line (HealthHeadline). Held here, not in the top bar, so it @@ -447,7 +452,9 @@ fun PulseLoopApp() { val route = navBackStackEntry?.destination?.route // The coach is no longer a tab but keeps the frosted header it had as one. val onTabRoute = route in tabRoutes || route == "coach" - if (onTabRoute && !isLandscape) { + // Landscape keeps the header (compact, one row): it is the only route to + // Settings and the ring, so dropping it stranded them. + if (onTabRoute) { Column( Modifier // iOS-style scroll-under: blur strongest at the status bar, @@ -509,6 +516,10 @@ fun PulseLoopApp() { else storedDevice?.state ?: ble.connectionState, batteryPercent = ble.batteryPercent ?: storedDevice?.batteryPercent, onOpenSettings = { navController.navigate("settings") }, + // The pill says what the ring is doing, so it opens the ring's + // screen; the gear beside it is the Settings hub. + onOpenRing = { navController.navigate("settings/wearable") { launchSingleTop = true } }, + compact = isLandscape, idle = ble.idleSince != null, sourceLabel = hcSource?.let { com.pulseloop.health.source.HealthConnectSource.label(context, it) + tr(" · Health Connect") }, name = profileName, @@ -545,14 +556,19 @@ fun PulseLoopApp() { launchSingleTop = true } } - if (currentDestination?.route == "onboarding") { - // The onboarding flow is full-screen chrome of its own — no tab bar. + // Blur only where content scrolls under the bar (the tabs); a pushed screen sits + // above an opaque bar anyway, so a per-frame blur there bought nothing. + val barGlass = if (currentDestination?.route in tabRoutes) Modifier.hazeEffect(state = hazeState, style = glassStyle) + else Modifier.background(com.pulseloop.ui.theme.PulseColors.background) + if (currentDestination?.route == "onboarding" || useRail) { + // The onboarding flow is full-screen chrome of its own — no tab bar; on wide + // windows the tabs live in the rail beside the content instead. } else if (isLandscape) { // Landscape: a compact icon-only bar at ~half the standard height, // so the short viewport keeps more room for content. Surface( color = Color.Transparent, - modifier = Modifier.hazeEffect(state = hazeState, style = glassStyle), + modifier = barGlass, ) { Row( modifier = Modifier @@ -586,7 +602,7 @@ fun PulseLoopApp() { HorizontalDivider(thickness = 1.dp, color = com.pulseloop.ui.theme.PulseColors.borderSubtle) NavigationBar( containerColor = Color.Transparent, - modifier = Modifier.hazeEffect(state = hazeState, style = glassStyle), + modifier = barGlass, ) { tabs.forEach { tab -> val selected = isSelected(tab) @@ -598,13 +614,13 @@ fun PulseLoopApp() { contentDescription = null, ) }, - // One line, a touch smaller than labelMedium: "Sinais vitais" wrapped to two - // lines and pushed its icon up out of line with the others. Items already + // One line at the 12sp label size. Portuguese says "Vitais" here: "Sinais vitais" + // wrapped to two lines and pushed its icon out of line. Items already // share the width equally (NavigationBarItem weights itself 1f). label = { Text( tab.label, - fontSize = 11.sp, + fontSize = 12.sp, maxLines = 1, softWrap = false, overflow = TextOverflow.Ellipsis, @@ -643,11 +659,50 @@ fun PulseLoopApp() { fun androidx.navigation.NavGraphBuilder.screen( route: String, content: @Composable (androidx.navigation.NavBackStackEntry) -> Unit, - ) = composable(route) { entry -> DitherTransitionBox { content(entry) } } + ) = composable(route) { entry -> + DitherTransitionBox { + // On a tablet or a landscape phone a single column of cards stretched across + // the whole window; it is capped at 720dp and centred instead. + Box(Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { + Box(Modifier.widthIn(max = 720.dp).fillMaxSize()) { content(entry) } + } + } + } + val railEntry by navController.currentBackStackEntryAsState() + val railDestination = railEntry?.destination + Row(Modifier.fillMaxSize()) { + if (useRail && railDestination?.route != "onboarding") { + NavigationRail( + containerColor = com.pulseloop.ui.theme.PulseColors.background, + modifier = Modifier.fillMaxHeight().padding(top = topPad, bottom = barPad), + ) { + tabs.forEach { tab -> + val selected = railDestination?.hierarchy?.any { it.route == tab.route } == true + NavigationRailItem( + selected = selected, + onClick = { + if (!selected) navController.navigate(tab.route) { + popUpTo(navController.graph.startDestinationId) + launchSingleTop = true + } + }, + icon = { Icon(if (selected) tab.selectedIcon else tab.unselectedIcon, contentDescription = null) }, + label = { Text(tab.label, maxLines = 1, softWrap = false, overflow = TextOverflow.Ellipsis) }, + colors = NavigationRailItemDefaults.colors( + selectedIconColor = com.pulseloop.ui.theme.PulseColors.onAccent, + selectedTextColor = com.pulseloop.ui.theme.PulseColors.textPrimary, + unselectedIconColor = com.pulseloop.ui.theme.PulseColors.textMuted, + unselectedTextColor = com.pulseloop.ui.theme.PulseColors.textMuted, + indicatorColor = com.pulseloop.ui.theme.PulseColors.accent, + ), + ) + } + } + } NavHost( navController = navController, startDestination = "today", - modifier = Modifier.hazeSource(hazeState), + modifier = Modifier.weight(1f).hazeSource(hazeState), enterTransition = { com.pulseloop.ui.theme.DitherTransition.enter }, exitTransition = { com.pulseloop.ui.theme.DitherTransition.exit }, popEnterTransition = { com.pulseloop.ui.theme.DitherTransition.enter }, @@ -748,8 +803,12 @@ fun PulseLoopApp() { navController.navigate("coach") { launchSingleTop = true } } else null // A tab: the shared header above it, and no back arrow of its own. - paddedComposable("nutrition") { - NutritionScreen(onBack = { navController.popBackStack() }, onDiscuss = discussMeal, asTab = true) + // Scrolls under the glass bars like the other four tabs, with the same paddings. + screen("nutrition") { + NutritionScreen( + onBack = { navController.popBackStack() }, onDiscuss = discussMeal, asTab = true, + topBarPadding = topPad, bottomBarPadding = tabPad, + ) } // Straight into a way of logging (Today's food card, the "Log meal" shortcut). listOf("photo", "barcode", "add").forEach { start -> @@ -919,6 +978,7 @@ fun PulseLoopApp() { ) } } + } // Row: rail + content } val logStep by LaunchRequests.openLog.collectAsState() diff --git a/app/src/main/java/com/pulseloop/ui/components/AppChrome.kt b/app/src/main/java/com/pulseloop/ui/components/AppChrome.kt index a0433183..ec0f8169 100644 --- a/app/src/main/java/com/pulseloop/ui/components/AppChrome.kt +++ b/app/src/main/java/com/pulseloop/ui/components/AppChrome.kt @@ -18,6 +18,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape import com.pulseloop.service.HealthHeadline import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Settings +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight +import com.pulseloop.ui.theme.PulseType import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text @@ -56,15 +58,19 @@ fun AppHeader( /** The health line under the greeting (`HealthHeadline`); null while it is first read. */ headline: HealthHeadline.Headline? = null, onOpenHeadline: (String) -> Unit = {}, + /** The pill opens the ring's own screen; the gear beside it opens the Settings hub. */ + onOpenRing: () -> Unit = onOpenSettings, + /** Landscape: one row, no greeting, so the short viewport keeps its height for content. */ + compact: Boolean = false, ) { Row( modifier = Modifier .fillMaxWidth() // No opaque background: the caller layers this header on the glass // top bar (hazeEffect in PulseLoopApp), which supplies the material. - .padding(start = 12.dp, end = 8.dp, top = 2.dp, bottom = 6.dp), + .padding(start = 12.dp, end = 8.dp, top = if (compact) 0.dp else 4.dp, bottom = if (compact) 0.dp else 4.dp), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), ) { // The greeting is the eyebrow now; the line below it is the door to My Health. // Both are one line, ellipsised, so a long translation or a new headline never @@ -75,7 +81,7 @@ fun AppHeader( Column( modifier = Modifier .weight(1f) - .heightIn(min = 44.dp) + .heightIn(min = 48.dp) .clip(RoundedCornerShape(8.dp)) .clickable( onClickLabel = tr("Open My Health"), @@ -84,12 +90,10 @@ fun AppHeader( .padding(horizontal = 8.dp, vertical = 2.dp), verticalArrangement = Arrangement.Center, ) { - Text( + if (!compact) Text( greeting, - fontSize = 10.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 1.2.sp, - color = PulseColors.textMuted, + style = PulseType.eyebrow, + color = PulseColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, ) @@ -98,19 +102,19 @@ fun AppHeader( headline == null -> PulseColors.textMuted headline.attention -> PulseColors.warning headline.kind == HealthHeadline.Kind.LEARNING || headline.kind == HealthHeadline.Kind.NONE -> PulseColors.textMuted - else -> PulseColors.accent + else -> PulseColors.success } Box(Modifier.size(8.dp).clip(CircleShape).background(dot)) Text( line, - fontSize = 15.sp, + fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false), ) - Text("›", fontSize = 18.sp, color = PulseColors.textMuted, maxLines = 1) + Chevron() } } ConnectionStatusPill( @@ -120,11 +124,16 @@ fun AppHeader( sourceLabel = sourceLabel, // Bounded: the pill is measured before the weighted greeting, so an unbounded // "Falha na sincronização" or "Oura · Health Connect" squeezed the greeting to nothing. - modifier = Modifier.widthIn(max = 168.dp).clickable( - onClickLabel = tr("Open ring settings"), - role = Role.Button, - onClick = onOpenSettings, - ), + // The capsule stays its size; the 48dp box around it is the touch target. + modifier = Modifier.widthIn(max = 168.dp), + touchModifier = Modifier + .heightIn(min = 48.dp) + .clip(RoundedCornerShape(8.dp)) + .clickable( + onClickLabel = tr("Open ring settings"), + role = Role.Button, + onClick = onOpenRing, + ), ) IconButton(onClick = onOpenSettings) { Icon(Icons.Outlined.Settings, tr("Settings"), tint = PulseColors.textSecondary) @@ -145,6 +154,8 @@ fun ConnectionStatusPill( /** Disconnected because the ring idled out after a sync — shown neutral, not as an error. */ idle: Boolean = false, sourceLabel: String? = null, + /** Wraps the capsule; give it the click and the 48dp target so the capsule can stay small. */ + touchModifier: Modifier = Modifier, ) { val idleNow = idle && state == RingConnectionState.DISCONNECTED // Holds still under "Remove animations"; the label already says "Connecting…". @@ -152,7 +163,9 @@ fun ConnectionStatusPill( !rememberReduceMotion() val dotColor = if (sourceLabel != null) PulseColors.success else when (state) { RingConnectionState.CONNECTED -> PulseColors.success - RingConnectionState.CONNECTING, RingConnectionState.RECONNECTING -> PulseColors.accent + // Connecting is amber, not the connected colour: without the pulse (Remove + // animations) the two would otherwise be identical. + RingConnectionState.CONNECTING, RingConnectionState.RECONNECTING -> PulseColors.warning else -> if (idleNow) PulseColors.textMuted else PulseColors.danger // scanning/failed/idle/disconnected all read "not connected" } val label = sourceLabel ?: when (state) { @@ -174,14 +187,15 @@ fun ConnectionStatusPill( ).value } else 1f + Box(touchModifier, contentAlignment = Alignment.Center) { Row( modifier = modifier .clip(CircleShape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, CircleShape) - .padding(horizontal = 10.dp, vertical = 6.dp), + .padding(horizontal = 12.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Box( Modifier @@ -199,6 +213,18 @@ fun ConnectionStatusPill( overflow = TextOverflow.Ellipsis, ) } + } +} + +/** A row's trailing "open" mark: a mirrored Material arrow, not a "›" glyph that RTL can't flip. */ +@Composable +fun Chevron(tint: Color = PulseColors.textMuted, modifier: Modifier = Modifier) { + Icon( + Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = tint, + modifier = modifier.size(24.dp), + ) } /** Time-of-day greeting, mirroring RootViews.swift `greetingForHour()`. */ @@ -236,9 +262,7 @@ fun CardEyebrow( // rather than pushing the trailing slot off the card; the slot is bounded for the same reason. Text( label.uppercase(), - fontSize = 11.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 1.sp, + style = PulseType.eyebrow, color = PulseColors.textSecondary, maxLines = 2, overflow = TextOverflow.Ellipsis, @@ -254,9 +278,9 @@ fun SectionHeaderCaps(title: String, modifier: Modifier = Modifier, action: (@Co Row(modifier = modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { Text( title.uppercase(), - fontSize = 13.sp, + fontSize = 14.sp, fontWeight = FontWeight.SemiBold, - letterSpacing = 0.8.sp, + letterSpacing = 1.sp, color = PulseColors.textSecondary, // Takes the free width (instead of a Spacer) so a long title wraps beside the action. modifier = Modifier.weight(1f), diff --git a/app/src/main/java/com/pulseloop/ui/components/Charts.kt b/app/src/main/java/com/pulseloop/ui/components/Charts.kt index e4738d42..61170c95 100644 --- a/app/src/main/java/com/pulseloop/ui/components/Charts.kt +++ b/app/src/main/java/com/pulseloop/ui/components/Charts.kt @@ -433,7 +433,7 @@ fun TrendChart( return best } - val labelStyle = TextStyle(fontSize = 11.sp, color = axisColor) + val labelStyle = TextStyle(fontSize = 12.sp, color = axisColor) // No zone-band background: the iOS detail chart plots on a clean card, with the // zone-split line + the REFERENCE ZONES card carrying the range context. @@ -538,8 +538,8 @@ fun TrendChart( else valueFormatter(points[idx]) val timeText = timestamps.getOrNull(idx)?.let { tooltipTimeFormatter?.invoke(it) } ?: labels.getOrNull(idx) ?: "" - val valStyle = TextStyle(fontSize = 13.sp, color = onSurfaceColor, fontWeight = FontWeight.Bold) - val timeStyle = TextStyle(fontSize = 10.sp, color = axisColor) + val valStyle = TextStyle(fontSize = 14.sp, color = onSurfaceColor, fontWeight = FontWeight.Bold) + val timeStyle = TextStyle(fontSize = 12.sp, color = axisColor) val valTl = textMeasurer.measure(valueText, valStyle) val timeTl = if (timeText.isNotEmpty()) textMeasurer.measure(timeText, timeStyle) else null val padPx = 8.dp.toPx() diff --git a/app/src/main/java/com/pulseloop/ui/components/PulseSegmented.kt b/app/src/main/java/com/pulseloop/ui/components/PulseSegmented.kt new file mode 100644 index 00000000..8388e9c6 --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/components/PulseSegmented.kt @@ -0,0 +1,47 @@ +package com.pulseloop.ui.components + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SegmentedButton +import androidx.compose.material3.SegmentedButtonDefaults +import androidx.compose.material3.SingleChoiceSegmentedButtonRow +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextOverflow +import com.pulseloop.ui.theme.PulseColors +import com.pulseloop.ui.theme.PulseType + +/** + * The one segmented control (Sleep's Day/Week/Month/Year, a vital's Today/Week/Month): Material's + * single-choice segmented row in the app's colours. Two hand-built versions used to drift apart. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun PulseSegmented( + options: List>, + selected: T, + onSelect: (T) -> Unit, + modifier: Modifier = Modifier, +) { + SingleChoiceSegmentedButtonRow(modifier.fillMaxWidth()) { + options.forEachIndexed { index, (key, label) -> + SegmentedButton( + selected = key == selected, + onClick = { onSelect(key) }, + shape = SegmentedButtonDefaults.itemShape(index, options.size), + icon = {}, + colors = SegmentedButtonDefaults.colors( + activeContainerColor = PulseColors.accentSoft, + activeContentColor = PulseColors.textPrimary, + activeBorderColor = PulseColors.accent, + inactiveContainerColor = PulseColors.card, + inactiveContentColor = PulseColors.textSecondary, + inactiveBorderColor = PulseColors.borderStrong, + ), + ) { + Text(label, style = PulseType.label, maxLines = 1, overflow = TextOverflow.Ellipsis) + } + } + } +} diff --git a/app/src/main/java/com/pulseloop/ui/components/RingArtView.kt b/app/src/main/java/com/pulseloop/ui/components/RingArtView.kt index de265b6d..648ce60a 100644 --- a/app/src/main/java/com/pulseloop/ui/components/RingArtView.kt +++ b/app/src/main/java/com/pulseloop/ui/components/RingArtView.kt @@ -40,12 +40,14 @@ fun RingArtView( // A black or gunmetal ring's colour would vanish on the dark page; those turn in the accent. val visible = if (tint.luminance() < 0.25f) com.pulseloop.ui.theme.PulseColors.accent else tint val color by animateColorAsState(visible, tween(250), label = "ringArtTint") - val spin by rememberInfiniteTransition(label = "ringSpin").animateFloat( + // Looping decoration holds still under "Remove animations" (A11y.kt), like the header pill. + val still = rememberReduceMotion() + val spin = if (still) 0.6f else rememberInfiniteTransition(label = "ringSpin").animateFloat( initialValue = 0f, targetValue = (2 * PI).toFloat(), animationSpec = infiniteRepeatable(tween(6000, easing = LinearEasing), RepeatMode.Restart), label = "ringAngle", - ) + ).value Canvas(modifier.size(size.dp)) { val radius = this.size.minDimension * 0.34f val band = this.size.minDimension * 0.075f diff --git a/app/src/main/java/com/pulseloop/ui/components/TodayTiles.kt b/app/src/main/java/com/pulseloop/ui/components/TodayTiles.kt index 955d4adf..a27a8f3c 100644 --- a/app/src/main/java/com/pulseloop/ui/components/TodayTiles.kt +++ b/app/src/main/java/com/pulseloop/ui/components/TodayTiles.kt @@ -1,5 +1,6 @@ package com.pulseloop.ui.components +import androidx.compose.ui.semantics.Role import com.pulseloop.ui.theme.pressScale import com.pulseloop.ui.i18n.trf @@ -54,7 +55,8 @@ import kotlin.math.roundToInt /** Shared sizing so every Today tile is identical (TodayTileMetrics in Swift). */ object TodayTileMetrics { - val corner = 20.dp + // One card radius across the app (the theme's medium shape); tiles used to be 20dp. + val corner = 8.dp /** * The tile height *floor*, not a fixed height. Tiles grow past it to fit their own contents. @@ -122,7 +124,7 @@ fun TodayTile( .border(1.dp, PulseColors.borderSubtle, shape) .then(if (onTap != null) Modifier.clickable(interactionSource = press, indication = androidx.compose.foundation.LocalIndication.current, onClick = onTap) else Modifier) .padding(12.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Box( @@ -134,10 +136,8 @@ fun TodayTile( ) Text( label.uppercase(), - fontSize = 11.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 0.6.sp, - color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = PulseColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, ) @@ -166,7 +166,7 @@ fun ActivityTile( Row( Modifier.weight(1f).fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), ) { ActivityRings( rings = rings, @@ -191,12 +191,12 @@ fun ActivityTile( // if the tile ends up shorter anyway, the column is scaled down to fit instead of // being cut off. The rings already shrink to the height they get. ScaleDownToFit(Modifier.weight(1f)) { - Column(verticalArrangement = Arrangement.spacedBy(3.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { values.forEach { value -> Column { Text( value.label.uppercase(), - fontSize = 10.sp, + fontSize = 12.sp, lineHeight = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 0.8.sp, @@ -260,10 +260,10 @@ fun buildSleepStageSegments( val byStage = blocks.groupBy { it.stageRaw } .mapValues { (_, stageBlocks) -> stageBlocks.sumOf { it.durationMinutes }.toDouble() } return listOf( - SleepStageSegment(byStage["DEEP"] ?: 0.0, PulseColors.stageDeep, "DEEP"), - SleepStageSegment(byStage["LIGHT"] ?: 0.0, PulseColors.stageLight, "LIGHT"), - SleepStageSegment(byStage["REM"] ?: 0.0, PulseColors.stageRem, "REM"), - SleepStageSegment(byStage["AWAKE"] ?: 0.0, PulseColors.stageAwake, "AWK"), + SleepStageSegment(byStage["DEEP"] ?: 0.0, PulseColors.stageDeep, tr("Deep")), + SleepStageSegment(byStage["LIGHT"] ?: 0.0, PulseColors.stageLight, tr("Light")), + SleepStageSegment(byStage["REM"] ?: 0.0, PulseColors.stageRem, tr("REM")), + SleepStageSegment(byStage["AWAKE"] ?: 0.0, PulseColors.stageAwake, tr("Awake")), ).filter { it.minutes > 0 } } @@ -275,24 +275,20 @@ fun buildSleepStageSegments( fun SleepStageBar(segments: List, modifier: Modifier = Modifier) { val total = segments.sumOf { it.minutes }.coerceAtLeast(1.0) val measurer = rememberTextMeasurer() - val labelStyle = TextStyle( - fontSize = 10.sp, - fontWeight = FontWeight.SemiBold, - letterSpacing = 0.5.sp, - ) + val labelStyle = com.pulseloop.ui.theme.PulseType.eyebrow.copy(fontWeight = FontWeight.SemiBold) // Measured rather than subcomposed: BoxWithConstraints would give the per-segment width // directly, but it is a SubcomposeLayout and the Today grid measures these tiles with // IntrinsicSize.Min, which subcomposition can't answer. onSizeChanged keeps intrinsics intact. var barWidthPx by remember { mutableIntStateOf(0) } // Labels drop out when a segment is too narrow, and the bar itself says nothing to TalkBack, // so the whole bar speaks one summary instead. - val spoken = segments.joinToString(", ") { "${stageName(it.label)} ${it.minutes.roundToInt()} min" } + val spoken = segments.joinToString(", ") { "${it.label.lowercase()} ${it.minutes.roundToInt()} ${tr("min")}" } Column( modifier = modifier .fillMaxWidth() .onSizeChanged { barWidthPx = it.width } .clearAndSetSemantics { contentDescription = trf("Sleep stages: {0}", spoken) }, - verticalArrangement = Arrangement.spacedBy(3.dp), + verticalArrangement = Arrangement.spacedBy(4.dp), ) { Row(Modifier.fillMaxWidth().height(12.dp), horizontalArrangement = Arrangement.spacedBy(2.dp)) { segments.forEach { seg -> @@ -315,10 +311,13 @@ fun SleepStageBar(segments: List, modifier: Modifier = Modifi // "DEE" at 2.0. A truncated stage name reads as a different stage, so drop the // label instead of clipping it — the colored segment still carries the meaning. // The measurer picks up the current density and font scale on its own. - val labelPx = measurer.measure(seg.label, labelStyle).size.width + val caption = seg.label.uppercase() + // Measured once per label, density and scale, not on every recomposition. + val density = androidx.compose.ui.platform.LocalDensity.current + val labelPx = remember(caption, labelStyle, density) { measurer.measure(caption, labelStyle).size.width } if (barWidthPx > 0 && labelPx <= barWidthPx * fraction) { Text( - seg.label, + caption, style = labelStyle, // Deep's indigo is ~2.4:1 on the card: legible as a bar, not as text. color = if (seg.color == PulseColors.stageDeep) PulseColors.textSecondary else seg.color, @@ -332,11 +331,6 @@ fun SleepStageBar(segments: List, modifier: Modifier = Modifi } } -private fun stageName(label: String) = when (label) { - "AWK" -> "awake" - "REM" -> "REM" - else -> label.lowercase() -} /** Sleep tile: duration on top, stage distribution bar, score below (SleepTileView in Swift). */ @Composable @@ -359,20 +353,19 @@ fun SleepTile( ) SleepStageBar(segments) if (score != null) { - Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(5.dp)) { + Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(4.dp)) { Text( "$score", - fontSize = 22.sp, + fontSize = 24.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, ) Text( tr("SCORE"), - fontSize = 10.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 1.sp, - color = PulseColors.textMuted, - modifier = Modifier.padding(bottom = 3.dp), + color = PulseColors.textSecondary, + modifier = Modifier.padding(bottom = 4.dp), ) } } @@ -391,7 +384,7 @@ fun SleepTile( Spacer(Modifier.height(6.dp)) Text( tr("No sleep recorded"), - fontSize = 13.sp, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, ) @@ -443,7 +436,7 @@ fun HeroInsightCard(title: String, summary: String, chips: List, modif Text(title, fontSize = 28.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary) Text( summary, - fontSize = 15.sp, + fontSize = 16.sp, lineHeight = 21.sp, color = PulseColors.textSecondary, modifier = Modifier.padding(top = 8.dp), @@ -452,8 +445,8 @@ fun HeroInsightCard(title: String, summary: String, chips: List, modif // Wraps: three translated chips ("Linha de base pendente", …) overflow one line. FlowRow( Modifier.padding(top = 16.dp), - horizontalArrangement = Arrangement.spacedBy(6.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { chips.forEach { chip -> Text( @@ -467,7 +460,7 @@ fun HeroInsightCard(title: String, summary: String, chips: List, modif .clip(CircleShape) .dither(chip.tone.ditherColor(), if (chip.tone == ChipTone.NEUTRAL) 0.10f else 0.15f) .border(1.dp, chip.tone.border(), CircleShape) - .padding(horizontal = 10.dp, vertical = 5.dp), + .padding(horizontal = 12.dp, vertical = 4.dp), ) } } @@ -492,10 +485,10 @@ fun CoachMessageCard( .clip(shape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, shape) - .then(if (onTap != null) Modifier.clickable(onClick = onTap) else Modifier) + .then(if (onTap != null) Modifier.clickable(role = Role.Button, onClick = onTap) else Modifier) .padding(20.dp), ) { - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Box( Modifier .size(6.dp) @@ -505,10 +498,8 @@ fun CoachMessageCard( ) Text( tr("COACH"), - fontSize = 10.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 1.8.sp, - color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = PulseColors.textSecondary, ) } Text( @@ -516,26 +507,26 @@ fun CoachMessageCard( fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, - modifier = Modifier.padding(top = 6.dp), + modifier = Modifier.padding(top = 8.dp), ) Text( body, fontSize = 14.sp, lineHeight = 20.sp, color = PulseColors.textSecondary, - modifier = Modifier.padding(top = 6.dp), + modifier = Modifier.padding(top = 8.dp), ) if (chips.isNotEmpty()) { // Wraps rather than ellipsising the third chip to nothing on a narrow phone. FlowRow( - Modifier.padding(top = 10.dp), + Modifier.padding(top = 12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { chips.take(3).forEach { chip -> Text( chip, - fontSize = 11.sp, + fontSize = 12.sp, color = PulseColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -543,7 +534,7 @@ fun CoachMessageCard( .clip(CircleShape) .background(PulseColors.cardSoft) .border(1.dp, PulseColors.borderSubtle, CircleShape) - .padding(horizontal = 10.dp, vertical = 5.dp), + .padding(horizontal = 12.dp, vertical = 4.dp), ) } } diff --git a/app/src/main/java/com/pulseloop/ui/components/VitalCard.kt b/app/src/main/java/com/pulseloop/ui/components/VitalCard.kt index 135c2800..bf41696c 100644 --- a/app/src/main/java/com/pulseloop/ui/components/VitalCard.kt +++ b/app/src/main/java/com/pulseloop/ui/components/VitalCard.kt @@ -1,5 +1,6 @@ package com.pulseloop.ui.components +import androidx.compose.ui.semantics.Role import com.pulseloop.ui.i18n.tr import com.pulseloop.ui.theme.dither import androidx.compose.foundation.background @@ -51,7 +52,7 @@ fun VitalCard( onTap: (() -> Unit)? = null, content: @Composable () -> Unit, ) { - val shape = RoundedCornerShape(if (compact) 24.dp else 30.dp) + val shape = RoundedCornerShape(8.dp) // one card radius app-wide (was 24/30dp) val footerText = footerOverride ?: state.lastUpdatedText Surface( @@ -59,7 +60,7 @@ fun VitalCard( .fillMaxWidth() .clip(shape) .border(1.dp, MaterialTheme.colorScheme.onSurface.copy(alpha = 0.08f), shape) - .then(if (onTap != null) Modifier.clickable(onClick = onTap) else Modifier), + .then(if (onTap != null) Modifier.clickable(role = Role.Button, onClick = onTap) else Modifier), shape = shape, color = MaterialTheme.colorScheme.surfaceVariant, ) { @@ -98,9 +99,8 @@ private fun CardHeader(state: VitalCardState, compact: Boolean, footerText: Stri // used to be unweighted, so a long translated title could squeeze the footer to nothing. Text( state.title.uppercase(), - fontSize = 11.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 1.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis, @@ -111,7 +111,7 @@ private fun CardHeader(state: VitalCardState, compact: Boolean, footerText: Stri if (footerText != null && !compact && !state.isEstimated) { Text( footerText, - fontSize = 11.sp, + fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -126,14 +126,14 @@ private fun CardHeader(state: VitalCardState, compact: Boolean, footerText: Stri private fun EstimatedChip() { Text( tr("ESTIMATED"), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 0.8.sp, + color = ZonePalette.ZoneAmber, modifier = Modifier .clip(RoundedCornerShape(50)) .dither(ZonePalette.ZoneAmber, 0.14f) - .padding(horizontal = 8.dp, vertical = 3.dp), + .padding(horizontal = 8.dp, vertical = 4.dp), ) } @@ -141,11 +141,11 @@ private fun EstimatedChip() { @Composable private fun ValueRow(state: VitalCardState) { - Column(verticalArrangement = Arrangement.spacedBy(3.dp)) { - Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { + Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Text( state.valueText, - fontSize = 36.sp, + fontSize = 32.sp, fontWeight = FontWeight.SemiBold, fontFamily = com.pulseloop.ui.theme.UbuntuMono, color = MaterialTheme.colorScheme.onSurface, @@ -153,34 +153,34 @@ private fun ValueRow(state: VitalCardState) { if (state.unitText != null) { Text( state.unitText!!, - fontSize = 13.sp, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(bottom = 6.dp), + modifier = Modifier.padding(bottom = 8.dp), ) } } - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) { Text( state.statusText.uppercase(), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 0.8.sp, + color = state.statusToken.toColor(), // Wraps beside the trend instead of pushing it off the card. modifier = Modifier.weight(1f, fill = false), ) if (state.trend.deltaText != null) { - Row(horizontalArrangement = Arrangement.spacedBy(3.dp)) { + Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { Text( state.trend.symbol, - fontSize = 10.sp, + fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onSurfaceVariant, ) Text( state.trend.deltaText!!, - fontSize = 11.sp, + fontSize = 12.sp, fontWeight = FontWeight.Medium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/app/src/main/java/com/pulseloop/ui/components/VitalRingGauge.kt b/app/src/main/java/com/pulseloop/ui/components/VitalRingGauge.kt index 986cf1ef..a7bbad40 100644 --- a/app/src/main/java/com/pulseloop/ui/components/VitalRingGauge.kt +++ b/app/src/main/java/com/pulseloop/ui/components/VitalRingGauge.kt @@ -187,7 +187,7 @@ fun VitalRingGauge( if (centerUnit != null) { Text( centerUnit, - fontSize = (size.value * 0.08f).sp, + fontSize = maxOf(12f, size.value * 0.08f).sp, fontWeight = FontWeight.Medium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -195,7 +195,7 @@ fun VitalRingGauge( if (centerStatus != null) { Text( centerStatus.uppercase(), - fontSize = (size.value * 0.08f).sp, + fontSize = maxOf(12f, size.value * 0.08f).sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.sp, color = valueColor, @@ -209,7 +209,7 @@ fun VitalRingGauge( if (subtitle != null) { Text( subtitle, - fontSize = (size.value * 0.065f).sp, + fontSize = maxOf(12f, size.value * 0.065f).sp, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, maxLines = 2, diff --git a/app/src/main/java/com/pulseloop/ui/components/ZoneLineChart.kt b/app/src/main/java/com/pulseloop/ui/components/ZoneLineChart.kt index 31cb0f42..799c7439 100644 --- a/app/src/main/java/com/pulseloop/ui/components/ZoneLineChart.kt +++ b/app/src/main/java/com/pulseloop/ui/components/ZoneLineChart.kt @@ -172,12 +172,12 @@ fun ZoneLineChart( } if (showAxes) { Column( - Modifier.width(34.dp).fillMaxHeight().padding(start = 6.dp), + Modifier.width(34.dp).fillMaxHeight().padding(start = 8.dp), verticalArrangement = Arrangement.SpaceBetween, horizontalAlignment = Alignment.End, ) { listOf(yDomain.endInclusive, (yDomain.start + yDomain.endInclusive) / 2, yDomain.start).forEach { - Text("${it.toInt()}", fontSize = 11.sp, color = PulseColors.textMuted) + Text("${it.toInt()}", fontSize = 12.sp, color = PulseColors.textMuted) } } } @@ -188,7 +188,7 @@ fun ZoneLineChart( horizontalArrangement = Arrangement.SpaceBetween, ) { listOf(minTs, (minTs + maxTs) / 2, maxTs).forEach { - Text(timeLabel(it, span), fontSize = 11.sp, color = PulseColors.textMuted) + Text(timeLabel(it, span), fontSize = 12.sp, color = PulseColors.textMuted) } } } diff --git a/app/src/main/java/com/pulseloop/ui/screens/ActivityScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/ActivityScreen.kt index a4dfbd3f..94b3951c 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/ActivityScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/ActivityScreen.kt @@ -34,6 +34,8 @@ import androidx.compose.material.icons.filled.ExpandMore import androidx.compose.material.icons.filled.History import androidx.compose.material.icons.filled.Map import androidx.compose.material3.AlertDialog +import androidx.compose.material3.FilledTonalButton +import androidx.compose.material3.FilledTonalIconButton import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -167,44 +169,22 @@ fun ActivityScreen( item { DailyActivitySummaryCard(state, units) } item { - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) { - Text( - tr("+ Record Activity"), - fontSize = 17.sp, - fontWeight = FontWeight.SemiBold, - color = PulseColors.onAccent, - textAlign = androidx.compose.ui.text.style.TextAlign.Center, - modifier = Modifier - .weight(1f) - .height(60.dp) - .clip(CircleShape) - .background(PulseColors.accent) - .clickable(role = Role.Button) { pickerOpen = true } - .wrapContentHeight(), - ) - Box( - Modifier - .size(60.dp) - .clip(CircleShape) - .background(PulseColors.card) - .border(1.dp, PulseColors.borderSubtle, CircleShape) - .clickable(role = Role.Button) { historyOpen = true }, - contentAlignment = Alignment.Center, + // Tonal, not filled mint: the Actions button is the screen's one filled accent, and + // two filled CTAs side by side left no primary action to find. + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically) { + FilledTonalButton( + onClick = { pickerOpen = true }, + modifier = Modifier.weight(1f).height(56.dp), ) { - Icon(Icons.Filled.CalendarMonth, tr("Workout history"), tint = PulseColors.textSecondary) + Text(tr("+ Record Activity"), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, maxLines = 1) + } + FilledTonalIconButton(onClick = { historyOpen = true }, modifier = Modifier.size(56.dp)) { + Icon(Icons.Filled.CalendarMonth, tr("Workout history")) } // Logging a forgotten workout used to be its own full-width card between the // summary and the day's workouts; it is the same job as recording one. - Box( - Modifier - .size(60.dp) - .clip(CircleShape) - .background(PulseColors.card) - .border(1.dp, PulseColors.borderSubtle, CircleShape) - .clickable(role = Role.Button) { navController?.navigate("log_past_activity") }, - contentAlignment = Alignment.Center, - ) { - Icon(Icons.Filled.History, tr("Log Past Activity"), tint = PulseColors.textSecondary) + FilledTonalIconButton(onClick = { navController?.navigate("log_past_activity") }, modifier = Modifier.size(56.dp)) { + Icon(Icons.Filled.History, tr("Log Past Activity")) } } } @@ -214,8 +194,7 @@ fun ActivityScreen( item { Text( tr("TODAY"), - fontSize = 11.sp, fontWeight = FontWeight.Medium, - letterSpacing = 1.4.sp, color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary, ) } if (todayWorkouts.isEmpty()) { @@ -279,7 +258,7 @@ fun ActivityScreen( "You can allow it in Android Settings › Apps › PulseLoop › Permissions."), ) }, - confirmButton = { TextButton(onClick = { permissionDenied = false }) { Text("OK") } }, + confirmButton = { TextButton(onClick = { permissionDenied = false }) { Text(tr("OK")) } }, ) } if (pickerOpen) { @@ -419,14 +398,14 @@ private fun DailyActivitySummaryCard(state: ActivityViewModel.ActivityState, uni verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), ) { - Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(18.dp)) { + Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(16.dp)) { Row { SummaryMetric(tr("Steps"), today?.steps?.let { Formats.count(it) } ?: "—", null, PulseColors.steps, Modifier.weight(1f)) SummaryMetric(tr("Distance"), distValue ?: "—", if (distValue != null) UnitConverter.distanceUnit(units) else null, PulseColors.distance, Modifier.weight(1f)) } // The same figure the Today screen shows, not the row's raw `calories` (issue #101). val calories = state.dayCalories - SummaryMetric(tr("Calories"), calories?.let { Formats.count(it.toInt()) } ?: "—", if (calories != null) "cal" else null, PulseColors.calories) + SummaryMetric(tr("Calories"), calories?.let { Formats.count(it.toInt()) } ?: "—", if (calories != null) tr("kcal") else null, PulseColors.calories) } ActivityRings( rings = listOf( @@ -444,11 +423,10 @@ private fun DailyActivitySummaryCard(state: ActivityViewModel.ActivityState, uni @Composable private fun SummaryMetric(label: String, value: String, unit: String?, color: Color, modifier: Modifier = Modifier) { - Column(modifier, verticalArrangement = Arrangement.spacedBy(5.dp)) { + Column(modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) { Text( label.uppercase(), - fontSize = 15.sp, fontWeight = FontWeight.Bold, - letterSpacing = 0.6.sp, color = color, maxLines = 1, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = color, maxLines = 1, ) Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(4.dp)) { // weight(fill = false): bounded so the unit beside it is never squeezed off. @@ -458,7 +436,7 @@ private fun SummaryMetric(label: String, value: String, unit: String?, color: Co modifier = Modifier.weight(1f, fill = false), ) if (unit != null) { - Text(unit, fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textMuted, modifier = Modifier.padding(bottom = 5.dp)) + Text(unit, fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textMuted, modifier = Modifier.padding(bottom = 4.dp)) } } } @@ -478,7 +456,7 @@ fun ActivityWorkoutRow(session: ActivitySessionEntity, units: UnitSystem, onTap: .clip(shape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, shape) - .clickable(onClick = onTap) + .clickable(role = Role.Button, onClick = onTap) .padding(12.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), @@ -492,7 +470,7 @@ fun ActivityWorkoutRow(session: ActivitySessionEntity, units: UnitSystem, onTap: ) { Icon(ActivityMeta.icon(session.type), null, tint = PulseColors.accent, modifier = Modifier.size(20.dp)) } - Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) { + Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) { Row(verticalAlignment = Alignment.CenterVertically) { // The label takes the weight (not a Spacer) so a long translated type name // ellipsizes instead of squeezing the start time. @@ -502,7 +480,7 @@ fun ActivityWorkoutRow(session: ActivitySessionEntity, units: UnitSystem, onTap: maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f), ) - Text(SleepFormat.clockTime(session.startedAt), fontSize = 11.sp, color = PulseColors.textMuted) + Text(SleepFormat.clockTime(session.startedAt), fontSize = 12.sp, color = PulseColors.textMuted) } Row(horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically) { if (durationSec != null) { @@ -543,7 +521,7 @@ private fun WeeklyGoalCard(state: ActivityViewModel.ActivityState, days: List) { Column( Modifier.weight(1f), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Box( Modifier @@ -636,13 +608,13 @@ private fun WeeklyPillCalendar(days: List) { ) { Text( if (day.completed) "✓" else if (day.isToday) "•" else "", - fontSize = 10.sp, fontWeight = FontWeight.Medium, + fontSize = 12.sp, fontWeight = FontWeight.Medium, color = if (day.completed) PulseColors.steps else PulseColors.textPrimary, ) } Text( day.label, - fontSize = 11.sp, fontWeight = FontWeight.Medium, letterSpacing = 0.5.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = if (day.isToday) PulseColors.textPrimary else PulseColors.textMuted, ) } @@ -673,14 +645,14 @@ private fun RecordTypePickerDialog(onDismiss: () -> Unit, onStart: (String, Bool .clip(RoundedCornerShape(4.dp)) .then(if (active) Modifier.dither(PulseColors.accent, 0.18f) else Modifier.background(Color.Transparent)) .selectable(selected = active, role = Role.RadioButton) { selected = type } - .padding(horizontal = 10.dp, vertical = 8.dp), + .padding(horizontal = 12.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), ) { Icon(ActivityMeta.icon(type), null, tint = PulseColors.accent, modifier = Modifier.size(18.dp)) Column { Text(ActivityMeta.label(type), fontSize = 14.sp, fontWeight = FontWeight.Medium) - Text(ActivityMeta.helper(type), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) + Text(ActivityMeta.helper(type), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) } } } @@ -741,10 +713,8 @@ private fun WorkoutHistoryDialog( item(key = "header-$day") { Text( header(day), - fontSize = 11.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 1.4.sp, - color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = PulseColors.textSecondary, modifier = Modifier .fillMaxWidth() .padding(top = if (index == 0) 0.dp else 8.dp), @@ -852,12 +822,12 @@ private fun ActivityRecordsCard( ) { Text( "RECORDS", - fontSize = 11.sp, fontWeight = FontWeight.SemiBold, - letterSpacing = 1.sp, color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, + color = PulseColors.textSecondary, ) Spacer(Modifier.weight(1f)) buckets?.let { - Text(it.size.toString(), fontSize = 12.sp, color = PulseColors.textMuted, modifier = Modifier.padding(end = 6.dp)) + Text(it.size.toString(), fontSize = 12.sp, color = PulseColors.textMuted, modifier = Modifier.padding(end = 8.dp)) } Icon( if (expanded) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore, @@ -872,34 +842,34 @@ private fun ActivityRecordsCard( when { rows == null -> Text( tr("Loading…"), - fontSize = 13.sp, color = PulseColors.textMuted, + fontSize = 14.sp, color = PulseColors.textMuted, modifier = Modifier.padding(start = 16.dp, bottom = 12.dp), ) rows.isEmpty() -> Text( trf("No activity records synced for {0} yet.", dayLabel), - fontSize = 13.sp, color = PulseColors.textMuted, + fontSize = 14.sp, color = PulseColors.textMuted, modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp), ) else -> { // Not a nested LazyColumn — this card already sits inside one. rows.take(visibleCount).forEach { bucket -> Row( - Modifier.fillMaxWidth().padding(start = 16.dp, end = 6.dp, bottom = 4.dp), + Modifier.fillMaxWidth().padding(start = 16.dp, end = 8.dp, bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, ) { Text( timeOf(bucket.startEpoch), - fontSize = 13.sp, color = PulseColors.textSecondary, + fontSize = 14.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f), ) Text( trf("{0} steps", Formats.count(bucket.steps)), - fontSize = 13.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, ) if (bucket.distanceMeters > 0) { Text( tr(" · %.2f %s").format(UnitConverter.distance(bucket.distanceMeters, units), UnitConverter.distanceUnit(units)), - fontSize = 11.sp, color = PulseColors.textMuted, + fontSize = 12.sp, color = PulseColors.textMuted, ) } IconButton(onClick = { pending = bucket }) { @@ -917,7 +887,7 @@ private fun ActivityRecordsCard( onClick = { visibleCount += ACTIVITY_RECORDS_PAGE_SIZE }, modifier = Modifier.padding(start = 8.dp), ) { - Text(trf("Show {0} more", minOf(ACTIVITY_RECORDS_PAGE_SIZE, rows.size - visibleCount)), fontSize = 13.sp) + Text(trf("Show {0} more", minOf(ACTIVITY_RECORDS_PAGE_SIZE, rows.size - visibleCount)), fontSize = 14.sp) } } Spacer(Modifier.height(8.dp)) @@ -975,7 +945,7 @@ private fun DetectedActivityCard() { .border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(8.dp)).padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp), ) { - Text(tr("DETECTED · REVIEW"), fontSize = 11.sp, letterSpacing = 1.6.sp, color = PulseColors.textMuted) + Text(tr("DETECTED · REVIEW"), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary) proposals.forEach { p -> val defaultType = when (p.kind) { com.pulseloop.service.ActivityDetection.Proposal.Kind.WALK -> "walk" @@ -984,17 +954,17 @@ private fun DetectedActivityCard() { } var type by remember(p.key) { mutableStateOf(defaultType) } val isNap = p.kind == com.pulseloop.service.ActivityDetection.Proposal.Kind.NAP - Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { Text( (if (isNap) tr("Possible nap") else trf("Possible {0}", ActivityMeta.label(type).lowercase())) + " · ${p.minutes} min", - fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, + fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, ) Text( "${java.time.Instant.ofEpochMilli(p.startAt).atZone(zone).format(fmt)} · ${p.detail}", fontSize = 12.sp, color = PulseColors.textMuted, ) if (p.kind == com.pulseloop.service.ActivityDetection.Proposal.Kind.CARDIO) { - FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { listOf("cycle", "gym", "sport", "dance", "other").forEach { t -> val on = t == type Text( @@ -1002,7 +972,7 @@ private fun DetectedActivityCard() { color = if (on) PulseColors.onAccent else PulseColors.textSecondary, modifier = Modifier.clip(RoundedCornerShape(16.dp)) .background(if (on) PulseColors.accent else PulseColors.cardSoft) - .clickable { type = t }.padding(horizontal = 10.dp, vertical = 6.dp), + .clickable(role = Role.Button) { type = t }.padding(horizontal = 12.dp, vertical = 8.dp), ) } } @@ -1010,14 +980,14 @@ private fun DetectedActivityCard() { // FlowRow: the two translated actions wrap rather than overflow the card. FlowRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) { Text( - if (isNap) tr("Yes, a nap") else tr("Add workout"), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, - modifier = Modifier.clickable { + if (isNap) tr("Yes, a nap") else tr("Add workout"), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, + modifier = Modifier.clickable(role = Role.Button) { scope.launch { runCatching { com.pulseloop.service.ActivityDetection.accept(context, db, p, type) }; tick++ } }.padding(vertical = 4.dp), ) Text( - tr("Not this"), fontSize = 13.sp, color = PulseColors.textMuted, - modifier = Modifier.clickable { com.pulseloop.service.ActivityDetection.answer(context, p); tick++ }.padding(vertical = 4.dp), + tr("Not this"), fontSize = 14.sp, color = PulseColors.textMuted, + modifier = Modifier.clickable(role = Role.Button) { com.pulseloop.service.ActivityDetection.answer(context, p); tick++ }.padding(vertical = 4.dp), ) } } diff --git a/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt b/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt index 8ca3e279..355791d0 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt @@ -104,7 +104,7 @@ fun LogSheet( Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { when (shownStep) { LogStep.MENU -> { - Text(tr("Actions"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Actions"), fontSize = 20.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) SheetOption(tr("Ask the coach"), tr("About your day, a plan, a meal idea"), Icons.Filled.AutoAwesome, onCoach) Row(Modifier.fillMaxWidth().height(IntrinsicSize.Min), horizontalArrangement = Arrangement.spacedBy(8.dp)) { IconAction(tr("Meal"), Icons.Filled.Restaurant, PulseColors.calories) { step = LogStep.MEAL } @@ -116,7 +116,7 @@ fun LogSheet( SheetOption(tr("Workout"), tr("Start one now"), Icons.Filled.DirectionsRun, onWorkout) } LogStep.MEAL -> { - Text(tr("Log a meal"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Log a meal"), fontSize = 20.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) SheetOption(tr("Photo"), tr("Snap your plate; the AI estimates it"), Icons.Filled.CameraAlt) { onMeal("photo") } SheetOption(tr("Barcode"), tr("Scan a packaged food"), Icons.Filled.QrCodeScanner) { onMeal("barcode") } SheetOption(tr("Add by hand"), tr("Type the name and calories"), Icons.Filled.Add) { onMeal("add") } @@ -125,7 +125,7 @@ fun LogSheet( LogStep.TAGS -> JournalTagsCard(db, java.time.LocalDate.now(), tr("Tag your day"), allowYesterday = true) { Text( tr("See what affects you"), - fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, + fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, modifier = Modifier .heightIn(min = 48.dp) .clickable(role = Role.Button, onClick = onSeeEffects) @@ -150,10 +150,10 @@ private fun RowScope.IconAction(label: String, icon: androidx.compose.ui.graphic .clickable(role = Role.Button, onClick = onClick) .padding(horizontal = 4.dp, vertical = 12.dp), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterVertically), + verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically), ) { Icon(icon, null, tint = tint, modifier = Modifier.size(26.dp)) - Text(label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, textAlign = TextAlign.Center, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(label, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, textAlign = TextAlign.Center, maxLines = 1, overflow = TextOverflow.Ellipsis) } } @@ -168,7 +168,7 @@ private fun QuickDrinks(db: PulseLoopDatabase, onMore: () -> Unit) { } var logged by remember { mutableStateOf>?>(null) } - Text(tr("Log a drink"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Log a drink"), fontSize = 20.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) Row(Modifier.fillMaxWidth().height(IntrinsicSize.Min), horizontalArrangement = Arrangement.spacedBy(8.dp)) { types.forEach { t -> val shape = RoundedCornerShape(8.dp) @@ -176,15 +176,15 @@ private fun QuickDrinks(db: PulseLoopDatabase, onMore: () -> Unit) { Modifier.weight(1f).fillMaxHeight().clip(shape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, shape) - .clickable { + .clickable(role = Role.Button) { scope.launch { logged = t.short to DrinksRepository.log(db, t) } } .padding(horizontal = 4.dp, vertical = 12.dp), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Icon(t.icon, null, tint = PulseColors.drinks, modifier = Modifier.size(24.dp)) - Text(t.short, fontSize = 11.sp, color = PulseColors.textPrimary, textAlign = TextAlign.Center, maxLines = 2, overflow = TextOverflow.Ellipsis) + Text(t.short, fontSize = 12.sp, color = PulseColors.textPrimary, textAlign = TextAlign.Center, maxLines = 2, overflow = TextOverflow.Ellipsis) } } } @@ -193,18 +193,16 @@ private fun QuickDrinks(db: PulseLoopDatabase, onMore: () -> Unit) { val last = logged Text( if (last != null) trf("Logged {0}", last.first.lowercase()) else "", - fontSize = 13.sp, color = PulseColors.accent, modifier = Modifier.weight(1f), + fontSize = 14.sp, color = PulseColors.accent, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis, ) if (last != null) { - Text( - tr("Undo"), - fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, - maxLines = 1, - modifier = Modifier.clickable { - scope.launch { last.second.forEach { DrinksRepository.delete(db, it) }; logged = null } - }.padding(12.dp), - ) + androidx.compose.material3.TextButton( + onClick = { scope.launch { last.second.forEach { DrinksRepository.delete(db, it) }; logged = null } }, + modifier = Modifier.heightIn(min = 48.dp), + ) { + Text(tr("Undo"), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1) + } } } SheetOption(tr("More drinks"), tr("Other types, several at once, or earlier tonight"), Icons.Filled.LocalBar, onMore) 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 ee66183b..705d8a19 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt @@ -29,6 +29,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Share +import androidx.compose.material.icons.filled.ExpandMore import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -54,6 +55,7 @@ import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.liveRegion import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow @@ -106,15 +108,20 @@ internal fun Section( content = { if (collapsible) { Row( - Modifier.fillMaxWidth().heightIn(min = 40.dp).clickable(role = Role.Button) { open = !open }, + Modifier.fillMaxWidth().heightIn(min = 48.dp) + .clickable(role = Role.Button, onClickLabel = if (open) tr("Collapse") else tr("Expand")) { open = !open } + .semantics { stateDescription = if (open) tr("Expanded") else tr("Collapsed") }, verticalAlignment = Alignment.CenterVertically, ) { Column(Modifier.weight(1f)) { - Text(title, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(title, style = com.pulseloop.ui.theme.PulseType.title, color = PulseColors.textPrimary) if (!open) Text(summary!!, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 2, overflow = TextOverflow.Ellipsis) } val turn by androidx.compose.animation.core.animateFloatAsState(if (open) 180f else 0f, label = "chevron") - Text("⌄", fontSize = 18.sp, color = PulseColors.textMuted, modifier = Modifier.graphicsLayer { rotationZ = turn }) + Icon( + Icons.Filled.ExpandMore, contentDescription = null, tint = PulseColors.textMuted, + modifier = Modifier.size(24.dp).graphicsLayer { rotationZ = turn }, + ) } androidx.compose.animation.AnimatedVisibility( visible = open, @@ -124,7 +131,7 @@ internal fun Section( Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { content() } } } else { - Text(title.uppercase(), fontSize = 11.sp, letterSpacing = 1.6.sp, color = PulseColors.textMuted) + Text(title.uppercase(), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary) content() } }, @@ -139,7 +146,7 @@ internal fun Fact(label: String, value: String, note: String? = null, color: Col note?.let { Text(it, fontSize = 12.sp, color = PulseColors.textMuted) } } // Bounded: a translated value ("Moderada · 3h 20m") must not squeeze the label column. - Text(value, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = color, textAlign = TextAlign.End, modifier = Modifier.widthIn(max = 160.dp)) + Text(value, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = color, textAlign = TextAlign.End, modifier = Modifier.widthIn(max = 160.dp)) } } @@ -151,9 +158,16 @@ private fun ratingColor(r: HealthArea.Rating) = when (r) { } @Composable -private fun Sparkline(values: List, color: Color, modifier: Modifier = Modifier.fillMaxWidth().height(40.dp)) { +private fun Sparkline(values: List, color: Color, modifier: Modifier = Modifier.fillMaxWidth().height(40.dp), label: String = "") { if (values.size < 2) return - Canvas(modifier) { + // TalkBack hears the direction, like every other chart in the app; the line itself says nothing. + val first = values.first(); val last = values.last() + val direction = when { + last > first * 1.05 -> tr("trending up") + last < first * 0.95 -> tr("trending down") + else -> tr("steady") + } + Canvas(modifier.semantics { contentDescription = listOf(label, direction).filter { it.isNotEmpty() }.joinToString(", ") }) { val min = values.min(); val max = values.max() val range = (max - min).takeIf { it > 0 } ?: 1.0 val path = Path() @@ -166,6 +180,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 = {}) { val context = LocalContext.current @@ -180,99 +195,94 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: () var restUntil by remember { mutableStateOf(RestMode.until(context)) } Column(Modifier.fillMaxSize().background(PulseColors.background)) { - Box(Modifier.fillMaxWidth().padding(vertical = 4.dp)) { - IconButton(onClick = onBack, modifier = Modifier.align(Alignment.CenterStart)) { Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back")) } - Text(tr("My Health"), modifier = Modifier.align(Alignment.Center), fontSize = 17.sp, fontWeight = FontWeight.Bold) - val shareScope = rememberCoroutineScope() - IconButton( - onClick = { - shareScope.launch { - runCatching { - val recap = com.pulseloop.service.WeeklyRecap.load(db) - val uri = com.pulseloop.service.WeeklyRecap.share(context, recap) - val intent = android.content.Intent(android.content.Intent.ACTION_SEND).apply { - type = "image/png" - putExtra(android.content.Intent.EXTRA_STREAM, uri) - addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION) + val shareScope = rememberCoroutineScope() + androidx.compose.material3.CenterAlignedTopAppBar( + title = { Text(tr("My Health"), style = com.pulseloop.ui.theme.PulseType.title) }, + navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back")) } }, + actions = { + IconButton( + onClick = { + shareScope.launch { + runCatching { + val recap = com.pulseloop.service.WeeklyRecap.load(db) + val uri = com.pulseloop.service.WeeklyRecap.share(context, recap) + val intent = android.content.Intent(android.content.Intent.ACTION_SEND).apply { + type = "image/png" + putExtra(android.content.Intent.EXTRA_STREAM, uri) + addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION) + } + context.startActivity(android.content.Intent.createChooser(intent, tr("Share my week"))) } - context.startActivity(android.content.Intent.createChooser(intent, tr("Share my week"))) } - } - }, - modifier = Modifier.align(Alignment.CenterEnd), - ) { Icon(androidx.compose.material.icons.Icons.Filled.Share, tr("Share my week"), tint = PulseColors.textSecondary) } - } - Column( - Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 8.dp), + }, + ) { Icon(androidx.compose.material.icons.Icons.Filled.Share, tr("Share my week"), tint = PulseColors.textSecondary) } + }, + windowInsets = androidx.compose.foundation.layout.WindowInsets(0, 0, 0, 0), + colors = androidx.compose.material3.TopAppBarDefaults.topAppBarColors(containerColor = PulseColors.background), + ) + // Lazy: each section composes as it scrolls in, instead of every chart and DB read at once. + androidx.compose.foundation.lazy.LazyColumn( + Modifier.fillMaxSize(), + contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(12.dp), ) { val s = snap if (s == null) { - if (loadFailed) { - Text(tr("Couldn't load your health history."), color = PulseColors.warning, fontSize = 13.sp) - } else { - // Only after a moment: on a quick read the line would just flash before the cards. - var slow by remember { mutableStateOf(false) } - LaunchedEffect(Unit) { delay(400); slow = true } - if (slow) Text(tr("Reading your history…"), color = PulseColors.textMuted, fontSize = 13.sp) + item { + if (loadFailed) { + Text(tr("Couldn't load your health history."), color = PulseColors.warning, fontSize = 14.sp) + } else { + // Only after a moment: on a quick read the line would just flash before the cards. + var slow by remember { mutableStateOf(false) } + LaunchedEffect(Unit) { delay(400); slow = true } + if (slow) Text(tr("Reading your history…"), color = PulseColors.textMuted, fontSize = 14.sp) + } } } else { // Overview first: is anything off, then the long view, then the tools to dig in. // Programs (cycle, meds, postpartum) live on Today and in "+ Log" now, and the // day's sleep, heart and stress detail on their own tabs. - RadarSection(s.radar, restUntil) { days -> - RestMode.set(context, days); restUntil = RestMode.until(context) + item { + RadarSection(s.radar, restUntil) { days -> + RestMode.set(context, days); restUntil = RestMode.until(context) + } } - if (s.areas.isNotEmpty()) { + if (s.areas.isNotEmpty()) item { Section(tr("Health areas · last 60–90 days")) { s.areas.forEach { a -> Row(verticalAlignment = Alignment.CenterVertically) { Column(Modifier.weight(1f)) { - Text(a.title, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - Text(a.detail, fontSize = 12.sp, color = PulseColors.textMuted) + Text(a.title, style = com.pulseloop.ui.theme.PulseType.title, color = PulseColors.textPrimary) + Text(a.detail, fontSize = 12.sp, color = PulseColors.textSecondary) } - Text(a.rating.label, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = ratingColor(a.rating), textAlign = TextAlign.End, maxLines = 2, modifier = Modifier.widthIn(max = 120.dp)) + Text(a.rating.label, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = ratingColor(a.rating), textAlign = TextAlign.End, maxLines = 2, modifier = Modifier.widthIn(max = 120.dp)) } - Sparkline(a.trend, ratingColor(a.rating)) + Sparkline(a.trend, ratingColor(a.rating), label = a.title) } } } - TrendsSection(db) - HabitsSection(s.habits, s.cardio) - StressSection(s, onBreathe) - Row( - Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card) - .clickable(onClick = onWhatChanged).padding(16.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Column(Modifier.weight(1f)) { - Text(tr("What changed"), fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - Text(tr("Your nights against your own normal, kept as a log"), fontSize = 12.sp, color = PulseColors.textMuted) - } - Text("›", fontSize = 22.sp, color = PulseColors.textMuted) - } + item { TrendsSection(db) } + item { HabitsSection(s.habits, s.cardio) } + item { StressSection(s, onBreathe) } + item { MyHealthLink(tr("What changed"), tr("Your nights against your own normal, kept as a log"), onWhatChanged) } // Lab reports (LabReportsUi.kt): the PDFs the user added, every marker charted by exam. - Row( - Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card) - .clickable(onClick = onLabReports).padding(16.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Column(Modifier.weight(1f)) { - Text(tr("Lab reports"), fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - Text(tr("Blood, urine and any other lab report, charted exam by exam"), fontSize = 12.sp, color = PulseColors.textMuted) - } - Text("›", fontSize = 22.sp, color = PulseColors.textMuted) + item { MyHealthLink(tr("Lab reports"), tr("Blood, urine and any other lab report, charted exam by exam"), onLabReports) } + item { + Text( + tr("Estimates from your ring compared with your own recent normal, not medical measurements."), + fontSize = 14.sp, color = PulseColors.textSecondary, + ) } - Text( - tr("Estimates from your ring compared with your own recent normal, not medical measurements."), - fontSize = 11.sp, color = PulseColors.textMuted, - ) - Spacer(Modifier.height(24.dp)) + item { Spacer(Modifier.height(24.dp)) } } } } } +/** A row that opens a deeper My Health screen. */ +@Composable +private fun MyHealthLink(title: String, subtitle: String, onClick: () -> Unit) = MyHealthEntryCard(title, subtitle, onClick) + @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. @@ -283,7 +293,7 @@ private fun RadarSection(r: SymptomRadar.Result?, restUntil: java.time.LocalDate } + if (restUntil != null) " · " + tr("Rest Mode on") else "" Section(tr("Symptom Radar"), summary = if (flagged) null else quiet) { if (r == null || r.baselineNights < SymptomRadar.MIN_BASELINE) { - Text(trf("Learning your normal: {0} of {1} nights.", r?.baselineNights ?: 0, SymptomRadar.MIN_BASELINE), fontSize = 13.sp, color = PulseColors.textSecondary) + Text(trf("Learning your normal: {0} of {1} nights.", r?.baselineNights ?: 0, SymptomRadar.MIN_BASELINE), fontSize = 14.sp, color = PulseColors.textSecondary) } else { val color = when (r.level) { SymptomRadar.Level.NONE -> PulseColors.success @@ -291,7 +301,7 @@ private fun RadarSection(r: SymptomRadar.Result?, restUntil: java.time.LocalDate SymptomRadar.Level.MAJOR -> PulseColors.danger } Text(r.level.label, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = color) - Text(r.level.summary, fontSize = 13.sp, color = PulseColors.textSecondary) + Text(r.level.summary, fontSize = 14.sp, color = PulseColors.textSecondary) // When nothing is flagged the headline says so; five "Normal" rows under it were noise. if (r.level != SymptomRadar.Level.NONE) r.signals.forEach { sig -> Fact(sig.metric.title, if (sig.flagged) tr("Elevated") else tr("Normal"), sig.detail, @@ -303,7 +313,7 @@ private fun RadarSection(r: SymptomRadar.Result?, restUntil: java.time.LocalDate } Row(Modifier.switchRow(checked = restUntil != null, onCheckedChange = { on -> onRest(if (on) 3 else null) }), verticalAlignment = Alignment.CenterVertically) { Column(Modifier.weight(1f)) { - Text(tr("Rest Mode"), fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Rest Mode"), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) Text( restUntil?.let { trf("On until {0}/{1}: activity nudges paused, the coach eases off.", it.dayOfMonth, it.monthValue) } ?: tr("Feeling unwell? Pause activity nudges for 3 days."), @@ -359,7 +369,7 @@ private fun Legend(color: Color, label: String) { Row(verticalAlignment = Alignment.CenterVertically) { Box(Modifier.size(8.dp).clip(CircleShape).background(color)) Spacer(Modifier.width(4.dp)) - Text(label, fontSize = 11.sp, color = PulseColors.textMuted) + Text(label, fontSize = 12.sp, color = PulseColors.textMuted) } } @@ -430,16 +440,16 @@ private fun TrendsSection(db: PulseLoopDatabase) { value = TrendLoad(m, p, runCatching { Trends.aggregate(HealthInsightsRepository.daily(db, m, p.days), p) }.getOrNull()) } Section(tr("Trends"), summary = tr("Sleep, steps, heart and more, from a week to a year")) { - Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).selectableGroup(), horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).selectableGroup(), horizontalArrangement = Arrangement.spacedBy(8.dp)) { TrendMetric.entries.forEach { m -> val on = m == metric Text(m.label, fontSize = 12.sp, color = if (on) PulseColors.onAccent else PulseColors.textSecondary, modifier = Modifier.minimumInteractiveComponentSize().clip(RoundedCornerShape(16.dp)) .background(if (on) PulseColors.accent else PulseColors.cardSoft) - .selectable(selected = on, role = Role.Tab) { metric = m }.padding(horizontal = 10.dp, vertical = 6.dp)) + .selectable(selected = on, role = Role.Tab) { metric = m }.padding(horizontal = 12.dp, vertical = 8.dp)) } } - Row(Modifier.fillMaxWidth().selectableGroup(), horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Row(Modifier.fillMaxWidth().selectableGroup(), horizontalArrangement = Arrangement.spacedBy(8.dp)) { Trends.Period.entries.forEach { p -> val on = p == period Text(p.label, fontSize = 12.sp, color = if (on) PulseColors.textPrimary else PulseColors.textMuted, @@ -447,7 +457,7 @@ private fun TrendsSection(db: PulseLoopDatabase) { modifier = Modifier.weight(1f).minimumInteractiveComponentSize().clip(RoundedCornerShape(4.dp)) .then(if (on) Modifier.dither(PulseColors.accent, 0.18f) else Modifier) .border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(4.dp)) - .selectable(selected = on, role = Role.Tab) { period = p }.padding(vertical = 6.dp), + .selectable(selected = on, role = Role.Tab) { period = p }.padding(vertical = 8.dp), textAlign = androidx.compose.ui.text.style.TextAlign.Center) } } @@ -532,7 +542,7 @@ fun BreatheScreen(onBack: () -> Unit) { IconButton(onClick = { if (startedAt != null) finish(); onBack() }, modifier = Modifier.align(Alignment.CenterStart)) { Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back")) } - Text(tr("Breathe"), modifier = Modifier.align(Alignment.Center), fontSize = 17.sp, fontWeight = FontWeight.Bold) + Text(tr("Breathe"), modifier = Modifier.align(Alignment.Center), fontSize = 16.sp, fontWeight = FontWeight.Bold) } Spacer(Modifier.weight(1f)) val r = result @@ -553,7 +563,7 @@ fun BreatheScreen(onBack: () -> Unit) { Box(Modifier.size(220.dp).scale(s).clip(CircleShape).dither(PulseColors.accent, 0.35f, CircleShape).border(2.dp, PulseColors.accent, CircleShape)) Spacer(Modifier.height(24.dp)) Text( - if (inhaling) tr("Breathe in") else tr("Breathe out"), fontSize = 18.sp, color = PulseColors.textPrimary, + if (inhaling) tr("Breathe in") else tr("Breathe out"), fontSize = 20.sp, color = PulseColors.textPrimary, modifier = Modifier.semantics { liveRegion = LiveRegionMode.Polite }, ) Text("%d:%02d".format(remaining / 60, remaining % 60), fontSize = 28.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) @@ -561,10 +571,10 @@ fun BreatheScreen(onBack: () -> Unit) { OutlinedButton(onClick = { finish() }) { Text(tr("End session")) } } r != null -> { - Text(tr("Session saved"), fontSize = 22.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - Text("${r.minutes} min" + (r.avgHr?.let { trf(" · average {0} bpm", it) } ?: ""), fontSize = 15.sp, color = PulseColors.textSecondary) + Text(tr("Session saved"), fontSize = 24.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text("${r.minutes} min" + (r.avgHr?.let { trf(" · average {0} bpm", it) } ?: ""), fontSize = 16.sp, color = PulseColors.textSecondary) if (r.startHr != null && r.endHr != null) { - Text(trf("Heart rate {0} → {1} bpm", r.startHr, r.endHr), fontSize = 15.sp, color = PulseColors.textSecondary) + Text(trf("Heart rate {0} → {1} bpm", r.startHr, r.endHr), fontSize = 16.sp, color = PulseColors.textSecondary) } else { Text(tr("Your ring logs heart rate every few minutes, so short sessions may show none."), fontSize = 12.sp, color = PulseColors.textMuted) } @@ -573,7 +583,7 @@ fun BreatheScreen(onBack: () -> Unit) { Button(onClick = onBack) { Text(tr("Done")) } } else -> { - Text(tr("Slow breathing: in for 4 seconds, out for 6."), fontSize = 15.sp, color = PulseColors.textSecondary) + Text(tr("Slow breathing: in for 4 seconds, out for 6."), fontSize = 16.sp, color = PulseColors.textSecondary) Spacer(Modifier.height(16.dp)) Row(Modifier.selectableGroup(), horizontalArrangement = Arrangement.spacedBy(8.dp)) { listOf(1, 3, 5, 10).forEach { m -> @@ -581,7 +591,7 @@ fun BreatheScreen(onBack: () -> Unit) { Text("$m min", fontSize = 14.sp, color = if (on) PulseColors.onAccent else PulseColors.textPrimary, modifier = Modifier.minimumInteractiveComponentSize().clip(RoundedCornerShape(16.dp)) .background(if (on) PulseColors.accent else PulseColors.card) - .selectable(selected = on, role = Role.RadioButton) { minutes = m }.padding(horizontal = 14.dp, vertical = 8.dp)) + .selectable(selected = on, role = Role.RadioButton) { minutes = m }.padding(horizontal = 16.dp, vertical = 8.dp)) } } Spacer(Modifier.height(24.dp)) @@ -604,14 +614,14 @@ private const val INHALE_MS = 4_000L fun MyHealthEntryCard(title: String, subtitle: String, onClick: () -> Unit) { Row( Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card) - .clickable(onClick = onClick).padding(16.dp), + .clickable(role = Role.Button, onClick = onClick).padding(16.dp), verticalAlignment = Alignment.CenterVertically, ) { Column(Modifier.weight(1f)) { - Text(title, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(title, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) Text(subtitle, fontSize = 12.sp, color = PulseColors.textMuted) } - Text("›", fontSize = 22.sp, color = PulseColors.textMuted) + com.pulseloop.ui.components.Chevron() } } @@ -642,7 +652,7 @@ internal fun StepCalibrationCard(db: PulseLoopDatabase) { Section(tr("Ring steps vs your phone")) { when { !granted -> { - Text(tr("Your phone counts steps too. Comparing the two over a few days shows whether your ring over- or under-counts."), fontSize = 13.sp, color = PulseColors.textSecondary) + Text(tr("Your phone counts steps too. Comparing the two over a few days shows whether your ring over- or under-counts."), fontSize = 14.sp, color = PulseColors.textSecondary) OutlinedButton(onClick = { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) launcher.launch(android.Manifest.permission.ACTIVITY_RECOGNITION) }, modifier = Modifier.fillMaxWidth()) { Text(tr("Compare with my phone")) } @@ -650,7 +660,7 @@ internal fun StepCalibrationCard(db: PulseLoopDatabase) { !resultLoaded -> Spacer(Modifier.height(36.dp)) result == null -> Text( trf("Collecting: needs {0} days with at least {1} steps on both. Carry your phone as usual.", com.pulseloop.service.StepCalibration.MIN_DAYS, com.pulseloop.service.StepCalibration.MIN_STEPS), - fontSize = 13.sp, color = PulseColors.textMuted, + fontSize = 14.sp, color = PulseColors.textMuted, ) else -> { val r = result!! @@ -664,10 +674,10 @@ internal fun StepCalibrationCard(db: PulseLoopDatabase) { fontSize = 14.sp, color = PulseColors.textPrimary, ) Row(verticalAlignment = Alignment.CenterVertically) { - Text(tr("Show phone-calibrated steps on Today"), fontSize = 13.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f)) + Text(tr("Show phone-calibrated steps on Today"), fontSize = 14.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f)) Switch(checked = applied, onCheckedChange = { applied = it; com.pulseloop.service.StepCalibration.setApplied(context, it) }) } - Text(tr("Goals, scores and Health Connect keep the ring's own count."), fontSize = 11.sp, color = PulseColors.textMuted) + Text(tr("Goals, scores and Health Connect keep the ring's own count."), fontSize = 12.sp, color = PulseColors.textMuted) } } } diff --git a/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt index 0bcce289..a3781528 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt @@ -55,6 +55,9 @@ fun NutritionScreen( onDiscuss: ((String) -> Unit)? = null, /** Shown as a tab: the app header sits above it, so no bar or back arrow of its own. */ asTab: Boolean = false, + /** As a tab: the glass bars' heights, so the list scrolls under them like the other tabs. */ + topBarPadding: androidx.compose.ui.unit.Dp = 0.dp, + bottomBarPadding: androidx.compose.ui.unit.Dp = 0.dp, ) { val context = androidx.compose.ui.platform.LocalContext.current val scope = rememberCoroutineScope() @@ -135,11 +138,12 @@ fun NutritionScreen( Modifier.fillMaxSize().padding(padding), verticalArrangement = Arrangement.spacedBy(12.dp), // As a tab, the last card scrolls clear of the Actions button. - contentPadding = PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = if (asTab) 88.dp else 16.dp), + contentPadding = PaddingValues( + start = 16.dp, top = 16.dp + topBarPadding, end = 16.dp, + bottom = if (asTab) 16.dp + bottomBarPadding else 16.dp, + ), ) { - if (asTab) item { - Text(tr("Nutrition"), fontSize = 28.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - } + // No title as a tab: the tab bar names the screen, as on the other four tabs. // Day navigation — left goes to older dates (higher offset), right goes to today (offset 0). item { Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) { @@ -183,45 +187,29 @@ fun NutritionScreen( // not below every meal of the day. // AI log actions (iOS logActions, NutritionView.swift:114-125): Photo opens the // analysis sheet in camera mode, Describe in describe mode. - if (coachEnabled) { - item { - // Half-width buttons: tighter padding and up to two lines for a long translation, - // equal heights so a wrapped label doesn't leave the pair misaligned. - Row(Modifier.fillMaxWidth().height(IntrinsicSize.Min), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - OutlinedButton( - onClick = { analysisRequest = AnalysisRequest(startWithCamera = true) }, - modifier = Modifier.weight(1f).fillMaxHeight(), - contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), - ) { - Icon(Icons.Filled.PhotoCamera, null, Modifier.size(18.dp)) - Spacer(Modifier.width(6.dp)) - Text(tr("Photo"), maxLines = 2, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center) + // One logging row for the day shown (the Actions button logs "now"; this one also + // reaches the earlier days the arrows open): Log meal, plus the AI ways in as icons. + item { + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) { + OutlinedButton( + onClick = { showAddDialog = true }, + modifier = Modifier.weight(1f).heightIn(min = 48.dp), + ) { + Icon(Icons.Filled.Add, null, Modifier.size(18.dp)) + Spacer(Modifier.width(8.dp)) + Text(tr("Log Meal"), maxLines = 1, overflow = TextOverflow.Ellipsis) + } + if (coachEnabled) { + FilledTonalIconButton(onClick = { analysisRequest = AnalysisRequest(startWithCamera = true) }, modifier = Modifier.size(48.dp)) { + Icon(Icons.Filled.PhotoCamera, tr("Photo")) } - OutlinedButton( - onClick = { analysisRequest = AnalysisRequest(startWithCamera = false) }, - modifier = Modifier.weight(1f).fillMaxHeight(), - contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), - ) { - Icon(Icons.Filled.AutoAwesome, null, Modifier.size(18.dp)) - Spacer(Modifier.width(6.dp)) - Text(tr("Describe"), maxLines = 2, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center) + FilledTonalIconButton(onClick = { analysisRequest = AnalysisRequest(startWithCamera = false) }, modifier = Modifier.size(48.dp)) { + Icon(Icons.Filled.AutoAwesome, tr("Describe")) } } } } - // Add button - item { - OutlinedButton( - onClick = { showAddDialog = true }, - modifier = Modifier.fillMaxWidth(), - ) { - Icon(Icons.Filled.Add, null, Modifier.size(18.dp)) - Spacer(Modifier.width(6.dp)) - Text(tr("Log Meal")) - } - } - // Next-meal idea, once a third of the day's target is eaten (today only). val eatenToday = totals.sumOf { it.totalCal } val targetToday = goal?.intakeCalories ?: 2000.0 @@ -385,7 +373,7 @@ private fun MacroBar(label: String, value: Double, goal: Double, color: Color, m // Equal thirds, so a long translated macro name ellipsizes instead of crowding its neighbours. Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) { Text(label, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 1, overflow = TextOverflow.Ellipsis) - Text("${value.roundToInt()}g", fontSize = 13.sp, fontWeight = FontWeight.SemiBold) + Text("${value.roundToInt()}g", fontSize = 14.sp, fontWeight = FontWeight.SemiBold) LinearProgressIndicator( progress = { pct.toFloat() }, modifier = Modifier.width(60.dp).height(4.dp), @@ -664,22 +652,22 @@ private fun NextMealCard( border = androidx.compose.foundation.BorderStroke(1.dp, PulseColors.accent), ) { Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - Text(trf("NEXT MEAL IDEA · {0}", idea.slot.uppercase()), fontSize = 11.sp, letterSpacing = 1.4.sp, color = PulseColors.accent) + Text(trf("NEXT MEAL IDEA · {0}", idea.slot.uppercase()), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.accent) if (idea.items.isEmpty()) { Text(idea.note ?: "", fontSize = 14.sp, color = PulseColors.textPrimary) } else { idea.items.forEach { item -> Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { Column(Modifier.weight(1f)) { - Text(item.name, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary) + Text(item.name, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary) Text("${item.english} · ${item.portion}", fontSize = 12.sp, color = PulseColors.textMuted) } - Text("${item.kcal} kcal", fontSize = 13.sp, color = PulseColors.textSecondary) + Text("${item.kcal} kcal", fontSize = 14.sp, color = PulseColors.textSecondary) } } Text( trf("≈ {0} kcal · {1} g protein · leaves {2} kcal", idea.totalKcal, idea.totalProteinG, idea.leavesKcal), - fontSize = 13.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, ) if (idea.fromPreferences.isNotEmpty()) { Text(tr("Your preference: ") + idea.fromPreferences.joinToString("; "), fontSize = 12.sp, color = PulseColors.accent) diff --git a/app/src/main/java/com/pulseloop/ui/screens/ReadinessUi.kt b/app/src/main/java/com/pulseloop/ui/screens/ReadinessUi.kt index f86e415b..2b54e836 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/ReadinessUi.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/ReadinessUi.kt @@ -137,17 +137,18 @@ private fun HeaderRing( onTap: () -> Unit, modifier: Modifier, centerText: String = value?.toString() ?: "—", + ringSize: androidx.compose.ui.unit.Dp = 84.dp, ) { Column( - modifier.clip(RoundedCornerShape(8.dp)).clickable(onClick = onTap).padding(vertical = 8.dp), + modifier.clip(RoundedCornerShape(8.dp)).clickable(role = androidx.compose.ui.semantics.Role.Button, onClick = onTap).padding(vertical = 8.dp), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { - ScoreRing(value = value, color = color, size = 84.dp, stroke = 7.dp, centerText = centerText) + ScoreRing(value = value, color = color, size = ringSize, stroke = 7.dp, centerText = centerText, centerSize = if (ringSize >= 100.dp) 28 else 20) // One line each, ellipsised: three rings share the row, and a voice's caption // ("Ainda sem sono. Óbvio.") is wider than a third of a phone. - Text(label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1, overflow = TextOverflow.Ellipsis) - Text(caption, fontSize = 11.sp, color = PulseColors.textMuted, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(label, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(caption, fontSize = 12.sp, color = PulseColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis) } } @@ -171,7 +172,19 @@ fun ScoreHeader( Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card).padding(12.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) { + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) { + // Readiness is the headline score: the larger ring in the centre, with sleep and + // activity as the two smaller rings that feed it, so the card has one entry point. + HeaderRing( + label = tr("Sleep"), + value = sleepScore, + caption = sleepScore?.let { Readiness.Band.of(it).label } ?: if (sleepLoaded) tr("No data") else " ", + color = PulseColors.sleep, + onTap = onSleep, + modifier = Modifier.weight(1f), + ringSize = 72.dp, + centerText = sleepScore?.toString() ?: if (sleepLoaded) "—" else "", + ) HeaderRing( label = tr("Readiness"), value = score?.value, @@ -184,19 +197,11 @@ fun ScoreHeader( }, color = score?.let { bandColor(it.band) } ?: PulseColors.readiness, onTap = onReadiness, - modifier = Modifier.weight(1f), + modifier = Modifier.weight(1.3f), + ringSize = 108.dp, // null is still loading (as the blank caption above): no "no score" dash yet. centerText = score?.value?.toString() ?: if (readiness == null) "" else "—", ) - HeaderRing( - label = tr("Sleep"), - value = sleepScore, - caption = sleepScore?.let { Readiness.Band.of(it).label } ?: if (sleepLoaded) tr("No data") else " ", - color = PulseColors.sleep, - onTap = onSleep, - modifier = Modifier.weight(1f), - centerText = sleepScore?.toString() ?: if (sleepLoaded) "—" else "", - ) HeaderRing( label = tr("Activity"), value = activity?.value, @@ -204,6 +209,7 @@ fun ScoreHeader( color = PulseColors.steps, onTap = onActivity, modifier = Modifier.weight(1f), + ringSize = 72.dp, centerText = activity?.value?.toString() ?: if (activityLoaded) "—" else "", ) } @@ -237,21 +243,19 @@ private fun ProgressBar(fraction: Float, color: Color, modifier: Modifier = Modi } /** Readiness detail: score, sentence, coverage caution, contributors, and what's missing. */ +@OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class) @Composable fun ReadinessScreen(db: PulseLoopDatabase, onBack: () -> Unit) { val load = rememberReadinessLoad(db, Unit) val result = load.value Column(Modifier.fillMaxSize()) { - Box(Modifier.fillMaxWidth().padding(vertical = 4.dp)) { - IconButton(onClick = onBack, modifier = Modifier.align(Alignment.CenterStart)) { - Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back")) - } - Text( - tr("Readiness"), modifier = Modifier.align(Alignment.Center), - style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold, - ) - } + androidx.compose.material3.CenterAlignedTopAppBar( + title = { Text(tr("Readiness"), style = com.pulseloop.ui.theme.PulseType.title) }, + navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back")) } }, + windowInsets = androidx.compose.foundation.layout.WindowInsets(0, 0, 0, 0), + colors = androidx.compose.material3.TopAppBarDefaults.topAppBarColors(containerColor = PulseColors.background), + ) Column( Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 8.dp), @@ -277,7 +281,7 @@ fun ReadinessScreen(db: PulseLoopDatabase, onBack: () -> Unit) { } if (result != null) { Text( - ReadinessCopy.headline(result), fontSize = 15.sp, color = PulseColors.textSecondary, + ReadinessCopy.headline(result), fontSize = 16.sp, color = PulseColors.textSecondary, textAlign = TextAlign.Center, ) } @@ -288,7 +292,7 @@ fun ReadinessScreen(db: PulseLoopDatabase, onBack: () -> Unit) { score?.let { ReadinessCopy.coverageNote(it) }?.let { note -> Text( - note, fontSize = 13.sp, color = PulseColors.warning, + note, fontSize = 14.sp, color = PulseColors.warning, modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(4.dp)) .dither(PulseColors.warning, 0.12f).padding(12.dp), ) @@ -307,10 +311,10 @@ fun ReadinessScreen(db: PulseLoopDatabase, onBack: () -> Unit) { if (result is Readiness.Result.Withheld) { Column( Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card).padding(16.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { - Text(tr("Why there's no score today"), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textMuted) - result.reasons.forEach { Text("• $it", fontSize = 13.sp, color = PulseColors.textSecondary) } + Text(tr("Why there's no score today"), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textMuted) + result.reasons.forEach { Text("• $it", fontSize = 14.sp, color = PulseColors.textSecondary) } } } @@ -328,7 +332,7 @@ fun ContributorsCard(contributors: List, title: String = tr("C if (contributors.isEmpty()) return var expanded by remember(contributors) { mutableStateOf(null) } Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { - Text(title, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textMuted) + Text(title, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textMuted) Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card)) { contributors.forEachIndexed { i, c -> ContributorRow(c, expanded == c.title) { expanded = if (expanded == c.title) null else c.title } @@ -347,16 +351,16 @@ private fun ContributorRow(c: ScoreContributor, expanded: Boolean, onTap: () -> .clickable(role = Role.Button, onClick = onTap) .semantics { stateDescription = if (expanded) tr("Expanded") else tr("Collapsed") } .padding(horizontal = 16.dp, vertical = 12.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { - Text(c.title, fontSize = 15.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, modifier = Modifier.weight(1f)) - Text(c.band.label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = bandColor(c.band)) + Text(c.title, fontSize = 16.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, modifier = Modifier.weight(1f)) + Text(c.band.label, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = bandColor(c.band)) } ProgressBar(c.score / 100f, bandColor(c.band)) Text(c.detail, fontSize = 12.sp, color = PulseColors.textSecondary) if (expanded) { - Text(c.explanation, fontSize = 13.sp, color = PulseColors.textSecondary, modifier = Modifier.padding(top = 4.dp)) + Text(c.explanation, fontSize = 14.sp, color = PulseColors.textSecondary, modifier = Modifier.padding(top = 4.dp)) } } } @@ -408,7 +412,7 @@ fun ActivityScoreScreen(db: PulseLoopDatabase, onBack: () -> Unit, onOpenActivit // Blank while loading: activityHeadline(null) is the "no activity yet" copy, // which flashed before every real score. if (load.loaded) activityHeadline(result) else " ", - fontSize = 15.sp, color = PulseColors.textSecondary, + fontSize = 16.sp, color = PulseColors.textSecondary, textAlign = TextAlign.Center, ) } @@ -452,11 +456,11 @@ private fun DataBehindScore(db: PulseLoopDatabase, result: Readiness.Result?) { Column( Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card) .clickable { open = !open }.padding(16.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Row(verticalAlignment = Alignment.CenterVertically) { Text(tr("Data behind this score"), fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, modifier = Modifier.weight(1f)) - Text(if (open) tr("Hide") else tr("Show"), fontSize = 13.sp, color = PulseColors.accent) + Text(if (open) tr("Hide") else tr("Show"), fontSize = 14.sp, color = PulseColors.accent) } if (open) { val night = inputs?.lastNight @@ -474,8 +478,8 @@ private fun DataBehindScore(db: PulseLoopDatabase, result: Readiness.Result?) { } rows.forEach { (k, v) -> Row(Modifier.fillMaxWidth()) { - Text(k, fontSize = 13.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f)) - Text(v, fontSize = 13.sp, color = PulseColors.textPrimary) + Text(k, fontSize = 14.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f)) + Text(v, fontSize = 14.sp, color = PulseColors.textPrimary) } } night?.withheld?.values?.forEach { Text(trf("Withheld: {0}.", it), fontSize = 12.sp, color = PulseColors.warning) } diff --git a/app/src/main/java/com/pulseloop/ui/screens/Screens.kt b/app/src/main/java/com/pulseloop/ui/screens/Screens.kt index be92506c..f770e185 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/Screens.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/Screens.kt @@ -292,7 +292,7 @@ fun VitalsScreen( item { Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Column(Modifier.weight(1f)) { - Text(tr("Vitals"), style = MaterialTheme.typography.headlineLarge, fontWeight = FontWeight.Bold) + // No title: the tab bar names the screen, as on the other tabs. // The answer first: is anything outside this person's usual range? The // cards below are the detail. VitalsStatusLine() @@ -622,10 +622,9 @@ private fun BpGaugeColumn( ) Text( title.uppercase(), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 0.8.sp, - color = PulseColors.textMuted, + color = PulseColors.textSecondary, ) } } @@ -682,7 +681,7 @@ fun VitalDetailScreen( LazyColumn( modifier = Modifier.fillMaxSize(), contentPadding = PaddingValues(start = 16.dp, end = 16.dp, top = 4.dp, bottom = 40.dp), - verticalArrangement = Arrangement.spacedBy(18.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), ) { // 1. Period selector — Today · Week · Month (iOS segmented picker) item { @@ -699,7 +698,7 @@ fun VitalDetailScreen( .clip(cardShape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, cardShape) - .padding(horizontal = 14.dp, vertical = 10.dp), + .padding(horizontal = 16.dp, vertical = 12.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { // Date navigator row: unit label leading (iOS), pager trailing @@ -743,7 +742,7 @@ fun VitalDetailScreen( ) { Text( tr("Not enough data for this period."), - fontSize = 13.sp, + fontSize = 14.sp, color = PulseColors.textMuted, ) } @@ -771,9 +770,9 @@ fun VitalDetailScreen( if (state.usualRange != null) { Text( tr("Shaded: your usual range over the last 30 days"), - fontSize = 11.sp, + fontSize = 12.sp, color = PulseColors.textMuted, - modifier = Modifier.padding(top = 6.dp), + modifier = Modifier.padding(top = 8.dp), ) } } @@ -789,7 +788,7 @@ fun VitalDetailScreen( .clip(cardShape) .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, cardShape) - .padding(horizontal = 10.dp, vertical = 14.dp), + .padding(horizontal = 12.dp, vertical = 16.dp), // Bottom, so the values stay on one line when a translated title // ("MAIS RECENTE") wraps to two; the dividers stay centred. verticalAlignment = Alignment.Bottom, @@ -836,15 +835,14 @@ fun VitalDetailScreen( ) { Text( tr("REFERENCE ZONES"), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 1.sp, - color = PulseColors.textMuted, + color = PulseColors.textSecondary, ) state.engineZones.forEach { zone -> Row( verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), ) { Box( Modifier @@ -855,7 +853,7 @@ fun VitalDetailScreen( // translated zone label wraps beside its range. Text( tr(zone.label), - fontSize = 13.sp, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, modifier = Modifier.weight(1f), @@ -881,18 +879,17 @@ fun VitalDetailScreen( .background(PulseColors.card) .border(1.dp, PulseColors.borderSubtle, cardShape) .padding(16.dp), - verticalArrangement = Arrangement.spacedBy(6.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), ) { Text( tr("WHAT THIS MEANS"), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 1.sp, - color = PulseColors.textMuted, + color = PulseColors.textSecondary, ) Text( metricExplainer(metric), - fontSize = 13.sp, + fontSize = 14.sp, lineHeight = 18.sp, color = PulseColors.textSecondary, ) @@ -912,7 +909,7 @@ fun VitalDetailScreen( .dither(ZonePalette.ZoneAmber, 0.10f) .border(1.dp, ZonePalette.ZoneAmber.copy(alpha = 0.30f), cardShape) .padding(16.dp), - horizontalArrangement = Arrangement.spacedBy(10.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), ) { Icon( Icons.Filled.Warning, null, @@ -984,17 +981,16 @@ private fun ReadingsCard( ) { Text( tr("READINGS"), - fontSize = 11.sp, + style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, - letterSpacing = 1.sp, - color = PulseColors.textMuted, + color = PulseColors.textSecondary, ) Spacer(Modifier.weight(1f)) Text( readings.size.toString(), fontSize = 12.sp, color = PulseColors.textMuted, - modifier = Modifier.padding(end = 6.dp), + modifier = Modifier.padding(end = 8.dp), ) Icon( if (expanded) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore, @@ -1009,25 +1005,25 @@ private fun ReadingsCard( // scrollers in the same axis crashes Compose. Bounded by [visibleCount] instead. readings.take(visibleCount).forEach { reading -> Row( - Modifier.fillMaxWidth().padding(start = 16.dp, end = 6.dp, bottom = 4.dp), + Modifier.fillMaxWidth().padding(start = 16.dp, end = 8.dp, bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, ) { Text( tooltipTime(reading.timestamp, period), - fontSize = 13.sp, + fontSize = 14.sp, color = PulseColors.textSecondary, modifier = Modifier.weight(1f), ) Text( readingText(reading), - fontSize = 13.sp, + fontSize = 14.sp, fontWeight = FontWeight.Medium, color = PulseColors.textPrimary, ) if (unitLabel.isNotEmpty()) { Text( " $unitLabel", - fontSize = 11.sp, + fontSize = 12.sp, color = PulseColors.textMuted, ) } @@ -1046,7 +1042,7 @@ private fun ReadingsCard( onClick = { visibleCount += READINGS_PAGE_SIZE }, modifier = Modifier.padding(start = 8.dp), ) { - Text(trf("Show {0} more", minOf(READINGS_PAGE_SIZE, readings.size - visibleCount)), fontSize = 13.sp) + Text(trf("Show {0} more", minOf(READINGS_PAGE_SIZE, readings.size - visibleCount)), fontSize = 14.sp) } } Spacer(Modifier.height(8.dp)) @@ -1092,38 +1088,7 @@ private const val READINGS_PAGE_SIZE = 50 /** iOS-style segmented control for Today/Week/Month. */ @Composable private fun PeriodSegmentedControl(selected: Period, onSelect: (Period) -> Unit) { - Row( - Modifier - .fillMaxWidth() - .clip(RoundedCornerShape(4.dp)) - .background(PulseColors.cardSoft) - .padding(2.dp) - .selectableGroup(), - ) { - Period.entries.forEach { p -> - val isSelected = selected == p - Box( - Modifier - .weight(1f) - .heightIn(min = 48.dp) - .clip(RoundedCornerShape(4.dp)) - .then(if (isSelected) Modifier.dither(PulseColors.textPrimary, 0.16f) else Modifier) - .selectable(selected = isSelected, role = Role.Tab) { onSelect(p) } - .padding(vertical = 7.dp), - contentAlignment = Alignment.Center, - ) { - Text( - p.label, - fontSize = 13.sp, - fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium, - color = if (isSelected) PulseColors.textPrimary else PulseColors.textSecondary, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.padding(horizontal = 4.dp), - ) - } - } - } + com.pulseloop.ui.components.PulseSegmented(Period.entries.map { it to it.label }, selected, onSelect) } /** One column of the LATEST/AVERAGE/MIN/MAX strip. */ @@ -1136,10 +1101,8 @@ private fun DetailStat(title: String, value: String, modifier: Modifier = Modifi ) { Text( title.uppercase(), - fontSize = 11.sp, - fontWeight = FontWeight.Medium, - letterSpacing = 0.6.sp, - color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = PulseColors.textSecondary, // A quarter of the card: "MAIS RECENTE" doesn't fit one line, so it wraps centred. maxLines = 2, overflow = TextOverflow.Ellipsis, @@ -1312,8 +1275,8 @@ private fun MeasurePickerSheet(titles: List, onDismiss: () -> Unit, onPi Modifier.fillMaxWidth().padding(horizontal = 16.dp).padding(bottom = 32.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { - Text(tr("Measure"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) - Text(tr("Keep the ring snug and your hand still until it finishes."), fontSize = 13.sp, color = PulseColors.textSecondary) + Text(tr("Measure"), fontSize = 20.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Keep the ring snug and your hand still until it finishes."), fontSize = 14.sp, color = PulseColors.textSecondary) titles.forEachIndexed { i, t -> SheetOption(t, tr("Tap to start"), Icons.Filled.MonitorHeart) { onPick(i) } } diff --git a/app/src/main/java/com/pulseloop/ui/screens/SleepScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/SleepScreen.kt index dc05f741..5ec8cee7 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/SleepScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/SleepScreen.kt @@ -222,7 +222,7 @@ private fun SessionHero(session: SleepSessionEntity, blocks: List Unit) { val options = listOf( - SleepRangeKey.DAY to "Day", SleepRangeKey.WEEK to "Week", - SleepRangeKey.MONTH to "Month", SleepRangeKey.YEAR to "Year", + SleepRangeKey.DAY to tr("Day"), SleepRangeKey.WEEK to tr("Week"), + SleepRangeKey.MONTH to tr("Month"), SleepRangeKey.YEAR to tr("Year"), ) - Row( - Modifier - .fillMaxWidth() - .clip(CircleShape) - .background(PulseColors.card) - .border(1.dp, PulseColors.borderSubtle, CircleShape) - .padding(4.dp) - .selectableGroup(), - horizontalArrangement = Arrangement.spacedBy(4.dp), - ) { - options.forEach { (key, label) -> - val active = selection == key - Text( - label, - fontSize = 12.sp, - fontWeight = FontWeight.SemiBold, - color = if (active) PulseColors.textPrimary else PulseColors.textMuted, - textAlign = androidx.compose.ui.text.style.TextAlign.Center, - maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier - .weight(1f) - .heightIn(min = 48.dp) - .clip(CircleShape) - .then(if (active) Modifier.dither(PulseColors.accent, 0.15f) else Modifier) - .border(1.dp, if (active) PulseColors.accent.copy(alpha = 0.4f) else Color.Transparent, CircleShape) - .selectable(selected = active, role = Role.Tab) { onSelect(key) } - .padding(vertical = 6.dp) - .wrapContentHeight(), - ) - } - } + com.pulseloop.ui.components.PulseSegmented(options, selection, onSelect) } /** LAST SLEEP hero: duration left, big purple score + rating word right (SleepHeroCardView). */ @@ -419,8 +388,7 @@ private fun SleepHeroCard( Column(Modifier.weight(1f)) { Text( label.uppercase(), - fontSize = 11.sp, fontWeight = FontWeight.Medium, - letterSpacing = 1.8.sp, color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary, ) Text( value, @@ -475,8 +443,7 @@ private fun VisualizationCard( Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) { Text( eyebrow.uppercase(), - fontSize = 11.sp, fontWeight = FontWeight.Medium, - letterSpacing = 1.8.sp, color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary, ) Text(title, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary) } @@ -501,9 +468,9 @@ private fun VisualizationCard( @Composable private fun LegendItem(label: String, color: Color) { - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(5.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) { Box(Modifier.size(6.dp).clip(CircleShape).background(color)) - Text(label, fontSize = 11.sp, color = PulseColors.textSecondary) + Text(label, fontSize = 12.sp, color = PulseColors.textSecondary) } } @@ -597,7 +564,7 @@ private fun SleepHypnogram( return "$stage · $startTime – $endTime" } - Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { Box( Modifier .fillMaxWidth() @@ -718,7 +685,7 @@ private fun SleepHypnogram( val labelY = yFrac * plotHeightPx Text( stage, - fontSize = 10.sp, fontWeight = FontWeight.SemiBold, + fontSize = 12.sp, fontWeight = FontWeight.SemiBold, // Not the stage colour: DEEP's is 2.4:1 on the card. The bars and // legend swatches carry the colour. letterSpacing = 1.4.sp, color = PulseColors.textSecondary, @@ -755,11 +722,11 @@ private fun SleepHypnogram( androidx.compose.foundation.layout.Box( Modifier .background(Color.Black.copy(alpha = 0.85f), RoundedCornerShape(4.dp)) - .padding(horizontal = 10.dp, vertical = 6.dp), + .padding(horizontal = 12.dp, vertical = 8.dp), ) { Text( readoutText(block), - fontSize = 11.sp, + fontSize = 12.sp, fontWeight = FontWeight.Medium, color = Color.White, ) @@ -773,7 +740,7 @@ private fun SleepHypnogram( Modifier.fillMaxWidth().padding(start = plotInsets.x, end = plotTrailing), horizontalArrangement = Arrangement.SpaceBetween, ) { - ticks.forEach { Text(it, fontSize = 11.sp, color = PulseColors.textMuted) } + ticks.forEach { Text(it, fontSize = 12.sp, color = PulseColors.textMuted) } } } } @@ -802,14 +769,13 @@ private fun StageStat(label: String, value: String, color: Color, modifier: Modi Box(Modifier.size(8.dp).clip(CircleShape).background(color)) Text( label.uppercase(), - fontSize = 11.sp, fontWeight = FontWeight.Medium, - letterSpacing = 0.6.sp, color = PulseColors.textMuted, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary, maxLines = 1, overflow = TextOverflow.Ellipsis, ) } Text( value, - fontSize = 22.sp, fontWeight = FontWeight.SemiBold, + fontSize = 24.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, modifier = Modifier.padding(top = 12.dp), ) @@ -843,7 +809,7 @@ private fun SleepDurationHistogram( (goalMin?.takeIf { it > 0 }?.let { trf(", goal {0}", SleepFormat.duration(it)) } ?: "") } - Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { Canvas(Modifier.fillMaxWidth().height(height - 24.dp).semantics { contentDescription = summary }) { val slotW = size.width / bars.size val barW = if (slim) 7.dp.toPx() else (slotW * 0.7f).coerceAtMost(30.dp.toPx()) @@ -883,7 +849,7 @@ private fun SleepDurationHistogram( bars.forEachIndexed { i, bar -> Box(Modifier.weight(1f), contentAlignment = Alignment.Center) { if (i % labelInterval == 0) { - Text(bar.label, fontSize = 11.sp, color = PulseColors.textMuted, maxLines = 1) + Text(bar.label, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 1) } } } @@ -911,8 +877,8 @@ private fun SleepDayNavHeader(state: SleepViewModel.SleepState, viewModel: Sleep Modifier .weight(1f) .clip(RoundedCornerShape(4.dp)) - .clickable { showPicker = true } - .padding(vertical = 6.dp), + .clickable(role = Role.Button) { showPicker = true } + .padding(vertical = 8.dp), horizontalAlignment = Alignment.CenterHorizontally, ) { Text( @@ -922,8 +888,7 @@ private fun SleepDayNavHeader(state: SleepViewModel.SleepState, viewModel: Sleep val sub = daySubLabel(state.shownDayMillis) Text( sub.ifEmpty { " " }, - fontSize = 11.sp, fontWeight = FontWeight.Medium, - letterSpacing = 0.5.sp, color = PulseColors.textSecondary, + style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary, ) } NavChevron(Icons.Filled.ChevronRight, tr("Next day"), canNewer) { viewModel?.stepDay(older = false) } @@ -1087,12 +1052,12 @@ private fun SleepRecordsCard( else trf("The ring recorded this night in {0} parts", runs.size), legend = false, ) { - Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(12.dp)) { runs.forEachIndexed { index, run -> Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { Text( "${index + 1}", - fontSize = 11.sp, + fontSize = 12.sp, color = PulseColors.textMuted, modifier = Modifier.width(18.dp), ) @@ -1139,7 +1104,7 @@ private fun SleepRecordsCard( trf("Awake {0} between", SleepFormat.duration(gapMinutes)), fontSize = 12.sp, color = PulseColors.textMuted, - modifier = Modifier.padding(start = 18.dp), + modifier = Modifier.padding(start = 16.dp), ) } } 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 957f280b..4c82af72 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/TodayScreen.kt @@ -15,6 +15,8 @@ import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.semantics.Role @@ -338,7 +340,7 @@ fun TodayScreen( ) { Text( tr("See what affects you"), - fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.readiness, + fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.readiness, modifier = Modifier .heightIn(min = 48.dp) .clickable(role = Role.Button) { navController?.navigate("journal") } @@ -442,9 +444,9 @@ private fun ActivityTileFor( ActivityRing(state.calories, state.caloriesGoal.toDouble(), PulseColors.calories), ), values = buildList { - steps?.let { add(ActivityTileValue(if (stepFactor != null) "≈ STEPS" else "STEPS", Formats.count(it), PulseColors.steps)) } + steps?.let { add(ActivityTileValue(if (stepFactor != null) "≈ " + tr("Steps") else tr("Steps"), Formats.count(it), PulseColors.steps)) } distText?.let { add(ActivityTileValue(UnitConverter.distanceUnit(units), it, PulseColors.distance)) } - state.calories?.let { add(ActivityTileValue("CAL", Formats.count(it.toInt()), PulseColors.calories)) } + state.calories?.let { add(ActivityTileValue(tr("kcal"), Formats.count(it.toInt()), PulseColors.calories)) } }, modifier = modifier, onTap = onTap, @@ -471,14 +473,14 @@ private fun ChartTile(card: VitalCardState, values: List, modifier: Modi Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(4.dp)) { Text( card.valueText, - fontSize = 22.sp, + fontSize = 24.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1, ) card.unitText?.let { Text( - it, fontSize = 11.sp, fontWeight = FontWeight.Medium, + it, fontSize = 12.sp, fontWeight = FontWeight.Medium, color = PulseColors.textMuted, maxLines = 1, modifier = Modifier.padding(bottom = 4.dp), ) @@ -520,16 +522,27 @@ private fun GaugeTile(card: VitalCardState, modifier: Modifier, onTap: () -> Uni // inside a Box pinned to it — a fixed ring with growing text overflows its own // ring. The tile is no longer fixed-height, so a taller ring just makes it taller. val gaugeScale = TodayTileMetrics.fontScale - VitalRingGauge( - value = card.latestValue, - domain = card.yDomain, - zones = card.zones, - valueColor = card.statusToken.toColor(), - centerValue = card.valueText, - centerStatus = card.statusText, - size = 88.dp * gaugeScale, - lineWidth = 9.dp * gaugeScale, - ) + // The zone verdict sits under the ring at the label size: inside an 88dp ring it + // came out at 7sp, the most meaningful word on the tile and the least readable. + Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(4.dp)) { + VitalRingGauge( + value = card.latestValue, + domain = card.yDomain, + zones = card.zones, + valueColor = card.statusToken.toColor(), + centerValue = card.valueText, + centerStatus = null, + size = 88.dp * gaugeScale, + lineWidth = 9.dp * gaugeScale, + ) + Text( + card.statusText.uppercase(), + style = com.pulseloop.ui.theme.PulseType.eyebrow, + color = card.statusToken.toColor(), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } } } } @@ -552,9 +565,9 @@ private fun BloodPressureTile( } else { val sysZones = VitalsThresholdEngine.zones(MetricKind.BLOOD_PRESSURE, vitals.profile) val diaZones = VitalsThresholdEngine.diastolicReferenceZones() - Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) { - BpRingColumn("SYS", sys, 80.0..190.0, sysZones, PulseColors.bloodPressure, Modifier.weight(1f)) - BpRingColumn("DIA", dia, 50.0..130.0, diaZones, PulseColors.bloodPressure.copy(alpha = 0.7f), Modifier.weight(1f)) + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + BpRingColumn(tr("SYS"), sys, 80.0..190.0, sysZones, PulseColors.bloodPressure, Modifier.weight(1f)) + BpRingColumn(tr("DIA"), dia, 50.0..130.0, diaZones, PulseColors.bloodPressure.copy(alpha = 0.7f), Modifier.weight(1f)) } } } @@ -573,7 +586,7 @@ private fun BpRingColumn( val valueColor = zones.firstOrNull { (it.lower ?: Double.NEGATIVE_INFINITY) <= value && value < (it.upper ?: Double.POSITIVE_INFINITY) }?.colorToken?.toColor() ?: fallback - Column(modifier, horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(5.dp)) { + Column(modifier, horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(4.dp)) { VitalRingGauge( value = value, domain = domain, @@ -585,8 +598,8 @@ private fun BpRingColumn( lineWidth = 6.dp * TodayTileMetrics.fontScale, ) Text( - title, fontSize = 10.sp, fontWeight = FontWeight.SemiBold, - letterSpacing = 0.8.sp, color = PulseColors.textMuted, + title, style = com.pulseloop.ui.theme.PulseType.eyebrow, fontWeight = FontWeight.SemiBold, + color = PulseColors.textSecondary, ) } } @@ -686,8 +699,8 @@ private fun NutritionTile(food: FoodTotals?, loaded: Boolean, modifier: Modifier private fun ColumnScope.NutritionTileBody(food: FoodTotals?, onLog: () -> Unit) { val kcal = food?.kcal ?: 0.0 Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(4.dp)) { - Text(Formats.count(kcal.toInt()), fontSize = 22.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1) - Text("kcal", fontSize = 11.sp, color = PulseColors.textMuted, modifier = Modifier.padding(bottom = 4.dp)) + Text(Formats.count(kcal.toInt()), fontSize = 24.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.textPrimary, maxLines = 1) + Text("kcal", fontSize = 12.sp, color = PulseColors.textMuted, modifier = Modifier.padding(bottom = 4.dp)) } val goal = food?.goalKcal?.takeIf { it > 0 } if (goal != null) { @@ -695,22 +708,24 @@ private fun ColumnScope.NutritionTileBody(food: FoodTotals?, onLog: () -> Unit) Box(Modifier.fillMaxWidth().height(6.dp).clip(shape).dither(PulseColors.calories, 0.25f)) { Box(Modifier.fillMaxWidth((kcal / goal).toFloat().coerceIn(0f, 1f)).fillMaxHeight().background(PulseColors.calories)) } - Text(trf("of {0}", Formats.count(goal.toInt())), fontSize = 11.sp, color = PulseColors.textMuted) + Text(trf("of {0}", Formats.count(goal.toInt())), fontSize = 12.sp, color = PulseColors.textMuted) } Spacer(Modifier.weight(1f)) if (food != null && food.meals > 0) { Text( "P ${food.proteinG.toInt()} · C ${food.carbsG.toInt()} · F ${food.fatG.toInt()} g", - fontSize = 11.sp, color = PulseColors.textSecondary, maxLines = 1, + fontSize = 12.sp, color = PulseColors.textSecondary, maxLines = 1, ) } else { - Text(tr("Nothing logged yet"), fontSize = 11.sp, color = PulseColors.textMuted, maxLines = 1) + Text(tr("Nothing logged yet"), fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 1) + } + // A real button, so it gets the 48dp target Material gives its components (a bare + // clickable does not). It makes the tile a little taller; the row grows to match. + TextButton( + onClick = onLog, + contentPadding = PaddingValues(horizontal = 0.dp), + modifier = Modifier.heightIn(min = 48.dp), + ) { + Text(tr("+ Log meal"), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent) } - Text( - tr("+ Log meal"), - fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent, - // No min height here: it would stretch the tile and its row. Compose already widens a - // small clickable's hit area towards 48dp. - modifier = Modifier.clickable(role = Role.Button, onClick = onLog).padding(vertical = 2.dp), - ) } diff --git a/app/src/main/java/com/pulseloop/ui/theme/PulseColors.kt b/app/src/main/java/com/pulseloop/ui/theme/PulseColors.kt index ae7a17f9..4aabdd89 100644 --- a/app/src/main/java/com/pulseloop/ui/theme/PulseColors.kt +++ b/app/src/main/java/com/pulseloop/ui/theme/PulseColors.kt @@ -27,7 +27,11 @@ object PulseColors { val accentSoft: Color get() = if (FairyMode.on) FairyMode.Palette.accentSoft else Color(0x2E43F3B7) // accent @ 18% /** Text and icons on a mint fill (GMind ON_MINT, 9:1 on mint). Never white on mint. */ val onAccent: Color get() = if (FairyMode.on) FairyMode.Palette.onAccent else Color(0xFF033423) - val success: Color get() = accent + /** + * "Good / in range / done". Its own green, not the mint: mint is the brand and the thing + * to tap, and when it also meant success, connected and REM it stopped saying "act here". + */ + val success = Color(0xFF4CC97A) val warning = Color(0xFFFFC46B) val danger = Color(0xFFFF7A70) // GMind coral (dark) val info = Color(0xFF5AD8F0) @@ -52,7 +56,8 @@ object PulseColors { // Vitals reference-zone colors (AppTheme.swift zone*) — aliased by // ZonePalette (fine iOS-parity palette) and [MetricColors] (coarse semantic palette) val zoneBlue = Color(0xFF5BA8FF) - val zoneMint = Color(0xFF43F3B7) + /** The in-range zone. Named for its old mint; it is the [success] green now. */ + val zoneMint = Color(0xFF4CC97A) val zoneCyan = Color(0xFF5AD8F0) val zoneAmber = Color(0xFFFFC46B) val zoneSoftAmber = Color(0xFFFFDDA6) @@ -61,9 +66,11 @@ object PulseColors { val zoneCritical = Color(0xFFFF4B3E) // Sleep stage colors (DesignSystem/Charts.swift SleepStageColors) - val stageDeep = Color(0xFF4B3BD6) + /** 3.3:1 on [card]: deep is the stage people look for, and #4B3BD6 was 2.4:1. */ + val stageDeep = Color(0xFF6352F0) val stageLight = Color(0xFF9A8CFF) - val stageRem: Color get() = if (FairyMode.on) FairyMode.Palette.rem else MINT + /** Cyan rather than the brand mint, so REM doesn't read as "tap here" (see [success]). */ + val stageRem: Color get() = if (FairyMode.on) FairyMode.Palette.rem else Color(0xFF5AD8F0) val stageAwake = Color(0xFFFFC46B) val borderSubtle = Color(0xFF2C2B30) // GMind hairline (LINE, dark) diff --git a/app/src/main/java/com/pulseloop/ui/theme/PulseType.kt b/app/src/main/java/com/pulseloop/ui/theme/PulseType.kt new file mode 100644 index 00000000..8b40673b --- /dev/null +++ b/app/src/main/java/com/pulseloop/ui/theme/PulseType.kt @@ -0,0 +1,39 @@ +package com.pulseloop.ui.theme + +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.em +import androidx.compose.ui.unit.sp + +/** + * The app's type scale: one size per role, so a screen can't drift to its own 13sp or 15sp. + * Inline `fontSize` values snap to [SCALE]; `PulseTypeScaleTest` fails on any other size in the + * main screens. 12sp is the floor for anything that carries meaning. + * + * Each style carries Ubuntu Mono itself: `Text(style = …)` replaces the theme's text style + * rather than merging into it, so a style without a family would fall back to the system font. + */ +object PulseType { + /** Every size the main screens may use, smallest to largest. */ + val SCALE = listOf(12, 14, 16, 20, 24, 28, 32, 40) + + /** The tracked ALL-CAPS label over a card or a section: one size, one tracking, everywhere. */ + val eyebrow = TextStyle( + fontFamily = UbuntuMono, + fontSize = 12.sp, + fontWeight = FontWeight.Medium, + letterSpacing = 1.sp, + lineHeight = 1.3.em, + ) + + /** Captions, units, axis ticks: the smallest text that says something. */ + val label = TextStyle(fontFamily = UbuntuMono, fontSize = 12.sp, lineHeight = 1.3.em) + + val body = TextStyle(fontFamily = UbuntuMono, fontSize = 14.sp, lineHeight = 1.4.em) + + /** A row's or card's title. */ + val title = TextStyle(fontFamily = UbuntuMono, fontSize = 16.sp, fontWeight = FontWeight.Bold, lineHeight = 1.3.em) + + /** A screen's own title, when it has one. */ + val headline = TextStyle(fontFamily = UbuntuMono, fontSize = 28.sp, fontWeight = FontWeight.Bold, lineHeight = 1.2.em) +} diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..c2a3809e --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,12 @@ + + + + #121214 + + diff --git a/app/src/test/java/com/pulseloop/ui/theme/PulseTypeScaleTest.kt b/app/src/test/java/com/pulseloop/ui/theme/PulseTypeScaleTest.kt new file mode 100644 index 00000000..8d9a4fbd --- /dev/null +++ b/app/src/test/java/com/pulseloop/ui/theme/PulseTypeScaleTest.kt @@ -0,0 +1,48 @@ +package com.pulseloop.ui.theme + +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +/** + * The main screens set type on [PulseType.SCALE] only. Sixteen sizes in 1sp steps had crept in + * (10, 11, 12, 13, 14, 15…), which no one can tell apart in a monospace face; this keeps a new + * 13sp from slipping back in unnoticed. + */ +class PulseTypeScaleTest { + private val mainScreens = listOf( + "ui/PulseLoopApp.kt", + "ui/components/AppChrome.kt", + "ui/components/TodayTiles.kt", + "ui/components/VitalCard.kt", + "ui/components/Charts.kt", + "ui/components/ZoneLineChart.kt", + "ui/screens/TodayScreen.kt", + "ui/screens/Screens.kt", + "ui/screens/ActivityScreen.kt", + "ui/screens/SleepScreen.kt", + "ui/screens/NutritionScreen.kt", + "ui/screens/MyHealthUi.kt", + "ui/screens/LogSheet.kt", + "ui/screens/ReadinessUi.kt", + ) + + private fun source(path: String): File { + val rel = "src/main/java/com/pulseloop/$path" + return listOf(File(rel), File("app/$rel")).first { it.exists() } + } + + @Test + fun mainScreensUseOnlySizesOnTheScale() { + val literal = Regex("""fontSize = (\d+)\.sp""") + val off = mainScreens.flatMap { path -> + source(path).readLines().mapIndexedNotNull { i, line -> + literal.findAll(line).map { it.groupValues[1].toInt() } + .filter { it !in PulseType.SCALE } + .map { "$path:${i + 1} uses ${it}sp" } + .toList().takeIf { it.isNotEmpty() } + }.flatten() + } + assertTrue("Sizes off the type scale ${PulseType.SCALE}:\n" + off.joinToString("\n"), off.isEmpty()) + } +} From 18a2b058af4f877bb7010a2d0a855b6b0a2132c1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 31 Oct 2026 14:16:28 +0000 Subject: [PATCH 2/2] Test: the in-range zone hex is the success green now Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w --- app/src/test/java/com/pulseloop/widgets/WidgetSnapshotTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/com/pulseloop/widgets/WidgetSnapshotTest.kt b/app/src/test/java/com/pulseloop/widgets/WidgetSnapshotTest.kt index 69b8da06..34e0dad7 100644 --- a/app/src/test/java/com/pulseloop/widgets/WidgetSnapshotTest.kt +++ b/app/src/test/java/com/pulseloop/widgets/WidgetSnapshotTest.kt @@ -129,7 +129,8 @@ class WidgetSnapshotTest { fun colorHexBridgeRoundTrips() { val original = ZonePalette.ZoneMint assertEquals(original, colorFromHex(colorToHex(original))) - assertEquals("#43F3B7", colorToHex(ZonePalette.ZoneMint)) + // The in-range zone is the success green now, not the brand mint (PulseColors.zoneMint). + assertEquals("#4CC97A", colorToHex(ZonePalette.ZoneMint)) } // ── 3. Zone payload reconstruction ──