How popup presentations work in LNPopupUI
masterA popup presentation is composed of several key abstractions:
- Popup container view: The
Viewthat hosts the presentation (e.g., aTabVieworNavigationStack). It is recommended to apply the popup modifier to the outermost view. - Popup content controller: The
Viewthat represents the content shown when the popup is fully open. - Popup bar: A bar docked to the bottom of the container view. It displays at-a-glance information and allows user interaction (swiping/tapping) to open the content view.
- Popup items: The data source that provides the information (title, image, etc.) displayed on the popup bar.
- Custom popup bar view: An optional custom implementation of the bar.
To implement a popup, use the .popup(isBarPresented:isPopupOpen:content:) modifier. You control the visibility of the bar and the open state by toggling the bound boolean variables.
// Example of the core structure
TabView {
// Container content
}
.popup(isBarPresented: $isPopupBarPresented, isPopupOpen: $isPopupOpen) {
// Popup content view
PlayerView()
.popupItems(selection: $currentSong) {
// ... items ...
}
}