mirror of
https://github.com/jphong1111/awesome-ios-developer.git
synced 2025-02-20 11:38:34 +07:00
Delete AlertProtocol.swift
This commit is contained in:
parent
3d28a95b89
commit
147736373c
@ -1,45 +0,0 @@
|
|||||||
//
|
|
||||||
// AlertProtocol.swift
|
|
||||||
// VariousManagerDemoApp
|
|
||||||
//
|
|
||||||
// Created by JungpyoHong on 4/21/21.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
enum AlertButton: String {
|
|
||||||
case ok
|
|
||||||
case cancel
|
|
||||||
case delete
|
|
||||||
case settings
|
|
||||||
}
|
|
||||||
|
|
||||||
protocol AlertProtocol: UIViewController {
|
|
||||||
func showAlert(title: String, message: String, buttons: [AlertButton], completion: @escaping (UIAlertController, AlertButton) -> Void)
|
|
||||||
}
|
|
||||||
|
|
||||||
extension AlertProtocol {
|
|
||||||
|
|
||||||
func showAlert(title: String, message: String, buttons: [AlertButton] = [.ok], completion: @escaping (UIAlertController, AlertButton) -> Void) {
|
|
||||||
|
|
||||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
||||||
|
|
||||||
buttons.forEach { button in
|
|
||||||
let action = UIAlertAction(title: button.rawValue.capitalized, style: button == .delete ? .destructive : .default) { [alert, button] _ in
|
|
||||||
completion(alert, button)
|
|
||||||
}
|
|
||||||
alert.addAction(action)
|
|
||||||
}
|
|
||||||
self.present(alert, animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protocol CellReusable {
|
|
||||||
static var identifier: String { get }
|
|
||||||
}
|
|
||||||
|
|
||||||
extension CellReusable {
|
|
||||||
static var identifier: String {
|
|
||||||
String(describing: self)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user