// // ProgressBarView.swift // MVMCoreUI // // Created by Panth Patel on 5/3/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import UIKit @objcMembers open class ProgressBarView: ViewConstrainingView { var progress = ProgressBar() var descriptionLabel = Label() var thickness: Float? public init() { super.init(frame: .zero) } public override init(frame: CGRect) { super.init(frame: frame) } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } open override func updateView(_ size: CGFloat) { super.updateView(size) } open override func needsToBeConstrained() -> Bool { return true } open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let jsonUnwrapped = json as? Dictionary { progress.styleprogessbar(json: jsonUnwrapped) } let textlabeljson = json!["label"] as! Dictionary //UILabel.init(frame: CGRect(x:0, y:0, width: 300, height: 300)) self.descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData) thickness = Float(json!["thickness"] as! String) // thickness = 20.0 } override open func setupView() { super.setupView() translatesAutoresizingMaskIntoConstraints = false addSubview(descriptionLabel) addSubview(progress) progress.translatesAutoresizingMaskIntoConstraints = false descriptionLabel.translatesAutoresizingMaskIntoConstraints = false let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth() descriptionLabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true descriptionLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true descriptionLabel.numberOfLines = 0 descriptionLabel.sizeToFit() progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true progress.heightAnchor.constraint(equalToConstant: 20).isActive = true progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).isActive = true progress.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true } }