PopoverPresenter

0.2.1

Demo SwiftUI-project with custom alerts/popovers
c-villain/PopoverPresenter

What's New

0.2.1

2022-12-30T14:40:46Z

PopoverPresenter

Latest release

contact: @lexkraev Telegram Group

👨🏻‍💻 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.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 12:52:01 GMT-0900 (Hawaii-Aleutian Daylight Time)