This commit is contained in:
Panth Patel 2019-05-15 12:27:48 -04:00
commit ff823d6862

View File

@ -9,7 +9,7 @@
import UIKit
@objcMembers open class ProgressBarView: ViewConstrainingView {
var progress = ProgressBar()
var topleftlabel = Label()
var toprightlabel = Label()
@ -40,6 +40,7 @@ import UIKit
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 topleftlabeljson = json?.optionalDictionaryForKey("label")
let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel")
@ -62,43 +63,48 @@ import UIKit
addSubview(progress)
progress.translatesAutoresizingMaskIntoConstraints = false
topleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
topleftlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
let topleftconstarint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
topleftconstarint.priority = UILayoutPriority(rawValue: 100)
topleftconstarint.isActive = true
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal)
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical)
NSLayoutConstraint(item: toprightlabel, attribute: .leading, relatedBy: .equal, toItem: topleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true
toprightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
toprightlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
toprightlabel.textAlignment = .right
let toprightconstraint = NSLayoutConstraint(item: toprightlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
toprightconstraint.priority = UILayoutPriority(rawValue: 100)
toprightconstraint.isActive = true
toprightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal)
toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical)
let progressconstraintone = NSLayoutConstraint(item: progress, attribute: .top, relatedBy: .equal, toItem: topleftlabel, attribute: .bottom, multiplier: 1.0, constant: PaddingTwo)
progressconstraintone.priority = UILayoutPriority(rawValue: 700)
progressconstraintone.isActive = true
let progressconstrainttwo = NSLayoutConstraint(item: progress, attribute: .top, relatedBy: .greaterThanOrEqual, toItem: toprightlabel, attribute: .bottom, multiplier: 1.0, constant: PaddingTwo)
progressconstrainttwo.priority = UILayoutPriority(rawValue: 1000)
progressconstrainttwo.isActive = true
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
bottomleftlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
bottomleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
let bottomleftconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
bottomleftconstraint.priority = UILayoutPriority(100)
bottomleftconstraint.isActive = true
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(900), for: .horizontal)
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(850), for: .vertical)
NSLayoutConstraint(item: bottomrightlabel, attribute: .leading, relatedBy: .equal, toItem: bottomleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true
bottomrightlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
bottomrightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
let bottomrightconstraint = NSLayoutConstraint(item: bottomrightlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
bottomrightconstraint.priority = UILayoutPriority(100)
bottomrightconstraint.isActive = true
@ -107,9 +113,3 @@ import UIKit
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical)
}
}