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;