ProHUD/Source/Guard/GuardModel.swift

77 lines
2.1 KiB
Swift

//
// GuardModel.swift
// ProHUD
//
// Created by xaoxuu on 2019/8/9.
// Copyright © 2019 Titan Studio. All rights reserved.
//
import UIKit
public extension Guard {
struct ViewModel {
weak var vc: Guard?
}
}
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 {
return vc!.insert(action: nil, style: style, title: title, handler: handler)
}
///
/// - Parameter index:
/// - Parameter style:
/// - Parameter title:
/// - Parameter handler:
@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)
}
///
/// - Parameter index:
/// - Parameter style:
/// - Parameter title:
/// - Parameter handler:
func update(action index: Int, style: UIAlertAction.Style, title: String?, handler: (() -> Void)?) {
vc?.update(action: index, style: style, title: title, handler: handler)
}
///
/// - Parameter index:
func remove(action index: Int...) {
for (i, idx) in index.enumerated() {
vc?.remove(index: idx-i)
}
}
}