Swiftpack.co - Jnis/ZPopupPresenter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Jnis.
Jnis/ZPopupPresenter 1.0.1
Easily to present different popups from any subview over fullscreen on SwiftUI
⭐️ 2
🕓 25 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Jnis/ZPopupPresenter.git", from: "1.0.1")

ZPopupPresenter

Easily to present different popups from any subview over fullscreen on SwiftUI.

Features

  • present different popups of different classes without pre-declaration
  • possible to start presenting from any subview or part of code
  • present over full screen (or part of screen you really need)
  • present several popups
  • no need a flag or constants
  • supports animations

Installing

Swift Package Manager:

https://github.com/Jnis/ZPopupPresenter.git

Usage

  1. Make a shared PresenterModel (ex. by using environment property)
  2. Add ZPopupPresenterView as overlay of your root view
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
            }
    }
}
  1. call showPopup method of shared model and wrap your view with AnyView( ... )
  2. call close closure to remove popup
struct 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.

License

MIT

GitHub

link
Stars: 2
Last commit: 25 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics