Easily to present different popups from any subview over fullscreen on SwiftUI.
![]() |
![]() |
![]() |
Swift Package Manager:
https://github.com/Jnis/ZPopupPresenter.git
import ZPopupPresenter
struct ContentView: View {
let zPopupPresenterModel = ZPopupPresenterModel() // 1.1. shared model
var body: some View {
MyView()
.environmentObject(zPopupPresenterModel) // 1.2. inject model for subviews
.overlay {
ZPopupPresenterView(model: zPopupPresenterModel) // 2. popups place
}
}
}
showPopup
method of shared model and wrap your view with AnyView( ... )
close
closure to remove popupstruct MyView: View {
@EnvironmentObject var zPopupPresenterModel: ZPopupPresenterModel // shared model
var body: some View {
VStack {
Button("Show Popup", action: {
zPopupPresenterModel.showPopup({ close in // 3.
AnyView(
DemoPopup1View(closeBlock: close) // 4.
)
})
})
}
}
}
You can find more examples inside /Examples
folder.
MIT
link |
Stars: 2 |
Last commit: 5 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics