ProHUD/Source/Guard/GuardModel.swift

77 lines
2.1 KiB
Swift
Raw Permalink Normal View History

2019-08-09 18:02:41 +08:00
//
// GuardModel.swift
// ProHUD
//
// Created by xaoxuu on 2019/8/9.
// Copyright © 2019 Titan Studio. All rights reserved.
//
import UIKit
public extension Guard {
2019-08-12 20:20:07 +08:00
struct ViewModel {
2019-08-09 18:02:41 +08:00
2021-07-20 16:04:39 +08:00
weak var vc: Guard?
2019-08-09 18:02:41 +08:00
}
}
public extension Guard.ViewModel {
///
/// - Parameter text:
@discardableResult func add(title: String?) -> UILabel {
return vc!.add(title: title)
}
///
/// - Parameter text:
@discardableResult func add(subTitle: String?) -> UILabel {
return vc!.add(subTitle: subTitle)
}
///
/// - Parameter text:
@discardableResult func add(message: String?) -> UILabel {
return vc!.add(message: message)
}
///
/// - Parameter style:
/// - Parameter title:
/// - Parameter action:
@discardableResult func add(action style: UIAlertAction.Style, title: String?, handler: (() -> Void)?) -> UIButton {
2019-08-12 15:02:36 +08:00
return vc!.insert(action: nil, style: style, title: title, handler: handler)
2019-08-09 18:02:41 +08:00
}
2019-08-12 20:20:07 +08:00
///
2019-08-09 18:02:41 +08:00
/// - Parameter index:
/// - Parameter style:
/// - Parameter title:
/// - Parameter handler:
2019-08-12 15:02:36 +08:00
@discardableResult func insert(action index: Int, style: UIAlertAction.Style, title: String?, handler: (() -> Void)?) -> UIButton {
return vc!.insert(action: index, style: style, title: title, handler: handler)
2019-08-09 18:02:41 +08:00
}
///
/// - Parameter index:
/// - Parameter style:
/// - Parameter title:
/// - Parameter handler:
2019-08-12 15:02:36 +08:00
func update(action index: Int, style: UIAlertAction.Style, title: String?, handler: (() -> Void)?) {
vc?.update(action: index, style: style, title: title, handler: handler)
2019-08-09 18:02:41 +08:00
}
///
/// - Parameter index:
func remove(action index: Int...) {
for (i, idx) in index.enumerated() {
2019-08-12 15:02:36 +08:00
vc?.remove(index: idx-i)
2019-08-09 18:02:41 +08:00
}
}
}