From 4221356c98488195e88258e8d5aacf05df1df6ea Mon Sep 17 00:00:00 2001 From: "swu-wise[bot]" <344778455+swu-wise[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:26:03 +0000 Subject: [PATCH 1/2] [WISE] Draw the iOS usage bar pacing marker and track like the Mac --- .../App/Views/CompanionContentView.swift | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift b/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift index 98ee8e02..dddde813 100644 --- a/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift +++ b/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift @@ -1094,7 +1094,8 @@ public struct CompanionUsageBar: View { private var trackColor: Color { #if os(iOS) - return Color(uiColor: .tertiarySystemFill) + // The Mac's track token: a faint black on light, a faint white on dark. + return colorScheme == .dark ? Color.white.opacity(0.14) : Color.black.opacity(0.08) #else return Color.secondary.opacity(0.15) #endif @@ -1105,7 +1106,7 @@ public struct CompanionUsageBar: View { } private var pacingMarkerHaloColor: Color { - colorScheme == .dark ? Color.black.opacity(0.7) : Color.white.opacity(0.75) + colorScheme == .dark ? Color.black.opacity(0.7) : Color.white.opacity(0.7) } public init(remainingPercent: Double?, elapsedFraction: Double? = nil, height: CGFloat = 7) { @@ -1114,6 +1115,19 @@ public struct CompanionUsageBar: View { self.height = height } + /// Where the marker's center sits: at the elapsed fraction, kept clear of + /// the bar's rounded ends, as the Mac bar does. + private func markerCenter(fraction: CGFloat, totalWidth: CGFloat, markerWidth: CGFloat) -> CGFloat { + let half = markerWidth / 2 + let cap = height / 2 + var center = min(max(fraction * totalWidth, half), max(half, totalWidth - half)) + if totalWidth >= (half + cap) * 2 { + if center - half < cap { center = half } + else if totalWidth - (center + half) < cap { center = totalWidth - half } + } + return center + } + public var body: some View { GeometryReader { geo in let totalWidth = geo.size.width @@ -1147,14 +1161,18 @@ public struct CompanionUsageBar: View { // Pacing marker line (elapsed time fraction) if safeRemaining != nil, let frac = elapsedFraction, frac.isFinite, frac >= 0, frac <= 1.0, totalWidth > 0 { - let markerX = CGFloat(frac) * totalWidth - let markerHeight: CGFloat = 18 + // Same geometry as the Mac bar: a 3 pt marker that stands 2 pt + // proud of the bar above and below, a 1 pt halo, and a position + // that stays off the rounded ends. let markerWidth: CGFloat = 3.0 + let haloPadding: CGFloat = 1.0 + let markerHeight = height + 4 + let markerX = markerCenter(fraction: CGFloat(frac), totalWidth: totalWidth, markerWidth: markerWidth) // Halo Rectangle() .fill(pacingMarkerHaloColor) - .frame(width: 5.5, height: markerHeight + 2) + .frame(width: markerWidth + haloPadding * 2, height: markerHeight + haloPadding * 2) .position(x: markerX, y: geo.size.height / 2) // Line From 387b483c8e881ac81a9853c65b04f872396885c9 Mon Sep 17 00:00:00 2001 From: "swu-wise[bot]" <344778455+swu-wise[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:38:51 +0000 Subject: [PATCH 2/2] [WISE] Keep the pinned 18 pt iOS marker; match the Mac clamp, halo trim and narrow-bar rule --- .../App/Views/CompanionContentView.swift | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift b/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift index dddde813..16a5a5b8 100644 --- a/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift +++ b/ios/CodeCapsCompanion/App/Views/CompanionContentView.swift @@ -1115,17 +1115,21 @@ public struct CompanionUsageBar: View { self.height = height } - /// Where the marker's center sits: at the elapsed fraction, kept clear of - /// the bar's rounded ends, as the Mac bar does. - private func markerCenter(fraction: CGFloat, totalWidth: CGFloat, markerWidth: CGFloat) -> CGFloat { + /// Where the marker and its halo sit, as the Mac bar lays them out: the + /// marker at the elapsed fraction, kept clear of the rounded ends, and the + /// halo trimmed to the bar. Narrower than the marker, it sits in the middle. + private func markerLayout(fraction: CGFloat, totalWidth: CGFloat, markerWidth: CGFloat, haloPadding: CGFloat) + -> (center: CGFloat, haloStart: CGFloat, haloEnd: CGFloat) { + guard totalWidth > markerWidth else { return (totalWidth / 2, 0, totalWidth) } let half = markerWidth / 2 let cap = height / 2 - var center = min(max(fraction * totalWidth, half), max(half, totalWidth - half)) + var center = min(max(fraction * totalWidth, half), totalWidth - half) if totalWidth >= (half + cap) * 2 { if center - half < cap { center = half } else if totalWidth - (center + half) < cap { center = totalWidth - half } } - return center + let reach = half + haloPadding + return (center, max(0, center - reach), min(totalWidth, center + reach)) } public var body: some View { @@ -1161,19 +1165,19 @@ public struct CompanionUsageBar: View { // Pacing marker line (elapsed time fraction) if safeRemaining != nil, let frac = elapsedFraction, frac.isFinite, frac >= 0, frac <= 1.0, totalWidth > 0 { - // Same geometry as the Mac bar: a 3 pt marker that stands 2 pt - // proud of the bar above and below, a 1 pt halo, and a position - // that stays off the rounded ends. + // Same placement as the Mac bar: a 1 pt halo, a position that + // stays off the rounded ends, and a halo trimmed to the bar. let markerWidth: CGFloat = 3.0 let haloPadding: CGFloat = 1.0 - let markerHeight = height + 4 - let markerX = markerCenter(fraction: CGFloat(frac), totalWidth: totalWidth, markerWidth: markerWidth) + let markerHeight: CGFloat = 18 + let layout = markerLayout(fraction: CGFloat(frac), totalWidth: totalWidth, markerWidth: markerWidth, haloPadding: haloPadding) + let markerX = layout.center // Halo Rectangle() .fill(pacingMarkerHaloColor) - .frame(width: markerWidth + haloPadding * 2, height: markerHeight + haloPadding * 2) - .position(x: markerX, y: geo.size.height / 2) + .frame(width: layout.haloEnd - layout.haloStart, height: markerHeight + haloPadding * 2) + .position(x: (layout.haloStart + layout.haloEnd) / 2, y: geo.size.height / 2) // Line Rectangle()