(Experimental libraries) Controls interrupt handling, such as alert views, and is compatible with UIKit and Swift UI.

Overview

UIPresentCoordinator

Platform License Version

Controls interrupt handling, such as alert views, and is compatible with UIKit and Swift UI.

This library manages items that are about to be presented in a queue and displays them on a first-in, first-out basis.

I have also tried to control the dialogs that the system displays, such as Push Notifications, App Tracking Transparency, and Location, but it has proven difficult.

Motivation

The purpose of creating this library was to make it easier to solve the following problems.

[Presentation] Attempt to present <UIAlertController> on <ViewController>  which is already presenting <UIViewController>.

In addition, I felt it was necessary to have a mechanism that takes into account SwiftUI as well as UIKit.

Requirements

  • iOS 13+
  • Swift 5

Demo

Before After
Before After

Demo

Installation

SwiftPM

  • File > Swift Packages > Add Package Dependency...
  • Add https://github.com/srea/UIPresentCoordinator

CocoaPods

pod 'UIPresentCoordinator'

Usage

Option

Queue control.

// Suspend queue processing.
UIPresentCoordinator.shared.suspend()
// Resume queue processing.
UIPresentCoordinator.shared.resume()

Interrupt suppression.

Set the class for automatic interrupt control.

UIPresentCoordinator.shared.interruptSuppressionTargets = [
    FirebaseInAppMessagingInterruptSuppression(),
    SystemAlertInterruptSuppression(),
    UserDefineInterruptSuppression.init(objects: [CustomDialogViewController.self])
]

UIKit

Before

// Display without interruption
let alert = UIAlertController(...)
...
present(alert, animated: true, completion: nil)

After

// Display without interruption
let alert = UIAlertController(...)
...
presentQueue(alert, animated: true, completion: nil)

SwiftUI

Before

struct DebugView: View {

    @State private var isPresented = false
    
    var body: some View {
        Button("Show Alert", action: {
            isPresented = true
        })
        .alert(isPresented: $isPresented) {
            Alert(title: Text("Alert"))
        }
    }
}

After

struct DebugView: View {
    private let presentCoordinator: UIPresentable = UIPresentCoordinator.shared

    @ObservedObject private var alertTask = Task<Alert>()
    
    var body: some View {
        Button("Show Alert", action: {
            presentCoordinator.enqueue(.alert(alertTask.content({
                Alert(title: Text("Alert"))
            })))
        })
        .alert(isPresented: $alertTask.isPresented) {
            presentCoordinator.dequeue()
        }
    }
}

Contributions

Your ideas, bug fixes, improvements, etc. are all welcome. 🐢

Special Thanks

License

UIPresentCoordinator is licensed under the MIT license. See LICENSE for more info.

You might also like...
A Simple Customizable Alert With Swift
A Simple Customizable Alert With Swift

SimpleCustomizableAlert trying to make my very first library. Support Title Message (TextView) Image TextField Button Action Example let alert

Swift UI Kit to present clean modal/alert
Swift UI Kit to present clean modal/alert

CleanyModal is a good way to use UI-Customised alerts with ease Features Present some kind of clean alerts (With same API as UIAlertViewController) Ad

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

PMAlertController is a great and customizable alert that can substitute UIAlertController
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

PMAlertController is a great and customizable alert that can substitute UIAlertController
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.
BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

BPStatusBarAlert BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

A simple alert with logo image and color.
A simple alert with logo image and color.

YMLogoAlert About YMLogoAlert A simple custom alert. YMLogoAlert lets you pop up a simple alert with a natural animation, your app's own color, font a

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

Releases(0.1.1)
Owner
Yuki Tamazawa
Less is more.🐢🐢🐢
Yuki Tamazawa
JAlert - This is "Alert View" project for UIKit + SwiftUI. you can use easily

JAlert Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation JAlert is a

Jackson 3 Feb 22, 2022
Package for creating, modifying, and managing subtitle files, such as SubRip (.srt).

SubtitleKit Package for creating, modifying, and managing subtitle files, such as SubRip (.srt). Supported formats Format File extension Is supported

GGorAA 2 Oct 28, 2022
📑 Actionsheet with navigation features such as the Flipboard App

?? SHEET helps you easily create a wide variety of action sheets with navigation features used in the Flipboard App Installation CocoaPods pod 'Sheet'

ArLupin 322 Nov 28, 2022
Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController. Screenshots Animations Usage Basic usage witho

Candost Dagdeviren 1.1k Dec 30, 2022
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
Beautiful animated Alert View. Written in Swift

SCLAlertView Animated Alert View written in Swift, which can be used as a UIAlertView or UIAlertController replacement. Since UIAlertView is deprecate

Viktor Radchenko 5.2k Jan 3, 2023
Live animated Alert View for iOS written in Swift

Sweet Alert iOS Beautiful Animated custom Alert View inspired from javascript library SweetAlert. Written in Swift this SweetAlertView can be used in

Sahil 2k Dec 22, 2022
A Swift package for iOS/tvOS for easy alert presentation

AlertPresenter Listed on the Swift Package Index and originally posted on my blog. It can be fiddly to handle the presentation of alerts on a specific

Chris Mash 14 Jul 1, 2022
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022