From dc4a7d9cc1d198cae4377ed52bdec92e4ac27af6 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Sun, 5 May 2019 22:45:50 -0400 Subject: [PATCH 01/13] lc --- MVMCoreUI/Atoms/Views/ProgressBar.json | 0 MVMCoreUI/Molecules/ProgressBarView.swift | 9 +++ MVMCoreUI/Molecules/ProgressUI.swift | 68 +++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 MVMCoreUI/Atoms/Views/ProgressBar.json create mode 100644 MVMCoreUI/Molecules/ProgressBarView.swift create mode 100644 MVMCoreUI/Molecules/ProgressUI.swift diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.json b/MVMCoreUI/Atoms/Views/ProgressBar.json new file mode 100644 index 00000000..e69de29b diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift new file mode 100644 index 00000000..9733a36b --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -0,0 +1,9 @@ +// +// ProgressBarView.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation diff --git a/MVMCoreUI/Molecules/ProgressUI.swift b/MVMCoreUI/Molecules/ProgressUI.swift new file mode 100644 index 00000000..4457e5de --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressUI.swift @@ -0,0 +1,68 @@ +// +// ProgressBar.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ProgressBar: UIProgressView { + + public func styleprogessbar(json: Dictionary) -> UIProgressView { + let percentage = Float(json["percent"] as! String) + let barstyle = json["barstyle"] as! Bool + let progresscolor = json["progresscolor"] as! String + let backgroundcolor = json["backgroundcolor"] as! String + + + self.progressTintColor = UIColor.init(hex: progresscolor) + self.trackTintColor = UIColor.init(hex: backgroundcolor) + self.progress = percentage!/100 + self.frame.size.width = 200 + switch barstyle { + case true: + self.progressViewStyle = .bar + default: + self.progressViewStyle = .default + } + + return self + } + +} + +extension UIColor { + public convenience init?(hex: String) { + let r, g, b, a: CGFloat + + if hex.hasPrefix("#") { + let start = hex.index(hex.startIndex, offsetBy: 1) + let hexColor = String(hex[start...]) + + if hexColor.count == 8 { + let scanner = Scanner(string: hexColor) + var hexNumber: UInt64 = 0 + + if scanner.scanHexInt64(&hexNumber) { + r = CGFloat((hexNumber & 0xff000000) >> 24) / 255 + g = CGFloat((hexNumber & 0x00ff0000) >> 16) / 255 + b = CGFloat((hexNumber & 0x0000ff00) >> 8) / 255 + a = CGFloat(hexNumber & 0x000000ff) / 255 + + self.init(red: r, green: g, blue: b, alpha: a) + return + } + } + } + + return nil + } +} + + + + + + From 8c0e38766394e53813a343111efe0226426ab6d3 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Wed, 8 May 2019 17:13:16 -0400 Subject: [PATCH 02/13] progresschanges123 --- MVMCoreUI/Molecules/ProgressBar.swift | 9 +++++++++ MVMCoreUI/Molecules/ProgressBarView.swift | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 MVMCoreUI/Molecules/ProgressBar.swift diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift new file mode 100644 index 00000000..6cf7c087 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -0,0 +1,9 @@ +// +// ProgressBar.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/6/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 9733a36b..2553c6eb 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -2,8 +2,20 @@ // ProgressBarView.swift // MVMCoreUI // -// Created by Panth Patel on 5/3/19. +// Created by Panth Patel on 5/7/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // -import Foundation +import UIKit + +class ProgressBarView: ViewConstrainingView { + + /* + // Only override draw() if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func draw(_ rect: CGRect) { + // Drawing code + } + */ + +} From faf0ce2607be77428c4413c02d787c7fc62953cf Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Wed, 8 May 2019 17:20:15 -0400 Subject: [PATCH 03/13] progress --- MVMCoreUI.xcodeproj/project.pbxproj | 10 +- MVMCoreUI/Molecules/ProgressBar.swift | 56 +++++- MVMCoreUI/Molecules/ProgressBarView.swift | 173 +++++++++++++++++- .../MVMCoreUIMoleculeMappingObject.m | 3 +- 4 files changed, 231 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 83b51092..4ea5c03a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; + B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E142280C4CF007245F4 /* ProgressBar.swift */; }; + B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E182281DC1A007245F4 /* ProgressBarView.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; @@ -175,6 +177,8 @@ 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; + B8200E142280C4CF007245F4 /* ProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; + B8200E182281DC1A007245F4 /* ProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarView.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; @@ -319,10 +323,10 @@ D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; - DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; + DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = ""; }; @@ -448,6 +452,8 @@ D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D274CA322236A78900B01B62 /* StandardFooterView.swift */, D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */, + B8200E142280C4CF007245F4 /* ProgressBar.swift */, + B8200E182281DC1A007245F4 /* ProgressBarView.swift */, ); path = Molecules; sourceTree = ""; @@ -894,6 +900,7 @@ D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, + B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, @@ -944,6 +951,7 @@ D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, + B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index 6cf7c087..301c645a 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -2,8 +2,62 @@ // ProgressBar.swift // MVMCoreUI // -// Created by Panth Patel on 5/6/19. +// Created by Panth Patel on 5/3/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import Foundation + +public class ProgressBar: UIProgressView { + + public func styleprogessbar(json: Dictionary) -> UIProgressView { + let percentage = Float(json["percent"] as! String) + let barstyle = json["barStyle"] as! Bool + let progresscolor = json["progressColor"] as! String + let backgroundcolor = json["backgroundColor"] as! String + let thickness = Float(json["thickness"] as! String) + + self.progressTintColor = UIColor.init(hex: progresscolor) + self.trackTintColor = UIColor.init(hex: backgroundcolor) + self.progress = percentage!/100 + self.frame.size.width = 200 + switch barstyle { + case true: + self.progressViewStyle = .bar + default: + self.layer.cornerRadius = CGFloat(thickness!/2) + self.clipsToBounds = true + } + + return self + } + +} + +extension UIColor { + public convenience init?(hex: String) { + let r, g, b, a: CGFloat + + if hex.hasPrefix("#") { + let start = hex.index(hex.startIndex, offsetBy: 1) + let hexColor = String(hex[start...]) + + if hexColor.count == 6 { + let scanner = Scanner(string: hexColor) + var hexNumber: UInt32 = 0 + + if scanner.scanHexInt32(&hexNumber) { + r = CGFloat((hexNumber & 0xff0000) >> 16) / 255 + g = CGFloat((hexNumber & 0x00ff00) >> 8) / 255 + b = CGFloat(hexNumber & 0x0000ff) / 255 + + self.init(red: r, green: g, blue: b, alpha: 1.0) + return + } + } + + } + + return nil + } +} diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 2553c6eb..a7350837 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -2,20 +2,177 @@ // ProgressBarView.swift // MVMCoreUI // -// Created by Panth Patel on 5/7/19. +// Created by Panth Patel on 5/3/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import UIKit -class ProgressBarView: ViewConstrainingView { +@objcMembers open class ProgressBarView: ViewConstrainingView { - /* - // Only override draw() if you perform custom drawing. - // An empty implementation adversely affects performance during animation. - override func draw(_ rect: CGRect) { - // Drawing code + 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) + 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) + 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]) + + } + } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index e1101191..5e5264c9 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -33,7 +33,8 @@ @"caretView": CaretView.class, @"caretButton": CaretButton.class, @"textField" : MFTextField.class, - @"checkbox" : MVMCoreUICheckBox.class + @"checkbox" : MVMCoreUICheckBox.class, + @"progressbar" : ProgressBarView.class } mutableCopy]; }); return mapping; From 350385a4995691f9c2fbb789f09ff3ef6cf79c47 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Thu, 9 May 2019 10:45:22 -0400 Subject: [PATCH 04/13] progress_bar changes --- MVMCoreUI/Molecules/ProgressBar.swift | 3 +- MVMCoreUI/Molecules/ProgressBarView.swift | 128 +++------------------- 2 files changed, 15 insertions(+), 116 deletions(-) diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index 301c645a..1ae7336a 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -10,7 +10,7 @@ import Foundation public class ProgressBar: UIProgressView { - public func styleprogessbar(json: Dictionary) -> UIProgressView { + public func styleprogessbar(json: Dictionary) { let percentage = Float(json["percent"] as! String) let barstyle = json["barStyle"] as! Bool let progresscolor = json["progressColor"] as! String @@ -29,7 +29,6 @@ public class ProgressBar: UIProgressView { self.clipsToBounds = true } - return self } } diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index a7350837..61cdde7b 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -12,6 +12,7 @@ import UIKit var progress = ProgressBar() var descriptionLabel = Label() + var thickness: Float? public init() { super.init(frame: .zero) @@ -29,12 +30,6 @@ import UIKit 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 } @@ -43,135 +38,40 @@ import UIKit super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - progress.styleprogessbar(json: json as! Dictionary) + 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) - 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 - + thickness = Float(json!["thickness"] as! String) + // thickness = 20.0 } override open func setupView() { super.setupView() translatesAutoresizingMaskIntoConstraints = false - self.addSubview(descriptionLabel) + 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 - + 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.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: vericalSpacing).isActive = true -// progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).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 - - /* 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]) - } From 2bd55296b8719159ed079c15651de2c59a687d6f Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Thu, 9 May 2019 17:31:18 -0400 Subject: [PATCH 05/13] ProgressBar molecule with a Label --- MVMCoreUI/Molecules/ProgressBar.swift | 65 +++++++++-------------- MVMCoreUI/Molecules/ProgressBarView.swift | 29 ++++------ 2 files changed, 33 insertions(+), 61 deletions(-) diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index 1ae7336a..15e0fedc 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -10,53 +10,36 @@ import Foundation public class ProgressBar: UIProgressView { - public func styleprogessbar(json: Dictionary) { - let percentage = Float(json["percent"] as! String) - let barstyle = json["barStyle"] as! Bool - let progresscolor = json["progressColor"] as! String - let backgroundcolor = json["backgroundColor"] as! String - let thickness = Float(json["thickness"] as! String) + public func styleprogessbar(json: [AnyHashable: Any]?) { + + var barstyle = Bool() + var progresscolor = String() + var backgroundcolor = String() + + let thickness = json?.floatFromStringForKey("thickness") + let percentage = json?.floatFromStringForKey("percent") + + if let backgroundcolorUnwrapped = json?.optionalStringForKey("backgroundColor") { + backgroundcolor = backgroundcolorUnwrapped + } + if let progresscolorUnwrapped = json?.optionalStringForKey("progressColor") { + progresscolor = progresscolorUnwrapped + } + if let barStyleUnwrapped = json?["barStyle"] as? Bool { + barstyle = barStyleUnwrapped + } + progressTintColor = UIColor.mfGet(forHex: progresscolor) + trackTintColor = UIColor.mfGet(forHex: backgroundcolor) + progress = (percentage ?? Float(PaddingThree))/100 - self.progressTintColor = UIColor.init(hex: progresscolor) - self.trackTintColor = UIColor.init(hex: backgroundcolor) - self.progress = percentage!/100 - self.frame.size.width = 200 switch barstyle { case true: - self.progressViewStyle = .bar + progressViewStyle = .bar default: - self.layer.cornerRadius = CGFloat(thickness!/2) - self.clipsToBounds = true + layer.cornerRadius = CGFloat((thickness ?? Float(PaddingTwo))/2) + clipsToBounds = true } } } - -extension UIColor { - public convenience init?(hex: String) { - let r, g, b, a: CGFloat - - if hex.hasPrefix("#") { - let start = hex.index(hex.startIndex, offsetBy: 1) - let hexColor = String(hex[start...]) - - if hexColor.count == 6 { - let scanner = Scanner(string: hexColor) - var hexNumber: UInt32 = 0 - - if scanner.scanHexInt32(&hexNumber) { - r = CGFloat((hexNumber & 0xff0000) >> 16) / 255 - g = CGFloat((hexNumber & 0x00ff00) >> 8) / 255 - b = CGFloat(hexNumber & 0x0000ff) / 255 - - self.init(red: r, green: g, blue: b, alpha: 1.0) - return - } - } - - } - - return nil - } -} diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 61cdde7b..4abb7e52 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -9,7 +9,7 @@ import UIKit @objcMembers open class ProgressBarView: ViewConstrainingView { - + var progress = ProgressBar() var descriptionLabel = Label() var thickness: Float? @@ -37,42 +37,31 @@ 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 textlabeljson = json?.optionalDictionaryForKey("label") - 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 + descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData) + progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true } override open func setupView() { super.setupView() - translatesAutoresizingMaskIntoConstraints = false addSubview(descriptionLabel) addSubview(progress) + let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth() 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 - - } - - + + } From 78f035ce08a4769d7946ff226676f8e39e37df15 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Wed, 15 May 2019 12:19:54 -0400 Subject: [PATCH 06/13] Molecule ProgressBar --- MVMCoreUI/Molecules/ProgressBar.swift | 67 ++++++---------- MVMCoreUI/Molecules/ProgressBarView.swift | 93 ++++++++++++++++------- 2 files changed, 89 insertions(+), 71 deletions(-) diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index 1ae7336a..eadf20eb 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -10,53 +10,34 @@ import Foundation public class ProgressBar: UIProgressView { - public func styleprogessbar(json: Dictionary) { - let percentage = Float(json["percent"] as! String) - let barstyle = json["barStyle"] as! Bool - let progresscolor = json["progressColor"] as! String - let backgroundcolor = json["backgroundColor"] as! String - let thickness = Float(json["thickness"] as! String) + public func styleprogessbar(json: [AnyHashable: Any]?) { + + var barstyle = Bool() + var progresscolor = String() + var backgroundcolor = String() + + let thickness = json?.floatFromStringForKey("thickness") + let percentage = json?.floatFromStringForKey("percent") + + if let backgroundcolorUnwrapped = json?.optionalStringForKey("backgroundColor") { + backgroundcolor = backgroundcolorUnwrapped + } + if let progresscolorUnwrapped = json?.optionalStringForKey("progressColor") { + progresscolor = progresscolorUnwrapped + } + if let barStyleUnwrapped = json?["barStyle"] as? Bool { + barstyle = barStyleUnwrapped + } + progressTintColor = UIColor.mfGet(forHex: progresscolor) + trackTintColor = UIColor.mfGet(forHex: backgroundcolor) + progress = (percentage ?? Float(PaddingThree))/100 - self.progressTintColor = UIColor.init(hex: progresscolor) - self.trackTintColor = UIColor.init(hex: backgroundcolor) - self.progress = percentage!/100 - self.frame.size.width = 200 switch barstyle { case true: - self.progressViewStyle = .bar + progressViewStyle = .bar default: - self.layer.cornerRadius = CGFloat(thickness!/2) - self.clipsToBounds = true + layer.cornerRadius = CGFloat((thickness ?? Float(PaddingTwo))/2) + clipsToBounds = true } - - } - -} - -extension UIColor { - public convenience init?(hex: String) { - let r, g, b, a: CGFloat - - if hex.hasPrefix("#") { - let start = hex.index(hex.startIndex, offsetBy: 1) - let hexColor = String(hex[start...]) - - if hexColor.count == 6 { - let scanner = Scanner(string: hexColor) - var hexNumber: UInt32 = 0 - - if scanner.scanHexInt32(&hexNumber) { - r = CGFloat((hexNumber & 0xff0000) >> 16) / 255 - g = CGFloat((hexNumber & 0x00ff00) >> 8) / 255 - b = CGFloat(hexNumber & 0x0000ff) / 255 - - self.init(red: r, green: g, blue: b, alpha: 1.0) - return - } - } - - } - - return nil } } diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 61cdde7b..25fd0c23 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -11,7 +11,10 @@ import UIKit @objcMembers open class ProgressBarView: ViewConstrainingView { var progress = ProgressBar() - var descriptionLabel = Label() + var topleftlabel = Label() + var toprightlabel = Label() + var bottomleftlabel = Label() + var bottomrightlabel = Label() var thickness: Float? public init() { @@ -35,44 +38,78 @@ 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") + let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") + let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") - 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 + topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true } override open func setupView() { super.setupView() - translatesAutoresizingMaskIntoConstraints = false - addSubview(descriptionLabel) + addSubview(topleftlabel) + addSubview(toprightlabel) + addSubview(bottomleftlabel) + addSubview(bottomrightlabel) 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() - + + 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 - 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 - + 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 + bottomrightlabel.textAlignment = .right + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) } - - } + + + + + + From 6cab25d384ca41eea04f305db25ef6907be804d6 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Thu, 16 May 2019 15:39:29 -0400 Subject: [PATCH 07/13] ProgressBar --- MVMCoreUI/Molecules/ProgressBar.swift | 58 ++++--- MVMCoreUI/Molecules/ProgressBar.swift.orig | 53 +++++++ MVMCoreUI/Molecules/ProgressBarView.swift | 68 ++++----- .../ProgressBarView_BACKUP_31500.swift | 142 ++++++++++++++++++ .../ProgressBarView_BASE_31500.swift | 78 ++++++++++ .../ProgressBarView_LOCAL_31500.swift | 115 ++++++++++++++ .../ProgressBarView_REMOTE_31500.swift | 67 +++++++++ 7 files changed, 516 insertions(+), 65 deletions(-) create mode 100644 MVMCoreUI/Molecules/ProgressBar.swift.orig create mode 100644 MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift create mode 100644 MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift create mode 100644 MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift create mode 100644 MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index eadf20eb..f868bbf5 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -10,34 +10,46 @@ import Foundation public class ProgressBar: UIProgressView { - public func styleprogessbar(json: [AnyHashable: Any]?) { - - var barstyle = Bool() - var progresscolor = String() - var backgroundcolor = String() - - let thickness = json?.floatFromStringForKey("thickness") + var isRounded = Bool() + var thickness : Float { + get { + return 10 + } + set { + heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true + switch isRounded { + case true: + progressViewStyle = .bar + default: + layer.cornerRadius = CGFloat((newValue ?? Float(0.0))/2) + clipsToBounds = true + } + } + } + + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0) let percentage = json?.floatFromStringForKey("percent") + progress = (percentage ?? Float(0.0))/100 + progressTintColor = UIColor.mfBattleshipGrey() + trackTintColor = UIColor.mfLighterGray() - if let backgroundcolorUnwrapped = json?.optionalStringForKey("backgroundColor") { - backgroundcolor = backgroundcolorUnwrapped + if let progresscolor = json?.optionalStringForKey("progressColor") { + if !progresscolor.isEmpty { + progressTintColor = UIColor.mfGet(forHex: progresscolor) + } } - if let progresscolorUnwrapped = json?.optionalStringForKey("progressColor") { - progresscolor = progresscolorUnwrapped + + if let backgroundcolor = json?.optionalStringForKey("backgroundColor") { + if !backgroundcolor.isEmpty { + trackTintColor = UIColor.mfGet(forHex: backgroundcolor) + } } + if let barStyleUnwrapped = json?["barStyle"] as? Bool { - barstyle = barStyleUnwrapped - } - progressTintColor = UIColor.mfGet(forHex: progresscolor) - trackTintColor = UIColor.mfGet(forHex: backgroundcolor) - progress = (percentage ?? Float(PaddingThree))/100 - - switch barstyle { - case true: - progressViewStyle = .bar - default: - layer.cornerRadius = CGFloat((thickness ?? Float(PaddingTwo))/2) - clipsToBounds = true + isRounded = barStyleUnwrapped } } } + + diff --git a/MVMCoreUI/Molecules/ProgressBar.swift.orig b/MVMCoreUI/Molecules/ProgressBar.swift.orig new file mode 100644 index 00000000..dbf0fac5 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBar.swift.orig @@ -0,0 +1,53 @@ +// +// ProgressBar.swift +// MVMCoreUI +// +// Created by Panth Patel on 5/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ProgressBar: UIProgressView { + + public func styleprogessbar(json: [AnyHashable: Any]?) { +<<<<<<< HEAD + +======= + +>>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f + var barstyle = Bool() + var progresscolor = String() + var backgroundcolor = String() + + let thickness = json?.floatFromStringForKey("thickness") + let percentage = json?.floatFromStringForKey("percent") + + if let backgroundcolorUnwrapped = json?.optionalStringForKey("backgroundColor") { + backgroundcolor = backgroundcolorUnwrapped + } + if let progresscolorUnwrapped = json?.optionalStringForKey("progressColor") { + progresscolor = progresscolorUnwrapped + } + if let barStyleUnwrapped = json?["barStyle"] as? Bool { + barstyle = barStyleUnwrapped + } + progressTintColor = UIColor.mfGet(forHex: progresscolor) + trackTintColor = UIColor.mfGet(forHex: backgroundcolor) + progress = (percentage ?? Float(PaddingThree))/100 + + switch barstyle { + case true: + progressViewStyle = .bar + default: + layer.cornerRadius = CGFloat((thickness ?? Float(PaddingTwo))/2) + clipsToBounds = true + } +<<<<<<< HEAD + } +======= + + } + +>>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f +} diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 3f6c97a6..1778c555 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -8,30 +8,13 @@ import UIKit -@objcMembers open class ProgressBarView: ViewConstrainingView { +@objcMembers public class ProgressBarView: ViewConstrainingView { var progress = ProgressBar() var topleftlabel = Label() var toprightlabel = Label() var bottomleftlabel = Label() var bottomrightlabel = 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 @@ -39,9 +22,8 @@ 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") + progress.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + let topleftlabeljson = json?.optionalDictionaryForKey("label") let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") @@ -51,7 +33,6 @@ import UIKit toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) - progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true } override open func setupView() { @@ -66,50 +47,53 @@ import UIKit 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 - + let topleftconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) + topleftconstraint.priority = UILayoutPriority(rawValue: 100) + topleftconstraint.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 + var topconstraint = progress.topAnchor.constraint(equalTo: topleftlabel.bottomAnchor, constant: PaddingTwo) + topconstraint.priority = UILayoutPriority(249) + topconstraint.isActive = true + progress.topAnchor.constraint(greaterThanOrEqualTo: topleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true + topconstraint = progress.topAnchor.constraint(equalTo: toprightlabel.bottomAnchor, constant: PaddingTwo) + topconstraint.priority = UILayoutPriority(249) + topconstraint.isActive = true + progress.topAnchor.constraint(greaterThanOrEqualTo: toprightlabel.bottomAnchor, constant: PaddingTwo).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 bottomrightlabel.textAlignment = .right bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) + + var bottomconstraint = bottomAnchor.constraint(equalTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo) + bottomconstraint.priority = UILayoutPriority(249) + bottomconstraint.isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true + bottomconstraint = bottomAnchor.constraint(equalTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo) + bottomconstraint.priority = UILayoutPriority(249) + bottomconstraint.isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo).isActive = true } } diff --git a/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift new file mode 100644 index 00000000..a22733b3 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift @@ -0,0 +1,142 @@ +// +// 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 topleftlabel = Label() + var toprightlabel = Label() + var bottomleftlabel = Label() + var bottomrightlabel = 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") +<<<<<<< HEAD + let topleftlabeljson = json?.optionalDictionaryForKey("label") + let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") + let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") + let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") + + topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) +======= + let textlabeljson = json?.optionalDictionaryForKey("label") + + descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData) +>>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f + progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true + } + + override open func setupView() { + super.setupView() +<<<<<<< HEAD + addSubview(topleftlabel) + addSubview(toprightlabel) + addSubview(bottomleftlabel) + addSubview(bottomrightlabel) +======= + addSubview(descriptionLabel) +>>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f + addSubview(progress) + + let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth() + progress.translatesAutoresizingMaskIntoConstraints = false +<<<<<<< HEAD + + 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 + bottomrightlabel.textAlignment = .right + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) + } +} + + + + + + +======= + 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 + } + + +} +>>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f diff --git a/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift new file mode 100644 index 00000000..61cdde7b --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift @@ -0,0 +1,78 @@ +// +// 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 + + + } + + +} diff --git a/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift new file mode 100644 index 00000000..25fd0c23 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift @@ -0,0 +1,115 @@ +// +// 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 topleftlabel = Label() + var toprightlabel = Label() + var bottomleftlabel = Label() + var bottomrightlabel = 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 topleftlabeljson = json?.optionalDictionaryForKey("label") + let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") + let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") + let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") + + topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) + bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) + progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true + } + + override open func setupView() { + super.setupView() + addSubview(topleftlabel) + addSubview(toprightlabel) + addSubview(bottomleftlabel) + addSubview(bottomrightlabel) + 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 + bottomrightlabel.textAlignment = .right + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) + } +} + + + + + + diff --git a/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift new file mode 100644 index 00000000..4abb7e52 --- /dev/null +++ b/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift @@ -0,0 +1,67 @@ +// +// 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 + } + + +} From d535e9190bd9c2f50566aa52860e846986d66706 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Thu, 16 May 2019 15:47:58 -0400 Subject: [PATCH 08/13] ProgressBar Changes --- MVMCoreUI/Molecules/ProgressBar.swift.orig | 53 ------- .../ProgressBarView_BACKUP_31500.swift | 142 ------------------ .../ProgressBarView_BASE_31500.swift | 78 ---------- .../ProgressBarView_LOCAL_31500.swift | 115 -------------- .../ProgressBarView_REMOTE_31500.swift | 67 --------- MVMCoreUI/Molecules/ProgressUI.swift | 68 --------- 6 files changed, 523 deletions(-) delete mode 100644 MVMCoreUI/Molecules/ProgressBar.swift.orig delete mode 100644 MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift delete mode 100644 MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift delete mode 100644 MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift delete mode 100644 MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift delete mode 100644 MVMCoreUI/Molecules/ProgressUI.swift diff --git a/MVMCoreUI/Molecules/ProgressBar.swift.orig b/MVMCoreUI/Molecules/ProgressBar.swift.orig deleted file mode 100644 index dbf0fac5..00000000 --- a/MVMCoreUI/Molecules/ProgressBar.swift.orig +++ /dev/null @@ -1,53 +0,0 @@ -// -// ProgressBar.swift -// MVMCoreUI -// -// Created by Panth Patel on 5/3/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ProgressBar: UIProgressView { - - public func styleprogessbar(json: [AnyHashable: Any]?) { -<<<<<<< HEAD - -======= - ->>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f - var barstyle = Bool() - var progresscolor = String() - var backgroundcolor = String() - - let thickness = json?.floatFromStringForKey("thickness") - let percentage = json?.floatFromStringForKey("percent") - - if let backgroundcolorUnwrapped = json?.optionalStringForKey("backgroundColor") { - backgroundcolor = backgroundcolorUnwrapped - } - if let progresscolorUnwrapped = json?.optionalStringForKey("progressColor") { - progresscolor = progresscolorUnwrapped - } - if let barStyleUnwrapped = json?["barStyle"] as? Bool { - barstyle = barStyleUnwrapped - } - progressTintColor = UIColor.mfGet(forHex: progresscolor) - trackTintColor = UIColor.mfGet(forHex: backgroundcolor) - progress = (percentage ?? Float(PaddingThree))/100 - - switch barstyle { - case true: - progressViewStyle = .bar - default: - layer.cornerRadius = CGFloat((thickness ?? Float(PaddingTwo))/2) - clipsToBounds = true - } -<<<<<<< HEAD - } -======= - - } - ->>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f -} diff --git a/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift deleted file mode 100644 index a22733b3..00000000 --- a/MVMCoreUI/Molecules/ProgressBarView_BACKUP_31500.swift +++ /dev/null @@ -1,142 +0,0 @@ -// -// 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 topleftlabel = Label() - var toprightlabel = Label() - var bottomleftlabel = Label() - var bottomrightlabel = 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") -<<<<<<< HEAD - let topleftlabeljson = json?.optionalDictionaryForKey("label") - let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") - let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") - let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") - - topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) - toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) - bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) - bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) -======= - let textlabeljson = json?.optionalDictionaryForKey("label") - - descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData) ->>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f - progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true - } - - override open func setupView() { - super.setupView() -<<<<<<< HEAD - addSubview(topleftlabel) - addSubview(toprightlabel) - addSubview(bottomleftlabel) - addSubview(bottomrightlabel) -======= - addSubview(descriptionLabel) ->>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f - addSubview(progress) - - let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth() - progress.translatesAutoresizingMaskIntoConstraints = false -<<<<<<< HEAD - - 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 - bottomrightlabel.textAlignment = .right - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) - } -} - - - - - - -======= - 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 - } - - -} ->>>>>>> 2bd55296b8719159ed079c15651de2c59a687d6f diff --git a/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift deleted file mode 100644 index 61cdde7b..00000000 --- a/MVMCoreUI/Molecules/ProgressBarView_BASE_31500.swift +++ /dev/null @@ -1,78 +0,0 @@ -// -// 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 - - - } - - -} diff --git a/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift deleted file mode 100644 index 25fd0c23..00000000 --- a/MVMCoreUI/Molecules/ProgressBarView_LOCAL_31500.swift +++ /dev/null @@ -1,115 +0,0 @@ -// -// 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 topleftlabel = Label() - var toprightlabel = Label() - var bottomleftlabel = Label() - var bottomrightlabel = 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 topleftlabeljson = json?.optionalDictionaryForKey("label") - let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel") - let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel") - let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel") - - topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) - toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData) - bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData) - bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData) - progress.heightAnchor.constraint(equalToConstant: CGFloat(thickness ?? Float(PaddingTwo))).isActive = true - } - - override open func setupView() { - super.setupView() - addSubview(topleftlabel) - addSubview(toprightlabel) - addSubview(bottomleftlabel) - addSubview(bottomrightlabel) - 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 - bottomrightlabel.textAlignment = .right - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) - } -} - - - - - - diff --git a/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift b/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift deleted file mode 100644 index 4abb7e52..00000000 --- a/MVMCoreUI/Molecules/ProgressBarView_REMOTE_31500.swift +++ /dev/null @@ -1,67 +0,0 @@ -// -// 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 - } - - -} diff --git a/MVMCoreUI/Molecules/ProgressUI.swift b/MVMCoreUI/Molecules/ProgressUI.swift deleted file mode 100644 index 4457e5de..00000000 --- a/MVMCoreUI/Molecules/ProgressUI.swift +++ /dev/null @@ -1,68 +0,0 @@ -// -// ProgressBar.swift -// MVMCoreUI -// -// Created by Panth Patel on 5/3/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ProgressBar: UIProgressView { - - public func styleprogessbar(json: Dictionary) -> UIProgressView { - let percentage = Float(json["percent"] as! String) - let barstyle = json["barstyle"] as! Bool - let progresscolor = json["progresscolor"] as! String - let backgroundcolor = json["backgroundcolor"] as! String - - - self.progressTintColor = UIColor.init(hex: progresscolor) - self.trackTintColor = UIColor.init(hex: backgroundcolor) - self.progress = percentage!/100 - self.frame.size.width = 200 - switch barstyle { - case true: - self.progressViewStyle = .bar - default: - self.progressViewStyle = .default - } - - return self - } - -} - -extension UIColor { - public convenience init?(hex: String) { - let r, g, b, a: CGFloat - - if hex.hasPrefix("#") { - let start = hex.index(hex.startIndex, offsetBy: 1) - let hexColor = String(hex[start...]) - - if hexColor.count == 8 { - let scanner = Scanner(string: hexColor) - var hexNumber: UInt64 = 0 - - if scanner.scanHexInt64(&hexNumber) { - r = CGFloat((hexNumber & 0xff000000) >> 24) / 255 - g = CGFloat((hexNumber & 0x00ff0000) >> 16) / 255 - b = CGFloat((hexNumber & 0x0000ff00) >> 8) / 255 - a = CGFloat(hexNumber & 0x000000ff) / 255 - - self.init(red: r, green: g, blue: b, alpha: a) - return - } - } - } - - return nil - } -} - - - - - - From 145cafbc3026336d7637c66f08e39677e6c8d537 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Mon, 20 May 2019 17:14:21 -0400 Subject: [PATCH 09/13] ProgreessBar Modifications --- MVMCoreUI/Atoms/Views/ProgressBar.json | 0 MVMCoreUI/Molecules/ProgressBar.swift | 16 +++++----------- MVMCoreUI/Molecules/ProgressBarView.swift | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 MVMCoreUI/Atoms/Views/ProgressBar.json diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.json b/MVMCoreUI/Atoms/Views/ProgressBar.json deleted file mode 100644 index e69de29b..00000000 diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index f868bbf5..fb417931 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -11,23 +11,21 @@ import Foundation public class ProgressBar: UIProgressView { var isRounded = Bool() - var thickness : Float { - get { - return 10 - } - set { + var thickness : Float = 0.0 { + willSet(newValue) { heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true switch isRounded { case true: - progressViewStyle = .bar - default: layer.cornerRadius = CGFloat((newValue ?? Float(0.0))/2) clipsToBounds = true + default: + progressViewStyle = .bar } } } open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + isRounded = json?.optionalBoolForKey("roundedRect") ?? false thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0) let percentage = json?.floatFromStringForKey("percent") progress = (percentage ?? Float(0.0))/100 @@ -45,10 +43,6 @@ public class ProgressBar: UIProgressView { trackTintColor = UIColor.mfGet(forHex: backgroundcolor) } } - - if let barStyleUnwrapped = json?["barStyle"] as? Bool { - isRounded = barStyleUnwrapped - } } } diff --git a/MVMCoreUI/Molecules/ProgressBarView.swift b/MVMCoreUI/Molecules/ProgressBarView.swift index 1778c555..04eb9046 100644 --- a/MVMCoreUI/Molecules/ProgressBarView.swift +++ b/MVMCoreUI/Molecules/ProgressBarView.swift @@ -47,9 +47,9 @@ import UIKit topleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true topleftlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true - let topleftconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) - topleftconstraint.priority = UILayoutPriority(rawValue: 100) - topleftconstraint.isActive = true + let topleftwidthconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) + topleftwidthconstraint.priority = UILayoutPriority(100) + topleftwidthconstraint.isActive = true topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal) topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical) @@ -57,7 +57,7 @@ import UIKit toprightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true toprightlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true toprightlabel.textAlignment = .right - toprightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) + toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal) toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical) var topconstraint = progress.topAnchor.constraint(equalTo: topleftlabel.bottomAnchor, constant: PaddingTwo) @@ -74,18 +74,18 @@ import UIKit 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) + let bottomleftwidthconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0) + bottomleftwidthconstraint.priority = UILayoutPriority(100) + bottomleftwidthconstraint.isActive = true + bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal) + bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), 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 bottomrightlabel.textAlignment = .right - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal) - bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal) + bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical) var bottomconstraint = bottomAnchor.constraint(equalTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo) bottomconstraint.priority = UILayoutPriority(249) From a95456edff24d899823981925732d45e90d5fef1 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Mon, 20 May 2019 17:31:41 -0400 Subject: [PATCH 10/13] ProgressBar Changes --- MVMCoreUI/Molecules/ProgressBar.swift | 6 +++--- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/ProgressBar.swift b/MVMCoreUI/Molecules/ProgressBar.swift index fb417931..9b40cb42 100644 --- a/MVMCoreUI/Molecules/ProgressBar.swift +++ b/MVMCoreUI/Molecules/ProgressBar.swift @@ -8,7 +8,7 @@ import Foundation -public class ProgressBar: UIProgressView { +public class ProgressBar: UIProgressView, MVMCoreUIMoleculeViewProtocol { var isRounded = Bool() var thickness : Float = 0.0 { @@ -16,7 +16,7 @@ public class ProgressBar: UIProgressView { heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true switch isRounded { case true: - layer.cornerRadius = CGFloat((newValue ?? Float(0.0))/2) + layer.cornerRadius = CGFloat(newValue/2) clipsToBounds = true default: progressViewStyle = .bar @@ -24,7 +24,7 @@ public class ProgressBar: UIProgressView { } } - open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { isRounded = json?.optionalBoolForKey("roundedRect") ?? false thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0) let percentage = json?.floatFromStringForKey("percent") diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 5e5264c9..fda960a2 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -34,7 +34,8 @@ @"caretButton": CaretButton.class, @"textField" : MFTextField.class, @"checkbox" : MVMCoreUICheckBox.class, - @"progressbar" : ProgressBarView.class + @"progressBarView" : ProgressBarView.class, + @"progressBar": ProgressBar.class } mutableCopy]; }); return mapping; From 423d28ede66bae8822847cbc54dab058cf7a8541 Mon Sep 17 00:00:00 2001 From: moscopa Date: Mon, 10 Jun 2019 11:12:17 -0400 Subject: [PATCH 11/13] DOPMO-49460 Making text fields public for Security Code Autofill. --- MVMCoreUI/Atoms/TextFields/MFDigitTextField.h | 3 +++ MVMCoreUI/Atoms/TextFields/MFDigitTextField.m | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h index 936ed017..4be970da 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h @@ -8,6 +8,7 @@ #import +@class MFDigitTextBox; @interface MFDigitTextField : MFTextField + (nullable instancetype)mfDigitTextFieldWithNumberOfDigits:(NSUInteger)numberOfDigits; @@ -18,4 +19,6 @@ - (void)setAsSecureTextEntry:(BOOL)secureTextEntry; +@property (nullable, nonatomic, strong) NSArray *textFields; +//Be careful when using this directly. There's a possiblity that you may break the view. @end diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m index d04cd56c..084ba338 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m @@ -29,7 +29,7 @@ @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *messageToTextFieldPin; @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *labelToTextFieldPin; -@property (nullable, nonatomic, strong) NSArray *textFields; + @property (nonatomic) BOOL switchedAutomatically; @end From f73c25cb618042456c1e42cffcc8bcc7c492c5d5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 11 Jun 2019 12:09:19 -0400 Subject: [PATCH 12/13] isvalid --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 4bdbc8d3..95a85ff5 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -576,7 +576,7 @@ - (BOOL)isValidField { - return self.valid; + return self.isValid; } - (nullable NSString *)formFieldName { From 0d9f49c9373cf346f30a0bcba578fdc965ac02b4 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 11 Jun 2019 13:46:26 -0400 Subject: [PATCH 13/13] update padding for close button --- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index affbc470..487a7b51 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -197,7 +197,13 @@ static const CGFloat VertialShadowOffset = 6; [view.rightAnchor constraintEqualToAnchor:button.rightAnchor constant:PaddingTwo].active = YES; [view.centerYAnchor constraintEqualToAnchor:button.centerYAnchor].active = YES; } else { - [NSLayoutConstraint constraintPinSubview:button pinTop:YES topConstant:PaddingOne pinBottom:NO bottomConstant:0 pinLeft:NO leftConstant:0 pinRight:YES rightConstant:PaddingTwo]; + if (@available(iOS 11.0, *)) { + [button.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.topAnchor constant:PaddingOne].active = YES; + [view.safeAreaLayoutGuide.trailingAnchor constraintEqualToAnchor:button.trailingAnchor constant:PaddingTwo].active = YES; + } else { + [NSLayoutConstraint constraintPinSubview:button pinTop:YES topConstant:PaddingOne pinBottom:NO bottomConstant:0 pinLeft:NO leftConstant:0 pinRight:YES rightConstant:PaddingTwo]; + } + } } return button;