//
//  Icon.swift
//  MVMCoreUI
//
//  Created by Matt Bruce on 12/14/23.
//  Copyright © 2023 Verizon Wireless. All rights reserved.
//

import Foundation
import VDS

/**
 This class expects its height and width to be equal.
 */
open class Icon: VDS.Icon, VDSMoleculeViewProtocol{
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    public var viewModel: IconModel!
    public var delegateObject: MVMCoreUIDelegateObject?
    public var additionalData: [AnyHashable: Any]?
        
    //--------------------------------------------------
    // MARK: - Initializers
    //--------------------------------------------------
    public convenience required init() {
        self.init(frame: .zero)
    }
    
    //--------------------------------------------------
    // MARK: - Public
    //--------------------------------------------------
    public func viewModelDidUpdate() {
        surface = viewModel.surface
        color = viewModel.color.uiColor
        size = viewModel.size
        customSize = viewModel.customSize
        name = viewModel.name
    }

    //--------------------------------------------------
    // MARK: - MVMCoreViewProtocol
    //--------------------------------------------------
    open func updateView(_ size: CGFloat) {}

    //--------------------------------------------------
    // MARK: - MoleculeViewProtocol
    //--------------------------------------------------
    //since this is a class func, we can't reference it directly
    public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
        VDS.Icon.Size.medium.dimensions.height
    }
}

extension Icon: MVMCoreUIViewConstrainingProtocol {

    public func needsToBeConstrained() -> Bool { true }
    
    public func horizontalAlignment() -> UIStackView.Alignment { .leading }
}
