//
//  LabelBarButtonItem.swift
//  MVMCoreUI
//
//  Created by Scott Pfeil on 5/27/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


@objcMembers open class LabelBarButtonItem: BarButtonItem {
    //--------------------------------------------------
    // MARK: - Initializers
    //--------------------------------------------------
    
    public static func create(with title: String?) -> Self {
        let actionObject = ActionDelegate()
        let button = self.init(title: title, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:)))
        button.actionDelegate = actionObject
        button.setTitleTextAttributes([NSAttributedString.Key.font: Styler.Font.RegularBodySmall.getFont()], for: .normal)
        return button
    }
    
    /// Creates the item with the passed in action.
    public static func create(with title: String?, model: NavigationLabelButtonModel, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self {
        let button = create(with: title)
        button.set(with: model, delegateObject: delegateObject, additionalData: additionalData)
        return button
    }
    
    /// Creates the item with the passed in action.
    public static func create(with title: String?, action: @escaping BarButtonAction) -> Self {
        let button = create(with: title)
        button.actionDelegate?.buttonAction = action
        return button
    }
}
