|
|
@ -33,14 +33,26 @@ import Foundation
|
|
|
|
public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) {
|
|
|
|
public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) {
|
|
|
|
assert(title.characters.count > 0)
|
|
|
|
assert(title.characters.count > 0)
|
|
|
|
|
|
|
|
|
|
|
|
let actionTitle = (buttonTitle != nil ? buttonTitle : NSLocalizedString("OK", comment: ""))
|
|
|
|
let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "")
|
|
|
|
|
|
|
|
|
|
|
|
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
|
|
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
|
|
alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: nil))
|
|
|
|
alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: nil))
|
|
|
|
UIApplication.shared.frontmostViewController?.present(alert, animated: true, completion: nil)
|
|
|
|
UIApplication.shared.frontmostViewController?.present(alert, animated: true, completion: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class func cancelAction() -> UIAlertAction {
|
|
|
|
public class func showConfirmationAlert(withTitle title: String, message: String? = nil, proceedTitle: String? = nil, proceedAction: @escaping (UIAlertAction) -> Void) {
|
|
|
|
|
|
|
|
assert(title.characters.count > 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
|
|
|
|
|
|
alert.addAction(self.cancelAction)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let actionTitle = proceedTitle ?? NSLocalizedString("OK", comment: "")
|
|
|
|
|
|
|
|
alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: proceedAction))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIApplication.shared.frontmostViewController?.present(alert, animated: true, completion: nil)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class var cancelAction: UIAlertAction {
|
|
|
|
let action = UIAlertAction(title: CommonStrings.cancelButton, style: .cancel) { _ in
|
|
|
|
let action = UIAlertAction(title: CommonStrings.cancelButton, style: .cancel) { _ in
|
|
|
|
Logger.debug("Cancel item")
|
|
|
|
Logger.debug("Cancel item")
|
|
|
|
// Do nothing.
|
|
|
|
// Do nothing.
|
|
|
|