Provide modifier to prevent propagation of toolbar preferences from a subview

Originator:darren.mo
Number:rdar://FB13437081 Date Originated:2023-12-02
Status:Open Resolved:
Product:SwiftUI Product Version:iOS 17.2 Seed 3 (21C5046c)
Classification:Suggestion Reproducible:
 
A common UX pattern is a non-root “tab view”. On iOS and macOS, this might be implemented as a segmented `Picker` in the center of the navigation bar. The `Picker` selection would determine the opacity of each tab’s content view: the selected tab’s content view would have an opacity of 1 while the rest would have an opacity of 0. The reason we are using opacity instead of making the tab content conditional is because we do not want a tab’s content to be destroyed when choosing a different tab.

This approach mostly works great, except when a tab’s content view uses the toolbar modifiers. A tab’s content view might add toolbar items or specify the visibility of certain toolbars. The issue is that the toolbar preferences from all of the tabs, even the unselected ones, are merged. Instead, the desired UX would be that only the selected tab’s toolbar preferences are propagated.

SwiftUI should provide a modifier to prevent propagation of toolbar preferences from a subview. Then, this custom tab view could apply the modifier to the unselected tab content views so that only the selected tab content view’s toolbar preferences are propagated.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!