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.
Summary
Graphic Lab now enables only color counts that the current palette and strategy can actually produce. Valid selections are retained; unavailable selections fall back to the largest available count. A single-color result disables all four options and displays an explanation.
Background
The lab always enabled 2–5, but the renderer can exhaust its eligible middle colors before reaching the requested count. It also retains two identical endpoint stops for a single-color result. Counting palette entries or returned stops alone therefore overstates the available choices.
A representative local reproduction produces one distinct color for Vibrant, two for Contrast, and up to four for Muted. This change derives those limits from the resolver rather than special-casing the image, strategies, or colors.
Solution
PaletteGraphic.resolvedStopColorsproperty, backed by the same internal resolution entry point as rendering. Anchor fallbacks, candidate filtering, bisection, ordering, and rendering are unchanged.GraphicColorOptions: resolve each requested count, count distinct RGB values, and enable a count only when the result fulfills it. No private selection algorithm is duplicated in the demo..twoas the rendering fallback while showing no selected segment.UISegmentedControlfor per-segment disabling, native disabled accessibility state, a Colors label, and explanatory text/hint. On both iOS 17.5 and 26.4, a separate SwiftUI segmented Picker probe confirmed that child.disabled(true)still allowed the supposedly disabled segment to be selected. UIKit'ssetEnabled(_:forSegmentAt:)blocked the same tap.Related Issue
N/A.
Verification
swift package resolveswift build -c debugswift test --filter PaletteKitTests --filter PaletteKitInsightsTests— 59 tests reported, with the availability-gated live model test skipped.xcodebuild test -scheme PaletteKit-Package -only-testing:PaletteKitTests -only-testing:PaletteKitInsightsTests -destination 'id=<iOS-26.4-simulator>'— all 150 core tests passed. The unrelated live Insights test failed because the simulator advertised model availability but lacked the Apple Intelligence model assets.xcodebuild test -scheme PaletteKit-Package -only-testing:PaletteKitInsightsTests -skip-testing:PaletteKitInsightsTests/LiveGenerationTests -destination 'id=<iOS-26.4-simulator>'— all 8 offline Insights tests passed.xcodegen generate --spec Examples/PaletteKitDemo/project.ymlxcodebuild test -project Examples/PaletteKitDemo/PaletteKitDemo.xcodeproj -scheme PaletteKitDemo -destination 'id=<simulator>' CODE_SIGNING_ALLOWED=NO— demo build and all 6 tests passed on both iOS 17.5 and 26.4.git diff --checkCompatibility and Impact
PaletteGraphic.resolvedStopColors; changelog updated. No existing signatures change.Additional Context
Based directly on
main. Implementation and test files do not overlap the open performance PRs #23, #24, and #25; #25 also updates the changelog. The user photo and temporary UI harness remain local and are not included in the branch or uploaded. All committed fixtures are synthetic.Checklist