//
//  FFAlertAction.swift
//  FFAlert
//
//  Created by FFIB on 2017/11/16.
//  Copyright © 2017年 FFIB. All rights reserved.
//

import UIKit

public class FFAlertAction {

    private(set) public var title: String? {
        get { return attributedTitle?.string }
        set { attributedTitle = NSAttributedString(string: newValue ?? "") }
    }

    internal(set) public var contentEdgInsets: UIEdgeInsets?
    private(set) var handler: ((FFAlertAction) -> Void)?
    private(set) public var attributedTitle: NSAttributedString?
    private(set) public var backgroundColor: UIColor

    init(attributedTitle: NSAttributedString?, contentEdgInsets: UIEdgeInsets? = nil,
         backgroundColor: UIColor? = nil, handler: ((FFAlertAction) -> Void)?) {
        self.contentEdgInsets = contentEdgInsets
        self.backgroundColor = backgroundColor ?? UIColor.white
        self.attributedTitle = attributedTitle
        self.handler = handler
    }

    init(title: String?, contentEdgInsets: UIEdgeInsets? = nil,
         backgroundColor: UIColor? = nil, handler: ((FFAlertAction) -> Void)?) {
        self.contentEdgInsets = contentEdgInsets
        self.backgroundColor = backgroundColor ?? UIColor.white
        self.title = title
        self.handler = handler
    }
}