//
//  BadgeIndicator.swift
//  MVMCoreUI
//
//  Created by Matt Bruce on 4/12/24.
//  Copyright © 2024 Verizon Wireless. All rights reserved.
//

import Foundation
import VDS

open class BadgeIndicator: VDS.BadgeIndicator, VDSMoleculeViewProtocol {

    //--------------------------------------------------
    // MARK: - Public Properties
    //--------------------------------------------------
    public var viewModel: BadgeIndicatorModel!
    
    public var delegateObject: MVMCoreUIDelegateObject?
    
    public var additionalData: [AnyHashable : Any]?
    
    //--------------------------------------------------
    // MARK: - Public Methods
    //--------------------------------------------------
    
    public func viewModelDidUpdate() {
        surface = viewModel.surface
        number = viewModel.number
        fillColor = viewModel.fillColor
        borderColorLight = viewModel.borderColorLight?.uiColor
        borderColorDark = viewModel.borderColorDark?.uiColor
        kind = viewModel.kind
        maximumDigits = viewModel.maximumDigits
        size = viewModel.size
        leadingCharacter = viewModel.leadingCharacter
        trailingText = viewModel.trailingText
        dotSize = viewModel.dotSize
        verticalPadding = viewModel.verticalPadding
        horizontalPadding = viewModel.horizontalPadding
        hideDot = viewModel.hideDot
        hideBorder = viewModel.hideBorder
        width = viewModel.width
        height = viewModel.height
    }
    
    public func updateView(_ size: CGFloat) {}
    
    //--------------------------------------------------
    // MARK: - Overrides
    //--------------------------------------------------
    open override func updateAccessibility() {
        super.updateAccessibility()
        
        if let viewModel {
            if let accessibilityText = viewModel.accessibilityText {
                self.accessibilityLabel = accessibilityText
            }
        }
    }
    
}

//to deal with how it's parent constrains this control
extension BadgeIndicator: MVMCoreUIViewConstrainingProtocol {

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