sleep: responsive round-hour time axis for the stepped hypnogram - #1130
Merged
Conversation
The Filled/Ribbon chart's axis was fixed at three labels (onset · midpoint · wake). Replace it with the reference's richer axis: the EXACT onset/wake at the edges plus round-HOUR marks between (23:28 · 02:00 · 04:00 … · 10:25), and make the number of marks RESPONSIVE to screen width (~one label per 90dp, so a Fold/ tablet shows more, a phone fewer). hypnogramAxisTicks (pure, unit-tested) picks a nice hour step (1/2/3/4/6/8/12) so the interior count fits maxLabels, drops marks within ~8% of an edge so they can't collide with onset/wake, and anchors the exact edges. HypnogramTimeAxis places each label CENTRED on its true time fraction via a Layout (not a weighted row), clamped to stay on-screen, so labels line up with the axis hairlines drawn at the same fractions. Applies to both Filled and Ribbon (shared component); Classic's proportional strip is unchanged. Android only. compileFullDebugKotlin + HypnogramAxisTicksTest pass.
- Read LocalConfiguration.current UNCONDITIONALLY (was inside the showsAxis if; it's @ReadOnlyComposable so it compiled, but the unconditional read is the safe idiom). - Widen the interior edge-drop guard 0.08 -> 0.12: on a phone the onset/wake labels are ~a tenth of the width, so a round-hour mark landing at ~0.08-0.12 could overlap them. 0.12 gives clearance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the Filled/Ribbon sleep chart — the axis was fixed at three labels (onset · midpoint · wake). This makes it the reference's richer axis:
23:28 · 02:00 · 04:00 · 06:00 · 08:00 · 10:25).How
hypnogramAxisTicks(pure, unit-tested): picks a nice hour step (1/2/3/4/6/8/12) so the interior count fitsmaxLabels; drops marks within ~8 % of an edge so they can't collide with onset/wake; anchors the exact edges.HypnogramTimeAxis: aLayout(not a weighted row) that centres each label on its true time fraction, clamped to stay on-screen — so labels line up with the axis hairlines drawn at the same fractions above.Scope
Android only; display-only.
compileFullDebugKotlin+HypnogramAxisTicksTest(edges exact, interior strictly-between, wider→more marks, zero-span→single tick) pass.