179 lines
8.5 KiB
Swift
179 lines
8.5 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()
|
|
|
|
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)
|
|
}
|
|
|
|
// public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
|
|
// super.init(frame: CGRect(x:0, y:0, width:400, height:80))
|
|
// setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
// }
|
|
//
|
|
|
|
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 as! Dictionary<String, Any>)
|
|
let textlabeljson = json!["label"] as! Dictionary<String,Any> //UILabel.init(frame: CGRect(x:0, y:0, width: 300, height: 300))
|
|
self.descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData)
|
|
let thickness = Float(json!["thickness"] as! String)
|
|
|
|
|
|
|
|
|
|
|
|
// let leadingconstraint = NSLayoutConstraint(item: progressUI,
|
|
// attribute: .leading,
|
|
// relatedBy: .equal,
|
|
// toItem: self,
|
|
// attribute: .leading,
|
|
// multiplier: 1,
|
|
// constant: 20)
|
|
//
|
|
//
|
|
//
|
|
// let topconstraint = NSLayoutConstraint(item: progressUI,
|
|
// attribute: .top,
|
|
// relatedBy: .equal,
|
|
// toItem: self,
|
|
// attribute: .top,
|
|
// multiplier: 1,
|
|
// constant: 0)
|
|
// let widthconstraint = NSLayoutConstraint(item: progressUI,
|
|
// attribute: .width,
|
|
// relatedBy: .equal,
|
|
// toItem: nil,
|
|
// attribute: .notAnAttribute,
|
|
// multiplier: 1,
|
|
// constant: 350)
|
|
NSLayoutConstraint(item: progress,
|
|
attribute: .height,
|
|
relatedBy: .equal,
|
|
toItem: nil,
|
|
attribute: .notAnAttribute,
|
|
multiplier: 1,
|
|
constant: (CGFloat(thickness!)))
|
|
|
|
// progressUI.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
|
|
|
|
// self.addConstraints([leadingconstraint, topconstraint, widthconstraint, heightconstraint])
|
|
// self.backgroundColor = .blue
|
|
|
|
}
|
|
|
|
override open func setupView() {
|
|
super.setupView()
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
self.addSubview(descriptionLabel)
|
|
addSubview(progress)
|
|
|
|
progress.translatesAutoresizingMaskIntoConstraints = false
|
|
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
// descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: 25).isActive = true
|
|
// descriptionLabel.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
|
|
// descriptionLabel.heightAnchor.constraint(equalTo: self.heightAnchor).isActive = true
|
|
|
|
let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth()
|
|
let horizontalSpacing = MFStyler.defaultHorizontalPaddingForApplicationWidth()
|
|
|
|
// let leadingconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
// attribute: .leading,
|
|
// relatedBy: .equal,
|
|
// toItem: self,
|
|
// attribute: .leading,
|
|
// multiplier: 1,
|
|
// constant: 20)
|
|
//
|
|
// let trailingconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
// attribute: .trailing,
|
|
// relatedBy: .equal,
|
|
// toItem: self,
|
|
// attribute: .trailing,
|
|
// multiplier: 1,
|
|
// constant: 20)
|
|
descriptionLabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
descriptionLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
|
|
descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: vericalSpacing).isActive = true
|
|
descriptionLabel.bottomAnchor.constraint(equalTo: progress.topAnchor, constant: vericalSpacing).isActive = true
|
|
|
|
|
|
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
|
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
|
progress.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: vericalSpacing).isActive = true
|
|
// progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).isActive = true
|
|
|
|
|
|
|
|
/* let topconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
attribute: .top,
|
|
relatedBy: .equal,
|
|
toItem: self,
|
|
attribute: .top,
|
|
multiplier: 1,
|
|
constant: 0) */
|
|
|
|
// let bottomconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
// attribute: .bottom,
|
|
// relatedBy: .equal,
|
|
// toItem: self,
|
|
// attribute: .bottom,
|
|
// multiplier: 1,
|
|
// constant: 1)
|
|
|
|
// NSLayoutConstraint.constraintPinSubview(descriptionLabel, pinCenterX: true, pinCenterY: false)
|
|
// NSLayoutConstraint.constraintPinSubview(descriptionLabel, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true)
|
|
// let widthconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
// attribute: .width,
|
|
// relatedBy: .equal,
|
|
// toItem: nil,
|
|
// attribute: .width,
|
|
// multiplier: 1,
|
|
// constant: 350)
|
|
//
|
|
// let heightconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
// attribute: .height,
|
|
// relatedBy: .equal,
|
|
// toItem: nil,
|
|
// attribute: .height,
|
|
// multiplier: 1,
|
|
// constant: 30)
|
|
|
|
// self.addConstraints([leadingconstraint,trailingconstraint])
|
|
|
|
}
|
|
|
|
|
|
}
|