summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Operations/AlertPresenter.swift
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@kvadrat.se>2023-05-22 13:25:38 +0200
committerJon Petersson <jon.petersson@kvadrat.se>2023-06-08 16:36:40 +0200
commite4677b9fe4b22bfbdb9140507ad6222feddf6b9d (patch)
tree533abd51cf76d60786ef4f9130d47d271707d6fd /ios/MullvadVPN/Operations/AlertPresenter.swift
parent04e49a9f00467a35138ba12d4c812397797ff1ce (diff)
downloadmullvadvpn-e4677b9fe4b22bfbdb9140507ad6222feddf6b9d.tar.xz
mullvadvpn-e4677b9fe4b22bfbdb9140507ad6222feddf6b9d.zip
Create custom alert dialogs
Diffstat (limited to 'ios/MullvadVPN/Operations/AlertPresenter.swift')
-rw-r--r--ios/MullvadVPN/Operations/AlertPresenter.swift41
1 files changed, 4 insertions, 37 deletions
diff --git a/ios/MullvadVPN/Operations/AlertPresenter.swift b/ios/MullvadVPN/Operations/AlertPresenter.swift
index bb86989d78..7c31017a4e 100644
--- a/ios/MullvadVPN/Operations/AlertPresenter.swift
+++ b/ios/MullvadVPN/Operations/AlertPresenter.swift
@@ -9,30 +9,11 @@
import Operations
import UIKit
-public final class AlertPresenter {
- static let alertControllerDidDismissNotification = Notification
- .Name("UIAlertControllerDidDismiss")
-
+final class AlertPresenter {
private let operationQueue = AsyncOperationQueue.makeSerial()
- private static let initClass: Void = {
- /// Swizzle `viewDidDisappear` on `UIAlertController` in order to be able to
- /// detect when the controller disappears.
- /// The event is broadcasted via
- /// `AlertPresenter.alertControllerDidDismissNotification` notification.
- swizzleMethod(
- aClass: UIAlertController.self,
- originalSelector: #selector(UIAlertController.viewDidDisappear(_:)),
- newSelector: #selector(UIAlertController.alertPresenter_viewDidDisappear(_:))
- )
- }()
-
- public init() {
- _ = Self.initClass
- }
-
- public func enqueue(
- _ alertController: UIAlertController,
+ func enqueue(
+ _ alertController: CustomAlertViewController,
presentingController: UIViewController,
presentCompletion: (() -> Void)? = nil
) {
@@ -45,21 +26,7 @@ public final class AlertPresenter {
operationQueue.addOperation(operation)
}
- public func cancelAll() {
+ func cancelAll() {
operationQueue.cancelAllOperations()
}
}
-
-private extension UIAlertController {
- @objc dynamic func alertPresenter_viewDidDisappear(_ animated: Bool) {
- // Call super implementation
- alertPresenter_viewDidDisappear(animated)
-
- if presentingViewController == nil {
- NotificationCenter.default.post(
- name: AlertPresenter.alertControllerDidDismissNotification,
- object: self
- )
- }
- }
-}