Skip to content

Add SwiftUI PillButtonBarView#2197

Merged
laminesm merged 56 commits intomainfrom
user/laminemale/pbb
Oct 16, 2025
Merged

Add SwiftUI PillButtonBarView#2197
laminesm merged 56 commits intomainfrom
user/laminemale/pbb

Conversation

@laminesm
Copy link
Copy Markdown
Contributor

@laminesm laminesm commented Aug 20, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

This PR adds a SwiftUI pill button bar.

This implementation uses generic binding to allow clients to set up pill selection with a Hashable Selection type that they provide to the PillButtonBarView. Each individual's pill button will have a matching PillButtonViewModel which will provide their respective Selection value used by the bar.

Moreover, this implementation supports 2 types of pill button bars:

1 - The traditional pill button bar that is restricted to 1 selected pill button at all times.
2 - A pill button bar that supports no selected pill button and a maximum of 1. In other words, if the user taps on the currently selected pill button it will be deselected (client request).

To best support this, I opted to have two separate initializers to help distinguish between the two types of pill button bars: one initializer that takes a non-optional Selection binding for the traditional pill button bar experience, and the other initializer taking an optional Selection binding for pill bars that support no selected pills. Internally, we use an optional Selection property and a bool (determining which kind of pill bar this is) to correctly set up and change pill selection.

This PR also reverts changes to the UIKit pill button made in #2188 as it was causing a bug on the UIKit pill button bar where it wouldn't show the unread dot. I've investigated the issue quite a bit and could accurately pinpoint what was happening but it seems related to some obscure logic in the bar where the buttons get created and destroyed during layout phases. Decided to simply revert as that control is very fragile and has been a source of headaches in the past with minor changes.

Binary change

Between 80 and 100KB binary impact.

Verification

Visually verified light/dark and all platforms. Disabled state doesn't look obvious on vision dark mode (though I'm not familiar with the platform), so we might need different disabled colors.

Visual Verification
iPhone Vision
iphone_pill_selection vision_pill_selection
iphone_dark vision_light
iphone_custom_theme vision_custom_theme
iphone_token_overrides vision_token_overrides
iphone_disabled vision_disabled

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@laminesm laminesm requested a review from huwilkes October 15, 2025 20:36
@laminesm laminesm enabled auto-merge (squash) October 15, 2025 20:44
@laminesm laminesm disabled auto-merge October 15, 2025 21:14
@laminesm laminesm enabled auto-merge (squash) October 15, 2025 21:24
@laminesm laminesm merged commit d4e7cc3 into main Oct 16, 2025
25 of 28 checks passed
@laminesm laminesm deleted the user/laminemale/pbb branch October 16, 2025 23:32
@joannaquu joannaquu mentioned this pull request Oct 23, 2025
12 tasks
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.

5 participants