From dc4a7d9cc1d198cae4377ed52bdec92e4ac27af6 Mon Sep 17 00:00:00 2001 From: Panth Patel Date: Sun, 5 May 2019 22:45:50 -0400 Subject: [PATCH 01/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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 38dc726f416e31826e59866b048effb3a3128c5e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 31 May 2019 09:42:31 -0400 Subject: [PATCH 11/14] Setting up for defaults --- MVMCoreUI/Atoms/Views/SeparatorView.m | 2 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 7 ++++--- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.m b/MVMCoreUI/Atoms/Views/SeparatorView.m index 50e59758..43c33f44 100644 --- a/MVMCoreUI/Atoms/Views/SeparatorView.m +++ b/MVMCoreUI/Atoms/Views/SeparatorView.m @@ -107,7 +107,7 @@ [self setAsMedium]; } else if ([type isEqualToString:@"heavy"]) { [self setAsHeavy]; - } else { + } else if ([type isEqualToString:@"standard"]) { [self setAsLight]; } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 308341fa..6a14416e 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -41,7 +41,7 @@ public class StandardHeaderView: ViewConstrainingView { messageLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) - topPin = headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFive) + topPin = headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: PaddingDefaultVerticalSpacing) topPin?.isActive = true spaceBetweenLabels = messageLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: PaddingTwo) @@ -126,8 +126,9 @@ public class StandardHeaderView: ViewConstrainingView { headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) let bodyJSON = json?.optionalDictionaryForKey("body") messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) - let separatorJSON = json?.optionalDictionaryForKey("separator") - separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) + if let separatorJSON = json?.optionalDictionaryForKey("separator") { + separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) + } if separatorView?.isHidden ?? true { bottomPin?.constant = 0 diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 0d80000b..9329a0a3 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -27,10 +27,10 @@ @"separator": SeparatorView.class, @"button": ButtonView.class, @"textButton": MFTextButton.class, - @"standardHeader": StandardHeaderView.class, + @"header": StandardHeaderView.class, @"moleculeStack": MoleculeStackView.class, @"twoButtonView": TwoButtonView.class, - @"standardFooter": StandardFooterView.class, + @"footer": StandardFooterView.class, @"caretView": CaretView.class, @"caretButton": CaretButton.class, @"textField": MFTextField.class, From c5e306f0aea2a159f2729a78447096c97f6a6210 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 31 May 2019 14:22:52 -0400 Subject: [PATCH 12/14] highlight button status --- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 16 ++++++++++++++-- MVMCoreUI/Categories/UIColor+MFConvenience.h | 3 --- MVMCoreUI/Categories/UIColor+MFConvenience.m | 12 ------------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index b2fe18d2..38cc164e 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -328,7 +328,18 @@ if (self.skipHighlighted) { return; } - if (self.primaryButtonType == PrimaryButtonTypeRed) { + if (self.primaryButtonType == PrimaryButtonTypeCustom) { + if (highlighted && self.enabled) { + CALayer *mask = [[CALayer alloc] init]; + mask.backgroundColor = [UIColor whiteColor].CGColor; + mask.opacity = 0.7; + mask.frame = self.bounds; + self.layer.mask = mask; + self.layer.opaque = true; + } else if (!highlighted) { + self.layer.mask = nil; + } + } if (self.primaryButtonType == PrimaryButtonTypeRed) { if (self.bordered) { if (highlighted) { self.backgroundColor = [UIColor mfRedColor]; @@ -485,11 +496,12 @@ [self setTitleColor:(self.disabledTextColor ?: [UIColor blackColor]) forState:UIControlStateNormal]; } } + [self setTitleColor:[self titleColorForState:UIControlStateNormal] forState:UIControlStateHighlighted]; } - (void)setBordered:(BOOL)bordered { if (bordered != _bordered) { - if (self.buttonType == PrimaryButtonTypeCustom) { + if (self.primaryButtonType == PrimaryButtonTypeCustom) { _bordered = bordered; [self setAsCustom]; } else if (bordered) { diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index c7b6a950..4a51a13b 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -12,11 +12,9 @@ #pragma mark - 2.0 -+ (nonnull UIColor *)mfNegativeOrangeColor; + (nonnull UIColor *)mfSwitchOnTintColor; + (nonnull UIColor *)mfSwitchOffTintColor; + (nonnull UIColor *)mfSilver; -+ (nonnull UIColor *)mfSilverTwo; + (nonnull UIColor *)mfBattleshipGrey; + (nonnull UIColor *)mfPrimaryButtonHighlightBlackColor; + (nonnull UIColor *)mfPrimaryWhiteButtonDisableColor; @@ -26,7 +24,6 @@ + (nonnull UIColor *)mfPumpkinColor; + (nonnull UIColor *)mfShamrock; + (nonnull UIColor *)mfCerulean; -+ (nonnull UIColor *)mfLightBlackColor; + (nonnull UIColor *)mfWhiteTwo; #pragma mark - legacy diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index b4ec2ea2..e56d89bc 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -13,10 +13,6 @@ #pragma mark - 2.0 -+ (nonnull UIColor *)mfNegativeOrangeColor { - return [UIColor mfPumpkinColor]; -} - + (nonnull UIColor *)mfSwitchOnTintColor { return [UIColor mfShamrock]; } @@ -29,10 +25,6 @@ return [UIColor mfColor8bitsWithRed:216 green:218 blue:218 alpha:1.0]; } -+ (nonnull UIColor *)mfSilverTwo { - return [UIColor mfColor8bitsWithRed:217 green:219 blue:219 alpha:1.0]; -} - + (nonnull UIColor *)mfBattleshipGrey { return [UIColor mfColor8bitsWithRed:116 green:118 blue:118 alpha:1.0]; } @@ -70,10 +62,6 @@ return [UIColor mfColor8bitsWithRed:0 green:122 blue:184 alpha:1.0]; } -+ (nonnull UIColor *)mfLightBlackColor { - return [UIColor mfColor8bitsWithRed:95 green:95 blue:95 alpha:1.0]; -} - + (nonnull UIColor *)mfWhiteTwo { return [UIColor mfColor8bitsWithRed:246 green:246 blue:246 alpha:1.0]; } From 81df953669c8eb4b7bfb16be2be7c7be444fd998 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 3 Jun 2019 10:30:09 -0400 Subject: [PATCH 13/14] disable fix. highlight fix. --- MVMCoreUI/Atoms/Buttons/MFTextButton.m | 2 +- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index 4c513ef9..c404fa08 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -54,7 +54,7 @@ self.backgroundColor = [UIColor clearColor]; self.contentMode = UIViewContentModeRedraw; [self setTitleColor:[UIColor mfTextButtonColor] forState:UIControlStateNormal]; - [self setTitleColor:[UIColor mfTextButtonColorHighlighted] forState:UIControlStateHighlighted]; + [self setTitleColor:[UIColor mfCharcoalColor] forState:UIControlStateHighlighted]; // left alignment by default self.titleLabel.textAlignment = NSTextAlignmentLeft; self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 38cc164e..16dc124e 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -643,6 +643,7 @@ self.primaryButtonType = PrimaryButtonTypeCustom; self.fillColor = [UIColor blackColor]; self.textColor = [UIColor whiteColor]; + self.disabledTextColor = self.textColor; self.borderColor = nil; _bordered = false; } From 161f3e9f085a1187f73baf6c30d3af33ecb6b8a7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 4 Jun 2019 12:42:52 -0400 Subject: [PATCH 14/14] reset function. standard spacing for cell molecule MFTextField to view contstraining view constraining protocol --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +++ MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 +-- MVMCoreUI/Atoms/Buttons/MFTextButton.h | 2 +- MVMCoreUI/Atoms/Buttons/MFTextButton.m | 9 ++++++- MVMCoreUI/Atoms/Buttons/PrimaryButton.h | 2 +- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 4 +++ MVMCoreUI/Atoms/TextFields/MFTextField.h | 4 +-- MVMCoreUI/Atoms/TextFields/MFTextField.m | 25 ++++++++----------- MVMCoreUI/Atoms/Views/CaretView.swift | 2 +- MVMCoreUI/Atoms/Views/Label.swift | 17 ++++++++++++- MVMCoreUI/Atoms/Views/MFView.h | 3 ++- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 2 +- MVMCoreUI/Atoms/Views/SeparatorView.m | 4 +++ MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 6 +++++ MVMCoreUI/MVMCoreUI.h | 1 + MVMCoreUI/Molecules/ButtonView.swift | 4 +++ .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 12 ++++----- .../Molecules/MoleculeTableViewCell.swift | 17 +++++++++++-- MVMCoreUI/Molecules/StandardFooterView.swift | 5 ++++ MVMCoreUI/Molecules/StandardHeaderView.swift | 11 ++++++++ MVMCoreUI/Molecules/Switch.swift | 2 +- MVMCoreUI/Molecules/SwitchLineItem.swift | 2 +- MVMCoreUI/Molecules/TwoButtonView.swift | 5 ++++ .../MVMCoreUIMoleculeMappingObject.m | 8 ++++-- .../MVMCoreUIViewConstrainingProtocol.h | 24 ++++++++++++++++++ MVMCoreUI/Styles/MFStyler.h | 1 + MVMCoreUI/Styles/MFStyler.m | 11 +++++--- .../Templates/MoleculeListTemplate.swift | 1 + 28 files changed, 151 insertions(+), 41 deletions(-) create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 577534d9..401a5589 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E143229729C30051EBE7 /* MoleculeMappingObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */; }; + D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */; }; @@ -202,6 +203,7 @@ D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MoleculeMappingObject+Extension.swift"; sourceTree = ""; }; + D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsTableViewController.m; sourceTree = ""; }; @@ -664,6 +666,7 @@ D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */, D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */, D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, + D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, @@ -768,6 +771,7 @@ D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */, D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */, + D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */, D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */, D29DF25721E6A177003B2FB9 /* MFTextField.h in Headers */, D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 4503a1f3..46c6d3f4 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -8,7 +8,7 @@ // -open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol { +open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { //------------------------------------------------------ // MARK: - Constants @@ -136,7 +136,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol { return true } - open func moleculeAlignment() -> UIStackView.Alignment { + open func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } } diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.h b/MVMCoreUI/Atoms/Buttons/MFTextButton.h index ec37589b..1e81e1f0 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.h @@ -10,7 +10,7 @@ #import @class MFSizeObject; -@interface MFTextButton : MFCustomButton +@interface MFTextButton : MFCustomButton @property (nonnull, strong, nonatomic) MFSizeObject *sizeObject; diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index c404fa08..336db92a 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -12,6 +12,7 @@ #import "UIColor+MFConvenience.h" #import "MVMCoreUISplitViewController.h" #import "MVMCoreUIConstants.h" +#import @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; @@ -128,6 +129,10 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol +- (void)reset { + [self setTitleColor:[UIColor mfTextButtonColor] forState:UIControlStateNormal]; +} + - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { NSString *color = [json string:KeyTextColor]; if (color) { @@ -141,11 +146,13 @@ } } +#pragma mark - MVMCoreUIViewConstrainingProtocol + - (BOOL)needsToBeConstrained { return YES; } -- (UIStackViewAlignment)moleculeAlignment { +- (UIStackViewAlignment)alignment { return UIStackViewAlignmentLeading; } diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h index 771f8c01..99929430 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h @@ -26,7 +26,7 @@ typedef enum : NSUInteger { static CGFloat const PrimaryButtonHeight = 42.0; static CGFloat const PrimaryButtonSmallHeight = 30.0; -@interface PrimaryButton : MFCustomButton +@interface PrimaryButton : MFCustomButton @property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 16dc124e..74a1e41a 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -638,6 +638,10 @@ #pragma mark - Molecule protocol +- (void)reset { + [self setAsStandardCustom]; +} + - (void)setAsStandardCustom { // Default to standard look. self.primaryButtonType = PrimaryButtonTypeCustom; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 27dd8414..62985c93 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -7,7 +7,7 @@ // #import -#import +#import @class PrimaryButton; @class MFTextField; @@ -28,7 +28,7 @@ @end -@interface MFTextField : MFView +@interface MFTextField : ViewConstrainingView @property (nullable, weak, nonatomic) UIView *view; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 55d6f8e6..9afcb24a 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -40,17 +40,12 @@ #pragma mark - setup - (void)updateView:(CGFloat)size { + [super updateView:size]; [MVMCoreDispatchUtility performBlockOnMainThread:^{ self.formLabel.font = [MFStyler fontB3]; self.label.font = [MFStyler fontForTextFieldUnderLabel]; [MFStyler styleTextField:self.textField]; [self.dashLine updateView:size]; - - if (self.isMolecule) { - [self setHorizontalPadding:[MFStyler defaultHorizontalPaddingForSize:size]]; - } else { - [self setHorizontalPadding:0]; - } }]; } @@ -369,14 +364,16 @@ }]; } -- (void)setHorizontalPadding:(CGFloat)padding { - self.textContainerLeftPin.constant = padding; - self.errorLableLeftPin.constant = padding; - self.formLabelLeftPin.constant = padding; - - self.textContainerRightPin.constant = padding; - self.errorLableRightPin.constant = padding; - self.formLabelRightPin.constant = padding; +- (void)setLeftPinConstant:(CGFloat)constant { + self.textContainerLeftPin.constant = constant; + self.errorLableLeftPin.constant = constant; + self.formLabelLeftPin.constant = constant; +} + +- (void)setRightPinConstant:(CGFloat)constant { + self.textContainerRightPin.constant = constant; + self.errorLableRightPin.constant = constant; + self.formLabelRightPin.constant = constant; } - (void)dealloc { diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index f5ee49c3..62b82b90 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -133,7 +133,7 @@ open class CaretView: MFView { return true } - open override func moleculeAlignment() -> UIStackView.Alignment { + open override func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } } diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 6302ed90..f2792081 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -10,7 +10,7 @@ import MVMCore -@objc open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { +@objc open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -295,14 +295,29 @@ import MVMCore // MARK: - Atomization //------------------------------------------------------ + public func reset() { + text = nil + attributedText = nil + originalAttributedString = nil + styleB2(true) + } + @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) originalAttributedString = attributedText } + public func setAsMolecule() { + setContentHuggingPriority(.required, for: .vertical) + } + public func needsToBeConstrained() -> Bool { return true; } + + public func alignment() -> UIStackView.Alignment { + return .leading + } } extension Label { diff --git a/MVMCoreUI/Atoms/Views/MFView.h b/MVMCoreUI/Atoms/Views/MFView.h index 5e32ff0a..62683433 100644 --- a/MVMCoreUI/Atoms/Views/MFView.h +++ b/MVMCoreUI/Atoms/Views/MFView.h @@ -8,9 +8,10 @@ #import #import +#import @import MVMCore.MVMCoreViewProtocol; -@interface MFView : UIView +@interface MFView : UIView @property (nullable, nonatomic, strong) NSDictionary *json; diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index 73a29011..9db9285b 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -54,7 +54,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0; return YES; } -- (UIStackViewAlignment)moleculeAlignment { +- (UIStackViewAlignment)alignment { return UIStackViewAlignmentLeading; } diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.m b/MVMCoreUI/Atoms/Views/SeparatorView.m index 43c33f44..2734bc94 100644 --- a/MVMCoreUI/Atoms/Views/SeparatorView.m +++ b/MVMCoreUI/Atoms/Views/SeparatorView.m @@ -70,6 +70,10 @@ #pragma mark - set up +- (void)reset { + [self setAsLight]; +} + - (void)updateView:(CGFloat)size { [super updateView:size]; self.height.constant = [self.heightSizeObject getValueBasedOnSize:size]; diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index d433388c..2830f19b 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -145,6 +145,12 @@ } } +- (void)reset { + if ([self.constrainedView respondsToSelector:@selector(reset)]) { + [self.constrainedView performSelector:@selector(reset)]; + } +} + #pragma mark - MVMCoreUIMoleculeViewProtocol - (void)setAsMolecule { diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index b5ccd8e1..4ef880c0 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,6 +20,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import +#import #import #import #import diff --git a/MVMCoreUI/Molecules/ButtonView.swift b/MVMCoreUI/Molecules/ButtonView.swift index d03a2e72..3e863a8e 100644 --- a/MVMCoreUI/Molecules/ButtonView.swift +++ b/MVMCoreUI/Molecules/ButtonView.swift @@ -39,6 +39,10 @@ import UIKit } // MARK: - MVMCoreViewProtocol + open override func reset() { + primaryButton?.reset() + } + open override func updateView(_ size: CGFloat) { super.updateView(size) MVMCoreDispatchUtility.performBlock(onMainThread: { diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 67e64d24..962b0c0c 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -12,21 +12,19 @@ @protocol MVMCoreUIMoleculeViewProtocol -// Sets up the ui based on the json +/// Sets up the ui based on the json - (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; @optional -// Called after init to provide an early setter for any molecule specific logic +/// Called after init to provide an early setter for any molecule specific logic - (void)setAsMolecule; -// Notifies the creator that the view needs to be constrained in a view. -- (BOOL)needsToBeConstrained; +/// Resets to default state before set with json is called again. +- (void)reset; -// The alignment for the molecule if constrained. -- (UIStackViewAlignment)moleculeAlignment; -// For the molecule list to load more efficiently. +/// For the molecule list to load more efficiently. + (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json; @end diff --git a/MVMCoreUI/Molecules/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/MoleculeTableViewCell.swift index e0053437..298fa6b5 100644 --- a/MVMCoreUI/Molecules/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/MoleculeTableViewCell.swift @@ -41,7 +41,7 @@ import UIKit // MARK: - MFViewProtocol public func updateView(_ size: CGFloat) { - MFStyler.setDefaultMarginsFor(self, size: size) + MFStyler.setDefaultMarginsFor(self, size: size, horizontal: true, vertical: true) if #available(iOS 11.0, *) { contentView.directionalLayoutMargins = directionalLayoutMargins topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading) @@ -75,7 +75,16 @@ import UIKit if molecule == nil { if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { contentView.addSubview(moleculeView) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: moleculeView.needsToBeConstrained?() ?? false).values)) + let standardConstraints = (moleculeView as? MVMCoreUIViewConstrainingProtocol)?.useStandardConstraints?() ?? true + NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: standardConstraints).values)) + if standardConstraints { + let constraint = contentView.heightAnchor.constraint(equalToConstant: 80) + constraint.priority = .defaultLow + constraint.isActive = true + if let moleculeView = moleculeView as? ViewConstrainingView { + moleculeView.updateViewHorizontalDefaults = false + } + } molecule = moleculeView } } else { @@ -97,6 +106,10 @@ import UIKit } } + public func reset() { + molecule?.reset?() + } + public static func estimatedHeight(forRow json: [AnyHashable : Any]?) -> CGFloat { guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON, delegateObject: nil), diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index 5c4aa688..73088b2e 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -101,4 +101,9 @@ public class StandardFooterView: ViewConstrainingView { twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData) textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData) } + + public override func reset() { + twoButtonView.reset() + textButton.reset() + } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 6a14416e..26ce345b 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -19,6 +19,7 @@ public class StandardHeaderView: ViewConstrainingView { var rightConstraintMessage: NSLayoutConstraint? private var heightConstraint: NSLayoutConstraint? + // MARK: - MVMCoreViewProtocol public override func updateView(_ size: CGFloat) { super.updateView(size) headlineLabel.updateView(size) @@ -74,6 +75,7 @@ public class StandardHeaderView: ViewConstrainingView { } } + // MARK: - Constraining public func setSpacing() { if headlineLabel.hasText && messageLabel.hasText { spaceBetweenLabels?.constant = PaddingTwo @@ -110,6 +112,15 @@ public class StandardHeaderView: ViewConstrainingView { separatorView?.rightPin?.constant = constant } + open override func reset() { + backgroundColor = .clear + headlineLabel.styleH2(true) + messageLabel.styleB2(true) + separatorView?.setAsHeavy() + separatorView?.show() + } + + // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { diff --git a/MVMCoreUI/Molecules/Switch.swift b/MVMCoreUI/Molecules/Switch.swift index b97496a3..a8bb00ba 100644 --- a/MVMCoreUI/Molecules/Switch.swift +++ b/MVMCoreUI/Molecules/Switch.swift @@ -80,7 +80,7 @@ import UIKit return true } - public override func moleculeAlignment() -> UIStackView.Alignment { + public override func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading } } diff --git a/MVMCoreUI/Molecules/SwitchLineItem.swift b/MVMCoreUI/Molecules/SwitchLineItem.swift index 665de248..8c15e8ec 100644 --- a/MVMCoreUI/Molecules/SwitchLineItem.swift +++ b/MVMCoreUI/Molecules/SwitchLineItem.swift @@ -113,7 +113,7 @@ import UIKit return true } - public override func moleculeAlignment() -> UIStackView.Alignment { + public override func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading } } diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index ca3c8215..48becca2 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -49,6 +49,11 @@ import UIKit set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) } + open override func reset() { + super.reset() + secondaryButton?.setAsSecondaryCustom() + } + // MARK: - Constraining override func setupButton() { setupWithTwoButtons() diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 9329a0a3..0004027a 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -13,6 +13,7 @@ #import "MVMCoreUIObject.h" #import #import "MFTextField.h" +#import "MVMCoreUIViewConstrainingProtocol.h" @implementation MVMCoreUIMoleculeMappingObject @@ -82,8 +83,11 @@ return nil; } UIView *molecule = [self createMoleculeForName:moleculeName]; - if (constrainIfNeeded && [molecule respondsToSelector:@selector(needsToBeConstrained)] && [molecule needsToBeConstrained]) { - molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[molecule respondsToSelector:@selector(moleculeAlignment)] ? [molecule moleculeAlignment] : UIStackViewAlignmentFill]; + + // Check if we need to constrain this view. + UIView *castMolecule = [molecule conformsToProtocol:@protocol(MVMCoreUIViewConstrainingProtocol)] ? (UIView *)molecule : nil; + if (constrainIfNeeded && [castMolecule respondsToSelector:@selector(needsToBeConstrained)] && [castMolecule needsToBeConstrained]) { + molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[castMolecule respondsToSelector:@selector(alignment)] ? [castMolecule alignment] : UIStackViewAlignmentFill]; } [molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:nil]; return molecule; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h b/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h new file mode 100644 index 00000000..8bdc3eb1 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h @@ -0,0 +1,24 @@ +// +// MVMCoreUIViewConstrainingProtocol.h +// MVMCoreUI +// +// Created by Scott Pfeil on 6/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +#import + +@protocol MVMCoreUIViewConstrainingProtocol + +@optional + +/// Notifies the creator that the view may not be suitable to be shown on its own and it needs to be added to a view to help with layout. +- (BOOL)needsToBeConstrained; + +/// The alignment if constrained. +- (UIStackViewAlignment)alignment; + +/// Can be used to override any standard constraints that may be added. +- (BOOL)useStandardConstraints; + +@end diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 0a52c468..b8c80752 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -91,6 +91,7 @@ B3 -> Legal + (CGFloat)defaultHorizontalPaddingForSize:(CGFloat)size; + (CGFloat)defaultVerticalPaddingForSize:(CGFloat)size; + (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size; ++ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size horizontal:(BOOL)horizontal vertical:(BOOL)vertical; //------------------------------------------------- // Returns the fonts for these styles. Scales them as needed by default diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 261181b1..4f27b2be 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -91,12 +91,17 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size { + [self setDefaultMarginsForView:view size:size horizontal:YES vertical:NO]; +} + ++ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size horizontal:(BOOL)horizontal vertical:(BOOL)vertical { [MVMCoreDispatchUtility performBlockOnMainThread:^{ - CGFloat padding = [MFStyler defaultHorizontalPaddingForSize:size]; + CGFloat horizontalPadding = horizontal ? [MFStyler defaultHorizontalPaddingForSize:size] : 0; + CGFloat verticalPadding = vertical ? PaddingDefaultVerticalSpacing : 0; if (@available(iOS 11.0, *)) { - view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(0, padding, 0, padding); + view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(verticalPadding, horizontalPadding, verticalPadding, horizontalPadding); } else { - view.layoutMargins = UIEdgeInsetsMake(0, padding, 0, padding); + view.layoutMargins = UIEdgeInsetsMake(verticalPadding, horizontalPadding, verticalPadding, horizontalPadding); } }]; } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index db69218b..9f8b7707 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -85,6 +85,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { protocolCell.setSeparatorWithJSON?(loadObject?.pageJSON?.optionalDictionaryForKey("separator"), delegateObject: delegate, additionalData: nil, indexPath: indexPath) } if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol { + protocolCell.reset?() protocolCell.setWithJSON(molecule.molecule, delegateObject: delegate, additionalData: nil) protocolCell.updateView(tableView.bounds.width) }