//
//  AlertController.swift
//  PaiaiUIKit
//
//  Created by ffib on 2019/1/21.
//  Copyright © 2019 yb. All rights reserved.
//

import Foundation

public class AlertController: AlertViewController {
    
    public fileprivate(set) var alertView: AlertView
    
    override public var animationView: UIView? {
        return alertView
    }
    
    public var titleLabel: UILabel? {
        return alertView.titleLabel
    }
    
    public var messageLabel: UILabel? {
        return alertView.messageLabel
    }
    
    public var cancelItem: AlertItem? {
        return alertView.cancelItem
    }
    
    public var confirmItem: AlertItem? {
        return alertView.confirmItem
    }
    
    /// title and message is only avilable in type is alert
    public init(title: String = "", message: String = "", contentView: UIView? = nil) {
        alertView = .default
        alertView.title = title
        alertView.message = message
        alertView.contentView = contentView
        super.init(style: .alert)
    }
    
    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

/// MARK: API
public extension AlertController {
    func addAlertAction(_ action: AlertAction) {
        alertView.addAlertAction(action)
    }
}