From 478635538f2f3e1d772e53ccc5a969dbe8f261be Mon Sep 17 00:00:00 2001 From: Andre Emiliano Date: Mon, 21 Sep 2026 15:56:35 +0100 Subject: [PATCH] today: stop the Key Metrics header naming a window it is not drawing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #2376. The Key Metrics header carries a trailing "7-day trend" / "14-day trend" / "30-day trend" label naming the window the DETAILED tiles graph over. The detailed tiles are opt-in and default OFF, and the toggle behind them (`today.keyMetricsDetailed`) gated only the sparkline itself and the tile's minimum height. The header was outside that gate on both platforms, so on a default install nothing in the section drew a trend and the header announced one anyway. The tiles in that state render a value and a caption, so the label was the only thing on the screen framing the section as a trend, and there was no setting that removed it: the window picker's shortest choice is a week, and hiding the section takes the values with it. Both platforms gate the label on the same flag now. Android's SectionHeader already accepted `trailing: String? = null` and omits the row when both optional slots are null, so only the call site changed there. The Apple `sectionHead` helper took a required String and always rendered the Text, so it becomes `String? = nil` — the shape its Kotlin twin already had — and renders the caption only when one is passed. Its three other callers pass a non-nil string and are unaffected. Nothing about the window picker, the sparkline data, the tile layout or the label's wording changes; only whether the caption is rendered at all. VERIFICATION Built locally, since app-target Swift has no default CI: xcodebuild -scheme NOOPiOS -configuration Debug -destination 'generic/platform=iOS' build xcodebuild -scheme Strand -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO build cd android && ./gradlew compileFullDebugKotlin All three succeed; the Kotlin warnings in that run are pre-existing and none are on the changed line. What was observed on hardware is the BUG, not the fix: on an iPhone running 11.8.0 (400), turning the trend graphs off leaves "7-day trend" in the header. This build has not been run on a device, and no screenshot of the fixed header is offered. The change is a render gate on an existing flag, so the compile is the substantive check, but that distinction is worth stating rather than implying a device pass that did not happen. The single-day option the issue also raises is left alone: that is a design decision about the picker, not part of this fix. Co-Authored-By: Claude Opus 5 --- Strand/Liquid/LiquidTodayView.swift | 14 +++++++++++--- .../app/src/main/java/com/noop/ui/TodayScreen.kt | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Strand/Liquid/LiquidTodayView.swift b/Strand/Liquid/LiquidTodayView.swift index 3f4ae341ed..7a8d294f75 100644 --- a/Strand/Liquid/LiquidTodayView.swift +++ b/Strand/Liquid/LiquidTodayView.swift @@ -1308,7 +1308,10 @@ struct LiquidTodayView: View { let rhr = (displayDay?.restingHr ?? restingHrDay?.restingHr).map(Double.init) return VStack(spacing: 8) { HStack(alignment: .firstTextBaseline, spacing: 8) { - sectionHead("KEY METRICS", trailing: trendWindowLabel) + // The label names the window the DETAILED tiles graph, so it is only honest while they + // are drawn: with the trend graphs off (the default) nothing in this section renders a + // trend, and the header was still announcing one (#2376). + sectionHead("KEY METRICS", trailing: keyMetricsDetailed ? trendWindowLabel : nil) // #430 parity: the SAME editor the classic grid uses — selection + order + Detailed tiles. Button { customizationDestination = .keyMetrics } label: { Text(String(localized: "Edit").uppercased()) @@ -1562,11 +1565,16 @@ struct LiquidTodayView: View { // MARK: - Reusable chrome - private func sectionHead(_ title: String, trailing: String) -> some View { + /// `trailing` is optional so a section can omit it entirely rather than carry a caption for + /// something it is not drawing (the Key Metrics window label, when the trend graphs are off). + /// Matches the Android twin, whose `SectionHeader` already takes `trailing: String? = null`. + private func sectionHead(_ title: String, trailing: String? = nil) -> some View { HStack(alignment: .firstTextBaseline) { Text(LocalizedStringKey(title)).font(StrandFont.overline).tracking(1.6).foregroundStyle(StrandPalette.textTertiary) Spacer() - Text(LocalizedStringKey(trailing)).font(StrandFont.caption).foregroundStyle(StrandPalette.textTertiary) + if let trailing { + Text(LocalizedStringKey(trailing)).font(StrandFont.caption).foregroundStyle(StrandPalette.textTertiary) + } } .padding(.horizontal, 2) .padding(.top, 4) diff --git a/android/app/src/main/java/com/noop/ui/TodayScreen.kt b/android/app/src/main/java/com/noop/ui/TodayScreen.kt index aa37a65eaa..33572dfe86 100644 --- a/android/app/src/main/java/com/noop/ui/TodayScreen.kt +++ b/android/app/src/main/java/com/noop/ui/TodayScreen.kt @@ -1769,7 +1769,10 @@ fun TodayScreen( ) { Row(verticalAlignment = Alignment.Top) { Box(modifier = Modifier.weight(1f)) { - SectionHeader(uiString(R.string.today_section_key_metrics), overline = dayLabel, trailing = trendWindowLabel(keyMetricsWindowDays)) + // The label names the window the DETAILED tiles graph, so it is only honest while they are + // drawn: with the trend graphs off (the default) nothing in this section renders a + // trend, and the header was still announcing one (#2376). Twin of the Apple change. + SectionHeader(uiString(R.string.today_section_key_metrics), overline = dayLabel, trailing = if (keyMetricsDetailed) trendWindowLabel(keyMetricsWindowDays) else null) } TodayEditAction( onClick = { showMetricsEditor = true },