-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ListItem on visionOS #2000
Add support for ListItem on visionOS #2000
Conversation
What happens if the Are we just assuming that the implementor makes the right decision? I guess I am a bit worried about the implications as there is a lot of bad implementations of MSFTTableViewCell because of how much it allows. Should we be adding in something that helps to identify what the action should be so we can handle it correctly and have it not be a button when used in a navigation link? For example we have toggle, push on navigation stack (navigation link), or just a simple action. |
ios/FluentUI.Demo/FluentUI.Demo/Demos/ListItemDemoController_SwiftUI.swift
Show resolved
Hide resolved
Can you add a screenshot of what it looks like in VoiceOver when the whole listItem is selected? |
Platforms Impacted
Description of changes
Adding support for
ListItem
on visionOS.Currently,
ListItem
internally is aView
, which means on visionOS, there is no hover/gaze effect. When there are no tap gestures added to the view, this is ok. However, when theListItem
is tappable, this presents a usability issue (users can't tell where they are and may not be aware the view is tappable). To fix this, updateListItem
to be aButton
when necessary.List of changes
action
is an optional closure that executes when theListItem
is tapped.ListItemButtonStyle
: a custom SwiftUI button style that is applied whenListItem
is aButton
TableViewCell
cellBackgroundSelectedColor
as the background color when selectedListItem
itselfbuttonStyle
on theListItem
will trickle down to the detail button. Explicitly set the detail button's style. On iOS, it should be.plain
and on visionOS it should be.bordered
ListItem
was first implemented, it was done so to mimicTableViewCell
as closely as possible. This meant a larger padded detail button. To achieve this, the accessory view's padding was applied to the image and an extra background was added to address VoiceOver. Both of these changes do not work on visionOS (bloated button and darker background).innerContent
instead. Changes made:paddingLeading/paddingTrailing/paddingVertical
are always be oninnerContent
. No matter what's inside the list item, these padding values always apply (this allows us to remove all the conditional code depending on if there's atrailingContentView
/accessory view.horizontalSpacing
should then apply to the leading edge of thetrailingContentView
and accessory view. Since it's on the leading edge, we don't run into the issue of double padding.TableViewCell
, notListItem
(see screenshot ofUITableViewCell
)action
is nil,ListItem
should still be aView
ListItemDemoController_SwiftUI
with an option to add/remove anaction
ListItem
outsideList
Binary change
Total increase: 56,264 bytes
Total decrease: -1,568 bytes
Full breakdown
Verification
Visual Verification
Standalone
ListItem
VoiceOver change
Pull request checklist
This PR has considered:
Microsoft Reviewers: Open in CodeFlow