Skip to content

feat(picker): implement Picker and built-in styles - #1280

Merged
Kyle-Ye merged 44 commits into
mainfrom
feature/picker
Nov 28, 2026
Merged

Kyle-Ye merged 44 commits into
mainfrom
feature/picker

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Nov 28, 2026

Copy link
Copy Markdown
Member

Closes #1225

Summary

  • Add Picker, PickerContent, PickerBuilder, PickerStyle, View.pickerStyle(_:), View.selectionDisabled(_:), PaletteSelectionEffect, and variadic Tag accessors for single- and multi-binding option selection.
  • Implement built-in automatic, inline, segmented, wheel, palette, radio group, section, menu, toolbar, and macOS accessory bar picker styles along with native UIKit and AppKit segmented, wheel, and radio option controls.
  • Add supporting platform item label merging, columnar form labeled content layout (HorizontalAlignment.formDetailLeading), menu title and dismissal modifiers, radio group accessibility configuration, and stack/list style context updates.
  • Add Picker example previews, hosted UI snapshot tests, and Tag unit tests.

@Kyle-Ye
Kyle-Ye requested a review from Mx-Iris as a code owner November 28, 2026 17:46
@Kyle-Ye Kyle-Ye added this to the 0.26.0 milestone Nov 28, 2026
@Kyle-Ye Kyle-Ye added type: feature New API, behavior, platform support, or user-facing capability. area: accessibility Accessibility APIs, settings, semantics, or behavior. area: data-flow State, binding, environment, preference, observation, or property data flow. area: layout Layout, geometry, safe area, alignment, stacks, or sizing. area: view View APIs, modifiers, AnyView, ForEach, DynamicView, and related behavior. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. labels Nov 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 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-28T18:14:25.832708Z f1a6340 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 the area: example Example apps, previews, sample projects, screenshots, or demo assets. label Nov 28, 2026

@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: 2179633644

ℹ️ 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 +156 to +158
let view = UIKitPickerView(frame: .zero)
view.delegate = context.coordinator
return view

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Assign the wheel picker's data source

On iOS and visionOS, UIKitWheelPicker assigns only delegate, leaving the native UIPickerView.dataSource unset. Although the coordinator implements UIPickerViewDataSource, the picker cannot obtain its component and row counts without that assignment, so .pickerStyle(.wheel) renders without selectable options. Assign context.coordinator to view.dataSource as well.

Useful? React with 👍 / 👎.

Comment on lines +123 to +125
init(selection: [Binding<SelectionValue>]) {
_selection = Binding(flattening: selection)
multiSelection = selection

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle empty source collections before flattening selection

When a picker created with sources: receives an empty collection—for example, an inspector after the user deselects all objects—this unconditional flattening crashes while constructing the configuration. Binding.init(flattening:) immediately calls FlattenedCollectionLocation.get(), whose primaryLocation force-unwraps base.first. Handle the empty-selection case before constructing a binding that requires a primary location so these pickers can remain mounted when their source collection becomes empty.

Useful? React with 👍 / 👎.

@tuist

tuist Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

🛠️ Tuist Run Report 🛠️

Tests 🧪

Scheme Status Ran test modules Commit
OpenSwiftUI ✅ 7 4528b899a

Builds 🔨

Scheme Status Duration Commit
OpenSwiftUI ✅ 38.4s 4528b899a

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

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.53551% with 1539 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.47%. Comparing base (8e33c09) to head (f1a6340).

Files with missing lines Patch % Lines
...urces/OpenSwiftUI/View/Control/Picker/Picker.swift 0.00% 292 Missing ⚠️
...ntegration/PlatformItemList/PlatformItemList.swift 7.00% 146 Missing ⚠️
...ntrol/Picker/SystemSegmentedControlStyle_Mac.swift 0.00% 139 Missing ⚠️
...UI/View/Control/Picker/RadioGroupPickerStyle.swift 0.00% 132 Missing ⚠️
...nSwiftUI/View/Control/Picker/MenuPickerStyle.swift 0.00% 84 Missing ⚠️
...penSwiftUI/View/Control/Picker/PickerContent.swift 0.00% 81 Missing ⚠️
.../OpenSwiftUI/View/Control/Picker/PickerStyle.swift 0.00% 59 Missing ⚠️
...wiftUI/View/Control/Picker/PickerContentView.swift 0.00% 56 Missing ⚠️
.../View/Control/Picker/AccessoryBarPickerStyle.swift 0.00% 50 Missing ⚠️
...OpenSwiftUI/View/Control/Button/OptionButton.swift 0.00% 48 Missing ⚠️
... and 35 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1280      +/-   ##
==========================================
- Coverage   35.16%   34.47%   -0.70%     
==========================================
  Files        1046     1080      +34     
  Lines       85616    87135    +1519     
==========================================
- Hits        30111    30039      -72     
- Misses      55505    57096    +1591     

☔ 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.

@Kyle-Ye

Kyle-Ye commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

/uitest update only-testing=OpenSwiftUIUITests/PickerUITests

@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: f1a634042e

ℹ️ 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 +119 to +123
if let text = item.base.text {
if control.label(forSegment: index) != text.string {
control.setLabel(text.string, forSegment: index)
}
} else if let image = item.base.image {

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 Clear stale segment labels and images during updates

On macOS, when a segmented picker's option changes from text to an image (or vice versa), the existing native segment retains its previous content. NSSegmentedControl stores its label and image separately, but this update loop only sets the newly applicable property, so an image-only option can still display the old title and a text-only option can retain the old icon. Clear the image in the text branch and clear the label in the image branch, including clearing both when neither is present.

Useful? React with 👍 / 👎.

@Kyle-Ye
Kyle-Ye merged commit 27d3be2 into main Nov 28, 2026
11 of 12 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/picker branch November 28, 2026 21:22
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: data-flow State, binding, environment, preference, observation, or property data flow. area: example Example apps, previews, sample projects, screenshots, or demo assets. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. 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.

Implement Picker

1 participant