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 + } +} + + + + + +