//
//  MVMCoreUITopAlertMainView+Extension.swift
//  MVMCoreUI
//
//  Created by Scott Pfeil on 9/15/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


extension MVMCoreUITopAlertMainView: MoleculeViewProtocol {
    
    public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
        defaultSetup()
        guard let model = model as? NotificationModel else { return }
        
        backgroundColor = model.backgroundColor?.uiColor ?? .mvmGreen
        var actionMap = model.button?.action.toJSON()
        
        if let title = model.button?.title {
            actionMap?.updateValue(title, forKey: KeyTitle)
        }
        
        if let accessibilityIdentifier = model.accessibilityIdentifier {
            self.accessibilityIdentifier = accessibilityIdentifier
        }
        
        setupCloseButton(model.closeButton != nil, animationDelegate: MVMCoreUITopAlertView.sharedGlobal()?.animationDelegate)
        setup(withMessage: model.headline.text, subMessage: model.body?.text, color: model.headline.textColor?.uiColor ?? .white, actionMap: actionMap, additionalData: nil)
    }
}
