68 lines
2.4 KiB
Swift
68 lines
2.4 KiB
Swift
//
|
|
// 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)
|
|
progress.styleprogessbar(json: json)
|
|
let thickness = json?.floatFromStringForKey("thickness")
|
|
let textlabeljson = json?.optionalDictionaryForKey("label")
|
|
|
|
descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData)
|
|
progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true
|
|
}
|
|
|
|
override open func setupView() {
|
|
super.setupView()
|
|
addSubview(descriptionLabel)
|
|
addSubview(progress)
|
|
|
|
let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth()
|
|
progress.translatesAutoresizingMaskIntoConstraints = false
|
|
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
descriptionLabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
descriptionLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
|
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).isActive = true
|
|
progress.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
|
|
}
|
|
|
|
|
|
}
|