Give ProgressView a label and a style - #54
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProgressViewworked 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:.progressViewStyle(.linear)/.circular), defaulting to.automatic, which keeps the old value-derived behaviorLabels
ProgressView("Loading…"),ProgressView("Copying", value:), and the builder formProgressView(value:) { … }. The label resolves as children and renders beneath the indicator.ProgressViewis now generic over its label, withEmptyView-constrained initializers so the existingProgressView()andProgressView(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 againsttotal, both style overrides, and that the label-free forms stay label-free.progressat 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/.linearspelling only — theProgressViewStyleprotocol for custom styles isn't modeled, and neither iscurrentValueLabel. 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.