Skip to content

Commit 123113d

Browse files
committed
Tell insulin apart by shape instead of a darker bolus
All insulin marks now use Loop's insulin colour, so the darker bolus colour set is gone and this PR adds no colour sets. Bolus is solid, automatic bolus is hatched and basal is an outline with a faint wash. No tint of orange reaches 3:1 against it on a white card, and faded orange turns brown on a dark one, so opacity alone can't separate them in both modes. Over one day, basal is a plain 25% fill, because an outline breaks into pieces along a stepped area and looks like small boluses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QHnVP9CXfENBveKkXDDz3c
1 parent 6adb417 commit 123113d

4 files changed

Lines changed: 41 additions & 65 deletions

File tree

‎Loop/DerivedAssetsBase.xcassets/bolus.colorset/Contents.json‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎Loop/Redesign/DayCharts.swift‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct DayTimelineCard: View {
8888
static let legend: [LegendItem] = [
8989
LegendItem(swatch: .solid(P.bolus), label: NSLocalizedString("Bolus", comment: "Chart legend: solid bars are manual boluses")),
9090
LegendItem(swatch: .hatch(P.bolus), label: NSLocalizedString("Automatic", comment: "Chart legend: hatched bars are automatic boluses given by Loop")),
91-
LegendItem(swatch: .basal, label: NSLocalizedString("Basal given", comment: "Chart legend: filled area is basal insulin actually delivered")),
91+
LegendItem(swatch: .solid(P.basalArea), label: NSLocalizedString("Basal given", comment: "Chart legend: filled area is basal insulin actually delivered")),
9292
LegendItem(swatch: .dash(P.basalScheduled), label: NSLocalizedString("Scheduled", comment: "Chart legend: dashed line is the scheduled basal rate")),
9393
]
9494

@@ -229,15 +229,12 @@ struct InsulinTimelineView: View {
229229
}
230230
}
231231

232-
// Delivered basal, edged, then the schedule dashed over it
232+
// Delivered basal, then the schedule dashed over it
233233
// Draw each recorded segment independently; a gap must not become an interpolated delivery area.
234234
ForEach(Array(history.basal.enumerated()), id: \.offset) { _, segment in
235235
RectangleMark(xStart: .value("Start", segment.start), xEnd: .value("End", segment.end),
236236
yStart: .value("Base", 0), yEnd: .value("Basal", y(basal: segment.rate)))
237-
.foregroundStyle(P.basal)
238-
RuleMark(xStart: .value("Start", segment.start), xEnd: .value("End", segment.end), y: .value("Basal", y(basal: segment.rate)))
239-
.foregroundStyle(P.basalEdge)
240-
.lineStyle(StrokeStyle(lineWidth: 1.5))
237+
.foregroundStyle(P.basalArea)
241238
}
242239
ForEach(Array(history.scheduledBasal.enumerated()), id: \.offset) { _, value in
243240
RuleMark(xStart: .value("Start", value.start), xEnd: .value("End", value.end), y: .value("Scheduled", y(basal: value.rate)))

‎Loop/Redesign/LoopDesign.swift‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import UIKit
1010

1111
/// Colours, spacing and type for the Trends screen.
1212
///
13-
/// Every colour but one is one Loop already has: the `glucose`, `insulin`, `carbs`, `fresh` and `warning` assets, so a
13+
/// Every colour is one Loop already has: the `glucose`, `insulin`, `carbs`, `fresh` and `warning` assets, so a
1414
/// DerivedAssetsOverride still recolours them, and the iOS system colours for grounds and text. Bands and fills are
15-
/// those colours at reduced opacity. The one addition is `bolus`, a darker insulin for light mode. Text is `label` or `secondaryLabel`; colour is for marks, not for numbers.
15+
/// those colours at reduced opacity. Text is `label` or `secondaryLabel`; colour is for marks, not for numbers.
1616
/// Red is only for something that needs action now.
1717
enum LoopDesign {
1818

@@ -37,13 +37,14 @@ enum LoopDesign {
3737
static let agpOuter = glucose.opacity(0.16)
3838
static let agpInner = glucose.opacity(0.34)
3939
static let insulin = Color("insulin")
40-
/// Basal is insulin's colour faded, with a stronger edge along its top. Insulin's own orange is too light for
41-
/// a bolus on it in light mode, where it is under 2:1 against faded basal, so bolus has its own asset: a deep
42-
/// orange in light mode, insulin's light orange in dark. Charts also keep a gap of the card's colour wherever
43-
/// basal and bolus meet.
44-
static let bolus = Color("bolus")
45-
static let basal = insulin.opacity(0.25)
46-
static let basalEdge = insulin.opacity(0.6)
40+
/// Insulin is one colour, told apart by shape: bolus is solid, automatic bolus is hatched and basal is hollow.
41+
/// No tint of insulin's orange reaches 3:1 against it on a white card, and faded orange turns brown on a dark
42+
/// one. Charts also keep a gap of the card's colour wherever basal and bolus meet.
43+
static let bolus = insulin
44+
static let basal = insulin.opacity(0.1)
45+
static let basalOutline = insulin
46+
/// Basal over a day is a stepped area that an outline would break into pieces, so it's a plain fill.
47+
static let basalArea = insulin.opacity(0.25)
4748
static let basalScheduled = inkMuted
4849
static let carbs = Color("carbs")
4950

@@ -182,12 +183,9 @@ struct LegendSwatch: View {
182183
case .hatch(let color):
183184
RoundedRectangle(cornerRadius: 2).fill(Hatch.paint(color, scheme: scheme)).frame(width: 10, height: 10)
184185
case .basal:
185-
VStack(spacing: 0) {
186-
Rectangle().fill(LoopDesign.Palette.basalEdge).frame(height: 2)
187-
Rectangle().fill(LoopDesign.Palette.basal)
188-
}
189-
.frame(width: 10, height: 10)
190-
.clipShape(RoundedRectangle(cornerRadius: 2))
186+
RoundedRectangle(cornerRadius: 2).fill(LoopDesign.Palette.basal)
187+
.overlay(RoundedRectangle(cornerRadius: 2).strokeBorder(LoopDesign.Palette.basalOutline, lineWidth: 1.25))
188+
.frame(width: 10, height: 10)
191189
}
192190
}
193191
}

‎Loop/Redesign/TrendsComponents.swift‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,12 @@ struct InsulinSplitBar: View {
490490
private func segment(_ part: Part) -> some View {
491491
switch part {
492492
case .basal:
493-
Rectangle().fill(LoopDesign.Palette.basal)
494-
.overlay(alignment: .trailing) {
495-
if !hairline { Rectangle().fill(LoopDesign.Palette.basalEdge).frame(width: 2) }
496-
}
493+
// Rounded where the capsule is, so the capsule's clip doesn't cut the outline. Basal is always first.
494+
let radius: CGFloat = hairline ? 3 : 7
495+
let trailing = units(.manual) + units(.automatic) > 0 ? 0 : radius
496+
let shape = UnevenRoundedRectangle(topLeadingRadius: radius, bottomLeadingRadius: radius, bottomTrailingRadius: trailing, topTrailingRadius: trailing)
497+
shape.fill(LoopDesign.Palette.basal)
498+
.overlay(shape.strokeBorder(LoopDesign.Palette.basalOutline, lineWidth: hairline ? 1 : 1.25))
497499
case .manual:
498500
Rectangle().fill(LoopDesign.Palette.bolus)
499501
case .automatic:
@@ -709,13 +711,30 @@ struct InsulinDailyTotalsView: View {
709711

710712
private var unitWidth: Calendar.Component { weekly ? .weekOfYear : .day }
711713

714+
/// A bar mark can't have a border, so the outline is four rules along the 0.7-wide bar's edges.
715+
@ChartContentBuilder
716+
private func basalOutline(_ day: LoopHistoryMath.DayTotal) -> some ChartContent {
717+
if day.basal > 0, let unit = Calendar.current.dateInterval(of: unitWidth, for: day.day) {
718+
let left = unit.start.addingTimeInterval(unit.duration * 0.15)
719+
let right = unit.start.addingTimeInterval(unit.duration * 0.85)
720+
let line = StrokeStyle(lineWidth: 1.25)
721+
RuleMark(x: .value("Left", left), yStart: .value("Base", 0), yEnd: .value("Basal", day.basal))
722+
.foregroundStyle(P.basalOutline).lineStyle(line)
723+
RuleMark(x: .value("Right", right), yStart: .value("Base", 0), yEnd: .value("Basal", day.basal))
724+
.foregroundStyle(P.basalOutline).lineStyle(line)
725+
RuleMark(xStart: .value("Left", left), xEnd: .value("Right", right), y: .value("Basal", day.basal))
726+
.foregroundStyle(P.basalOutline).lineStyle(line)
727+
RuleMark(xStart: .value("Left", left), xEnd: .value("Right", right), y: .value("Base", 0))
728+
.foregroundStyle(P.basalOutline).lineStyle(line)
729+
}
730+
}
731+
712732
private var chart: some View {
713733
Chart {
714734
ForEach(totals) { day in
715735
BarMark(x: .value("Day", day.day, unit: unitWidth), yStart: .value("Base", 0), yEnd: .value("Basal", day.basal), width: .ratio(0.7))
716736
.foregroundStyle(P.basal)
717-
BarMark(x: .value("Day", day.day, unit: unitWidth), yStart: .value("Basal", max(0, day.basal - yMax * 0.006)), yEnd: .value("Edge", day.basal), width: .ratio(0.7))
718-
.foregroundStyle(P.basalEdge)
737+
basalOutline(day)
719738
ForEach(Self.bolusParts(day, gap: yMax * 0.015), id: \.automatic) { part in
720739
BarMark(x: .value("Day", day.day, unit: unitWidth), yStart: .value("Bolus start", part.start), yEnd: .value("Bolus end", part.end), width: .ratio(0.7))
721740
.foregroundStyle(part.automatic ? AnyShapeStyle(Hatch.paint(P.bolus, scheme: scheme)) : AnyShapeStyle(P.bolus))

0 commit comments

Comments
 (0)