Skip to content

Refactor/glucose range thresholds - #791

Merged
marionbarker merged 3 commits into
devfrom
refactor/glucose-range-thresholds
Oct 27, 2026
Merged

marionbarker merged 3 commits into
devfrom
refactor/glucose-range-thresholds

Conversation

@codebymini

Copy link
Copy Markdown
Collaborator

Summary

Time in range cut-offs are now defined in one place, the range mode is picked from a clearer full-width list, and a new mode is added: Extended Tight Range (TING, 63–140 mg/dL).

Why

  • The cut-offs were repeated. 54, 70, 140, 180 and 250 mg/dL were written out separately in the stats, GRI, the settings footer and the Live Activity, so a change in one place could miss the others.
  • Adding a mode meant touching many files. Each one needed edits to several switch statements, the segmented picker, the settings footer and the stats card toggle.
  • The segmented picker didn't scale. A fourth option made each segment cramped, and the full names and ranges had to go in a separate footer.

What changed

Cut-offs in one place

  • New GlucoseThresholds in Shared/, so the app, Live Activity and watch targets all use the same values. It holds the very low/very high cut-offs and each mode's low/high.
  • TIRCalculator, TIRView, GRICalculator and the Live Activity background tint now read from it. GRI keeps the standard 70–180 range whichever mode is selected, as its definition requires.

Range modes describe themselves

  • Each TimeInRangeDisplayMode now has a title, fixedThresholds and next.
  • effectiveThresholds(), the stats title and the stats card toggle use these instead of their own switch statements.
  • Adding a mode is now: its cut-offs in GlucoseThresholds, plus one case with a title and thresholds. The settings, stats, chart lines, header, watch and Live Activity pick it up from there.

Range settings

Screenshot 2026-10-26 at 22 31 06
  • The segmented TIR/TITR/Custom picker and its footer are replaced by a single row. It shows the selected mode's full name with its cut-offs, e.g. Time in Tight Range 3,9–7,8.
Screenshot 2026-10-26 at 22 30 59
  • Tapping the row opens a Range list with one line per mode (name, cut-offs, checkmark). Picking a fixed mode goes back.
  • Picking Custom Range stays on the list and shows the Low and High pickers there, so the settings page no longer changes height when you switch modes.
  • The onboarding Statistics page now has a navigation stack, with its bar hidden, so the list can open from there too.

Extended Tight Range (TING)

  • A new mode for 63–140 mg/dL (3,5–7,8 mmol/L): the tight range with its lower cut-off moved down from 70, also known as Time in Normoglycemia.
  • It's shown as Extended Tight Range and sits between Time in Tight Range and Custom Range.
  • Settings search finds Range Mode for "ting" and "extended".

…om a full-width list

The 54/70/140/180/250 mg/dL cut-offs were repeated across the stats, GRI, the settings footer and the Live Activity. They now live in GlucoseThresholds in Shared, so the app, Live Activity and watch targets all see the same values. Each TimeInRangeDisplayMode carries its title and fixed thresholds, and the range settings, stats title and stats card toggle are built from allCases, so a new mode is its cut-offs plus one case.

The segmented TIR/TITR/Custom picker and its footer are replaced by a row showing the selected mode's full name and cut-offs, which opens a list with one line per mode. Choosing Custom Range stays on the list and shows the Low and High pickers there. The onboarding statistics page gets a navigation stack so the list can open from it.
TING is the tight range with its lower cut-off moved down from 70 to 63 mg/dL, also known as Time in Normoglycemia. It is shown as Extended Tight Range, sits between Time in Tight Range and Custom Range in the range list and the stats card toggle, and its cut-offs live in GlucoseThresholds next to TIR and TITR. The settings search finds Range Mode for "ting" and "extended".

@marionbarker marionbarker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by test.

@marionbarker
marionbarker merged commit c3345e0 into dev Oct 27, 2026
1 check passed
@marionbarker
marionbarker deleted the refactor/glucose-range-thresholds branch October 27, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants