Skip to content

feat(gauge): implement Gauge and built-in styles - #1266

Merged
Kyle-Ye merged 19 commits into
mainfrom
feature/gauge
Nov 24, 2026
Merged

Kyle-Ye merged 19 commits into
mainfrom
feature/gauge

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add Gauge with value normalization, label configuration, accessibility, and built-in linear and circular styles.
  • Support gauge tint customization, layout direction, and native macOS capacity indicators.
  • Correct right-to-left placement and offset handling, and apply the correct opacity to redacted text.
  • Cover the Gauge API and styles with unit and snapshot tests.

Closes #1022

@Kyle-Ye Kyle-Ye added this to the 0.26.0 milestone Nov 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T16:02:21.535593Z 8c17702 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added area: accessibility Accessibility APIs, settings, semantics, or behavior. area: layout Layout, geometry, safe area, alignment, stacks, or sizing. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. area: view View APIs, modifiers, AnyView, ForEach, DynamicView, and related behavior. type: feature New API, behavior, platform support, or user-facing capability. labels Nov 24, 2026
@Kyle-Ye

Kyle-Ye commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

/uitest osui-iag update only-testing=OpenSwiftUIUITests/GaugeUITests

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d351f30175

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +225 to +228
if configuration.currentValueLabel != nil {
HStack { configuration.currentValueLabel }
} else {
HStack { configuration.label }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the circular capacity gauge's accessibility label

When an .accessoryCircularCapacity gauge supplies a currentValueLabel, this branch renders only that value and never includes configuration.label in the accessibility subtree. AccessibilityGaugeModifier combines existing children and adds the numeric value; it does not restore the omitted purpose label. Consequently, a gauge labeled “Battery” with a current-value label of “75” loses “Battery” for accessibility users. Add an accessibility representation containing both labels, as the other gauge implementations do.

Useful? React with 👍 / 👎.

Comment on lines +298 to +302
private struct OpenRing: Shape {
var lineWidth: CGFloat
var radius: CGFloat
var startAngle: Angle
var endAngle: Angle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Animate the open-ring marker alongside its cutout

When an .accessoryCircular gauge's value changes inside an animation, RotationOffsetEffect animates the destination-out cutout, but OpenRing inherits empty animatable data, so the visible marker immediately jumps to its final angle. During the transition, the hole and marker occupy different positions, leaving a detached marker and an unrelated gap in the track. Expose the ring's angles through animatableData so the marker and cutout interpolate together.

Useful? React with 👍 / 👎.

Comment on lines +123 to +125
if let controlTint {
nsView.fillColor = NSColor(controlTint)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset the native gauge fill when its tint is removed

On macOS, changing a gauge's tint from a color to nil reuses the existing NSLevelIndicator, but this conditional skips updating fillColor. The indicator therefore retains the previous custom color instead of returning to its default appearance. Handle the nil case by restoring the native default fill color rather than leaving the previous value installed.

Useful? React with 👍 / 👎.

@tuist

tuist Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🛠️ Tuist Run Report 🛠️

Tests 🧪

Scheme Status Ran test modules Commit
OpenSwiftUI ✅ 7 1ecb8ded4

Builds 🔨

Scheme Status Duration Commit
OpenSwiftUI ✅ 2m 53s 1ecb8ded4

Reported by Tuist, faster builds and reliable tests for Xcode, Gradle, Bazel, and more.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.07480% with 738 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.71%. Comparing base (87752c3) to head (8c17702).

Files with missing lines Patch % Lines
...ol/Gauge/AccessoryCircularCapacityGaugeStyle.swift 0.00% 195 Missing ⚠️
...tUI/View/Control/Gauge/HalfOpenCircularGauge.swift 0.00% 195 Missing ⚠️
Sources/OpenSwiftUI/View/Control/Gauge/Gauge.swift 27.97% 103 Missing ⚠️
...View/Control/Gauge/AccessoryLinearGaugeStyle.swift 0.00% 72 Missing ⚠️
.../View/Control/Gauge/LinearCapacityGaugeStyle.swift 0.00% 70 Missing ⚠️
...trol/Gauge/AccessoryLinearCapacityGaugeStyle.swift 0.00% 23 Missing ⚠️
...es/OpenSwiftUI/View/Control/Gauge/GaugeStyle.swift 0.00% 18 Missing ⚠️
...tUI/Accessibility/AccessibilityConfiguration.swift 0.00% 17 Missing ⚠️
...ew/Control/Gauge/AccessoryCircularGaugeStyle.swift 0.00% 12 Missing ⚠️
...enSwiftUICore/Shape/ShapeStyle/AnyShapeStyle.swift 0.00% 7 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1266      +/-   ##
==========================================
- Coverage   31.76%   31.71%   -0.05%     
==========================================
  Files        1033     1046      +13     
  Lines       85191    85540     +349     
==========================================
+ Hits        27059    27133      +74     
- Misses      58132    58407     +275     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c177026b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +323 to +325
if fractionCompleted > 0.5 {
RingArc(fractionCompleted: fractionCompleted, lineWidth: lineWidth, firstHalf: false)
.fill(foreground)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the second ring arc alive across animated value changes

When an .accessoryCircularCapacity gauge animates across 50%, such as from 0.25 to 0.75, this conditional inserts the second arc already at its final fraction. Its animatableData therefore cannot interpolate from the previous value: the second arc fades in at its final length while the first arc and end cap continue moving, temporarily displaying fill ahead of the cap. Keep the second arc structurally present and control its visibility using the interpolated fraction so both halves track the same animated progress.

Useful? React with 👍 / 👎.

@Kyle-Ye
Kyle-Ye merged commit 7d0df61 into main Nov 24, 2026
7 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/gauge branch November 24, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: accessibility Accessibility APIs, settings, semantics, or behavior. area: layout Layout, geometry, safe area, alignment, stacks, or sizing. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. area: view View APIs, modifiers, AnyView, ForEach, DynamicView, and related behavior. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Gauge support

1 participant