Add confirmation prompt for removing keys (fix #491)

This commit is contained in:
Mingshen Sun 2021-12-29 16:19:12 -08:00
parent 7320319031
commit ff6a1edf62
7 changed files with 42 additions and 9 deletions

View file

@ -28,6 +28,10 @@ public extension UIAlertAction {
UIAlertAction(title: "Ok".localize(), style: .default, handler: handler)
}
static func remove(handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction {
UIAlertAction(title: "Remove".localize(), style: .destructive, handler: handler)
}
static func okAndPopView(controller: UIViewController) -> UIAlertAction {
ok { _ in
controller.navigationController?.popViewController(animated: true)

View file

@ -0,0 +1,17 @@
//
// UIAlertControllerExtension.swift
// passKit
//
// Copyright © 2021 Bob Sun. All rights reserved.
//
import Foundation
public extension UIAlertController {
class func removeConfirmationAlert(title: String, message: String, handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertController {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction.remove(handler: handler))
alert.addAction(UIAlertAction.cancel())
return alert
}
}