Swiftpack.co - c-villain/PopoverPresenter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by c-villain.
c-villain/PopoverPresenter 0.1.0
Demo SwiftUI-project with custom alerts/popovers
⭐️ 1
🕓 21 weeks ago
iOS
.package(url: "https://github.com/c-villain/PopoverPresenter.git", from: "0.1.0")

PopoverPresenter

👨🏻‍💻 Feel free to subscribe to channel SwiftUI dev in telegram.

Demo project with tutorial how to customize alerts or popovers in SwiftUI based on this article.

Before starting highly recommended to read SwiftUI Custom Environment Values.

demo

Installation

To use PopoverPresenter with a project targeting iOS 13, simply copy folder Source into your project.

Swift Package Manager

To integrate PopoverPresenter into your project using SwiftPM add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/c-villain/PopoverPresenter", from: "0.1.0"),
],

Quick start

  1. Import library to your root-file view:
import PopoverPresenter
  1. Init instance in root view:
@StateObject var popoverPresenter = PopoverPresenter()
  1. Add modifier to root-object view:
.environment(\.popoverPresenterKey, popoverPresenter)
.customPopover(item: $popoverPresenter.activePopover) { popover in
    switch popover {
    default:
        popoverPresenter.currentPopover
    }
}
  1. In child view create link to environment key:
@Environment(\.popoverPresenterKey) var popoverPresenter
  1. In child view create view with alert:
popoverPresenter.currentPopover = AnyView(Text("This is alert!"))
popoverPresenter.activePopover = .any

You may look iOS example in package for guide steps above.

GitHub

link
Stars: 1
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.1.0
21 weeks ago

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