Skip to content

Give ProgressView a label and a style - #54

Merged
colemancda merged 5 commits into
masterfrom
feature/progressview
Jul 24, 2026
Merged

Give ProgressView a label and a style#54
colemancda merged 5 commits into
masterfrom
feature/progressview

Conversation

@colemancda

Copy link
Copy Markdown
Member

ProgressView worked for the two common cases but had two gaps: it couldn't carry a label, and it conflated two independent things — determinacy and shape.

The conflation

Shape was inferred from whether a value was present: a value meant a linear bar, no value meant a circular spinner. So ProgressView(value:) drawn as a ring was simply impossible to express, as was an indeterminate bar. These are separate axes in SwiftUI, and now here too:

  • determinacy — is there a value?
  • shape.progressViewStyle(.linear) / .circular), defaulting to .automatic, which keeps the old value-derived behavior

Labels

ProgressView("Loading…"), ProgressView("Copying", value:), and the builder form ProgressView(value:) { … }. The label resolves as children and renders beneath the indicator. ProgressView is now generic over its label, with EmptyView-constrained initializers so the existing ProgressView() and ProgressView(value:) call sites are untouched (verified — the gallery's existing usages compile unchanged).

Verification

  • swift test — 2 new tests, 84 total passing. They cover value normalization against total, both style overrides, and that the label-free forms stay label-free.
  • Emulator (ProgressView screen, two new sections), screenshot-checked. The load-bearing one: with progress at 25% the determinate ring shows a quarter arc, and after advancing to 75% the same ring shows a three-quarter arc — determinate-plus-circular tracking a real value, which the old implementation couldn't render at all. The indeterminate linear bar animates alongside it.

Scope

This is the .circular/.linear spelling only — the ProgressViewStyle protocol for custom styles isn't modeled, and neither is currentValueLabel. It is, though, the first style-ish modifier in the codebase, so it sets the shape for the broader style system (.buttonStyle, .listStyle, …) that's still outstanding.

@colemancda
colemancda merged commit d56ba52 into master Jul 24, 2026
6 checks passed
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.

1 participant