Skip to content

Format battery voltage with NumberFormatter + " V"#2

Open
loopkitdev wants to merge 1 commit into
loopandlearn:loop-next-devfrom
loopkitdev:loop-next-dev
Open

Format battery voltage with NumberFormatter + " V"#2
loopkitdev wants to merge 1 commit into
loopandlearn:loop-next-devfrom
loopkitdev:loop-next-dev

Conversation

@loopkitdev

Copy link
Copy Markdown

Summary

Replace the temporary String(format: "%0.2f", voltage) placeholder for battery voltage display with a NumberFormatter + V suffix.

LoopUnit currently has no .volt case, so QuantityFormatter can't render volts. A locale-aware NumberFormatter restores the previous UX (2 fraction digits, decimal style with locale-correct separators) without depending on a unit type we don't have.

Applies to both PatchDetailsViewModel and PreviousPatchDetailsViewModel, and switches PreviousPatchDetailsView back to calling the view model's batteryText(for:) helper.

Test plan

  • Active patch settings: Battery voltage row shows 4.10 V (or similar) with locale-correct decimal separator
  • Previous patch detail: same formatting
  • No String(format:) printf for displayed values

Replaces the temporary placeholder (commented-out QuantityFormatter,
raw `String(format: "%0.2f", voltage)`) with a `NumberFormatter`
restoring 2 fraction digits and a `" V"` suffix.

LoopUnit has no `.volt` case, so a `QuantityFormatter` (which now
takes a `LoopUnit`) can't render the value. `NumberFormatter` matches
the original UX (decimal style, 2 fraction digits) and goes through
the locale's grouping/decimal separators -- no more raw printf.

Applies to both the current-patch and previous-patch detail views;
the previous-patch view goes back to calling `viewModel.batteryText`
instead of formatting inline.
loopkitdev pushed a commit to loopkitdev/LoopWorkspace that referenced this pull request Jun 7, 2026
- MedtrumKit: pin onto loopandlearn/MedtrumKit:loop-next-dev (their
  fork is the canonical place for the Loop-next-dev adaptation work)
  plus our voltage-formatter improvement on top, pushed as a PR
  against loopandlearn (loopandlearn/MedtrumKit#2).
- EversenseKit: replace ResizeablePicker (internal to LoopKitUI) with
  SwiftUI Picker(.wheel) at the 10 call sites across
  TransmitterSettingsView, DMSSettingsView, CalibrationView, matching
  the conversion loopandlearn just shipped on MedtrumKit.
- LoopKit: revert the ResizeablePicker public-access change -- no
  external driver needs it anymore now that both MedtrumKit and
  EversenseKit switched to SwiftUI Picker.
ps2 added a commit to LoopKit/LoopWorkspace that referenced this pull request Jun 9, 2026
- LoopKit: bump c5a5beb9 -> 4490dddb (latest loopkitdev/LoopKit next-dev).
- EversenseKit: add submodule (LoopKit/EversenseKit loop-next-dev @
  2aab7f9) -- adapted to current LoopKit CGMManager API + SwiftUI
  Picker. Forked to the LoopKit org since bastiaanv's repo is upstream
  we don't control.
- MedtrumKit: add submodule (loopkitdev/MedtrumKit loop-next-dev @
  3b3af0c) -- LoopKit API compat + decisionId threading + voltage
  formatter; mirrors loopandlearn/MedtrumKit#2.
- Workspace + scheme: add EversenseKit/MedtrumKit FileRefs and
  BuildActionEntries so both build as part of LoopWorkspace.

LoopWorkspace scheme builds clean on Xcode 26.5 / iOS 17 simulator.
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.

2 participants