progress updates
This commit is contained in:
parent
9e241e6d8e
commit
24bce846f4
@ -136,8 +136,8 @@
|
||||
942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; };
|
||||
942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378D2412F5B60066E45E /* ModalMoleculeStackTemplate.swift */; };
|
||||
9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; };
|
||||
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; };
|
||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; };
|
||||
943784F5236B77BB006A1E82 /* Wheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* Wheel.swift */; };
|
||||
943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */; };
|
||||
9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; };
|
||||
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; };
|
||||
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; };
|
||||
@ -249,7 +249,7 @@
|
||||
D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */; };
|
||||
D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837E23CCA96400DFE4FC /* TabsModel.swift */; };
|
||||
D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */; };
|
||||
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */; };
|
||||
D28A838323CCBD3F00DFE4FC /* WheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* WheelModel.swift */; };
|
||||
D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; };
|
||||
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; };
|
||||
D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; };
|
||||
@ -525,8 +525,8 @@
|
||||
942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalMoleculeListTemplate.swift; sourceTree = "<group>"; };
|
||||
942C378D2412F5B60066E45E /* ModalMoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalMoleculeStackTemplate.swift; sourceTree = "<group>"; };
|
||||
9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = "<group>"; };
|
||||
943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = "<group>"; };
|
||||
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = "<group>"; };
|
||||
943784F3236B77BB006A1E82 /* Wheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wheel.swift; sourceTree = "<group>"; };
|
||||
943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WheelAnimationHandler.swift; sourceTree = "<group>"; };
|
||||
9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = "<group>"; };
|
||||
9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = "<group>"; };
|
||||
9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = "<group>"; };
|
||||
@ -635,7 +635,7 @@
|
||||
D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsListItemModel.swift; sourceTree = "<group>"; };
|
||||
D28A837E23CCA96400DFE4FC /* TabsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsModel.swift; sourceTree = "<group>"; };
|
||||
D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionListItemModel.swift; sourceTree = "<group>"; };
|
||||
D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressModel.swift; sourceTree = "<group>"; };
|
||||
D28A838223CCBD3F00DFE4FC /* WheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WheelModel.swift; sourceTree = "<group>"; };
|
||||
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = "<group>"; };
|
||||
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = "<group>"; };
|
||||
D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = "<group>"; };
|
||||
@ -1539,9 +1539,9 @@
|
||||
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */,
|
||||
31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */,
|
||||
0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */,
|
||||
D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */,
|
||||
943784F3236B77BB006A1E82 /* GraphView.swift */,
|
||||
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */,
|
||||
D28A838223CCBD3F00DFE4FC /* WheelModel.swift */,
|
||||
943784F3236B77BB006A1E82 /* Wheel.swift */,
|
||||
943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */,
|
||||
D260105223CEA61600764D80 /* ToggleModel.swift */,
|
||||
0AA33B392398524F0067DD0F /* Toggle.swift */,
|
||||
0AE98BB623FF18E9004C5109 /* ArrowModel.swift */,
|
||||
@ -1902,7 +1902,7 @@
|
||||
5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */,
|
||||
0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */,
|
||||
8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */,
|
||||
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */,
|
||||
943784F5236B77BB006A1E82 /* Wheel.swift in Sources */,
|
||||
31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */,
|
||||
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */,
|
||||
D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */,
|
||||
@ -2008,7 +2008,7 @@
|
||||
D2A514672213885800345BFB /* MoleculeHeaderView.swift in Sources */,
|
||||
D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */,
|
||||
01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */,
|
||||
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */,
|
||||
D28A838323CCBD3F00DFE4FC /* WheelModel.swift in Sources */,
|
||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||
@ -2149,7 +2149,7 @@
|
||||
D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */,
|
||||
0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */,
|
||||
94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */,
|
||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */,
|
||||
943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */,
|
||||
011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */,
|
||||
D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */,
|
||||
011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */,
|
||||
|
||||
@ -24,14 +24,12 @@ import UIKit
|
||||
}
|
||||
var previous: UIView?
|
||||
for progressObject in progressList! {
|
||||
guard progressObject.progress > 0.0 else {
|
||||
continue
|
||||
}
|
||||
guard progressObject.percent > 0.0 else { continue }
|
||||
let view = UIView(frame: .zero)
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(view)
|
||||
view.backgroundColor = progressObject.progressColor.uiColor
|
||||
view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress/100.0).isActive = true
|
||||
view.backgroundColor = progressObject.color.uiColor
|
||||
view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.percent/100.0).isActive = true
|
||||
view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true
|
||||
previous = view
|
||||
NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: false, pinRight: false)
|
||||
@ -39,9 +37,9 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
var roundedRect: Bool = false {
|
||||
var roundedCorners: Bool = false {
|
||||
didSet {
|
||||
if roundedRect {
|
||||
if roundedCorners {
|
||||
layer.cornerRadius = (thicknessConstraint?.constant ?? defaultHeight)/2
|
||||
} else {
|
||||
layer.cornerRadius = 0
|
||||
@ -69,7 +67,7 @@ import UIKit
|
||||
guard let multiProgressModel = multiProgressModel else {
|
||||
return
|
||||
}
|
||||
roundedRect = multiProgressModel.roundedRect ?? false
|
||||
roundedCorners = multiProgressModel.roundedCorners ?? false
|
||||
thicknessConstraint?.constant = multiProgressModel.thickness ?? defaultHeight
|
||||
progressList = multiProgressModel.progressList
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class SingleProgressBarModel: Codable {
|
||||
@Percent var progress: CGFloat
|
||||
var progressColor: Color
|
||||
@Percent var percent: CGFloat
|
||||
var color: Color
|
||||
|
||||
init(_ progress: CGFloat, color: Color) {
|
||||
self.progress = progress
|
||||
self.progressColor = color
|
||||
init(_ percent: CGFloat, color: Color) {
|
||||
self.percent = percent
|
||||
self.color = color
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,13 +23,13 @@ import Foundation
|
||||
public var progressList: [SingleProgressBarModel]
|
||||
public var backgroundColor: Color?
|
||||
public var thickness: CGFloat?
|
||||
public var roundedRect: Bool?
|
||||
public var roundedCorners: Bool?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case progressList
|
||||
case thickness
|
||||
case roundedRect
|
||||
case roundedCorners
|
||||
case backgroundColor
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ import Foundation
|
||||
progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness)
|
||||
roundedRect = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedRect)
|
||||
roundedCorners = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedCorners)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -50,7 +50,7 @@ import Foundation
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(progressList, forKey: .progressList)
|
||||
try container.encodeIfPresent(thickness, forKey: .thickness)
|
||||
try container.encodeIfPresent(roundedRect, forKey: .roundedRect)
|
||||
try container.encodeIfPresent(roundedCorners, forKey: .roundedCorners)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ import Foundation
|
||||
var thickness: CGFloat = 8.0 {
|
||||
willSet(newValue) {
|
||||
heightAnchor.constraint(equalToConstant: newValue).isActive = true
|
||||
if progressBarModel?.isRounded ?? false {
|
||||
if progressBarModel?.roundedCorners ?? false {
|
||||
layer.cornerRadius = newValue/2.0
|
||||
} else {
|
||||
progressViewStyle = .bar
|
||||
@ -52,12 +52,11 @@ import Foundation
|
||||
|
||||
//MARK: - MoleculeViewProtocol
|
||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
guard let progressBarModel = model as? ProgressBarModel else {
|
||||
return
|
||||
}
|
||||
guard let progressBarModel = model as? ProgressBarModel else { return }
|
||||
self.progressBarModel = progressBarModel
|
||||
thickness = progressBarModel.thickness ?? 8
|
||||
progress = Float((progressBarModel.percent)/100.0)
|
||||
progressTintColor = progressBarModel.progressColor.uiColor
|
||||
progressTintColor = progressBarModel.color.uiColor
|
||||
if let backgroundColor = progressBarModel.backgroundColor {
|
||||
trackTintColor = backgroundColor.uiColor
|
||||
}
|
||||
|
||||
@ -11,17 +11,17 @@ import Foundation
|
||||
@objcMembers public class ProgressBarModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "progressBar"
|
||||
@Percent public var percent: CGFloat
|
||||
public var progressColor: Color = Color(uiColor: .mfCerulean())
|
||||
public var color: Color = Color(uiColor: .mfCerulean())
|
||||
public var backgroundColor: Color? = Color(uiColor: .mfLightSilver())
|
||||
public var isRounded: Bool?
|
||||
public var roundedCorners: Bool?
|
||||
public var thickness: CGFloat?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case isRounded = "roundRect"
|
||||
case roundedCorners
|
||||
case thickness
|
||||
case percent
|
||||
case progressColor
|
||||
case color
|
||||
case backgroundColor
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ import Foundation
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
percent = try typeContainer.decode(CGFloat.self, forKey: .percent)
|
||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .progressColor) {
|
||||
progressColor = color
|
||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) {
|
||||
self.color = color
|
||||
}
|
||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) {
|
||||
backgroundColor = color
|
||||
}
|
||||
isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded)
|
||||
roundedCorners = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedCorners)
|
||||
thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness)
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ import Foundation
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(percent, forKey: .percent)
|
||||
try container.encode(progressColor, forKey: .progressColor)
|
||||
try container.encode(color, forKey: .color)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encodeIfPresent(isRounded, forKey: .isRounded)
|
||||
try container.encodeIfPresent(roundedCorners, forKey: .roundedCorners)
|
||||
try container.encodeIfPresent(thickness, forKey: .thickness)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// GraphView.swift
|
||||
// Wheel.swift
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Ryan on 10/24/19.
|
||||
@ -8,12 +8,12 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class GraphView: View, MVMCoreUIViewConstrainingProtocol {
|
||||
@objcMembers open class Wheel: View, MVMCoreUIViewConstrainingProtocol {
|
||||
|
||||
var heightConstraint: NSLayoutConstraint?
|
||||
var gradientLayer: CALayer?
|
||||
var graphModel: CircleProgressModel? {
|
||||
return model as? CircleProgressModel
|
||||
var graphModel: WheelModel? {
|
||||
return model as? WheelModel
|
||||
}
|
||||
|
||||
// MARK: setup
|
||||
@ -28,7 +28,7 @@ import UIKit
|
||||
|
||||
override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? CircleProgressModel else { return }
|
||||
guard let model = model as? WheelModel else { return }
|
||||
createGraphCircle(model)
|
||||
rotationAnimation(model)
|
||||
}
|
||||
@ -42,7 +42,7 @@ import UIKit
|
||||
}
|
||||
|
||||
// MARK: circle
|
||||
open func createGraphCircle(_ graphObject: CircleProgressModel) {
|
||||
open func createGraphCircle(_ graphObject: WheelModel) {
|
||||
if let sublayers = layer.sublayers {
|
||||
for sublayer in sublayers {
|
||||
sublayer.removeAllAnimations()
|
||||
@ -56,7 +56,7 @@ import UIKit
|
||||
|
||||
//begin point will be at the bottom, clockwise direction
|
||||
let path = UIBezierPath(arcCenter: CGPoint(x: radius
|
||||
, y: radius), radius: radius - graphObject.lineWidth/2.0, startAngle: CGFloat(GraphView.getPiValue(90.0)), endAngle: CGFloat(GraphView.getPiValue(90.0 + 360.0)), clockwise: true)
|
||||
, y: radius), radius: radius - graphObject.lineWidth/2.0, startAngle: CGFloat(Wheel.getPiValue(90.0)), endAngle: CGFloat(Wheel.getPiValue(90.0 + 360.0)), clockwise: true)
|
||||
path.lineWidth = graphObject.lineWidth
|
||||
|
||||
let circleLayer = CAShapeLayer()
|
||||
@ -83,7 +83,7 @@ import UIKit
|
||||
| | |
|
||||
-------------
|
||||
*/
|
||||
func createGradientLayer(_ graphObject: CircleProgressModel) -> CALayer {
|
||||
func createGradientLayer(_ graphObject: WheelModel) -> CALayer {
|
||||
let containLayer = CALayer()
|
||||
containLayer.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter)
|
||||
let radius = graphObject.diameter / 2.0
|
||||
@ -151,18 +151,18 @@ import UIKit
|
||||
}
|
||||
|
||||
//MARK: Animation
|
||||
func rotationAnimation(_ object: CircleProgressModel) {
|
||||
func rotationAnimation(_ object: WheelModel) {
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread:{
|
||||
let rotation = CABasicAnimation(keyPath: "transform.rotation")
|
||||
let animationHandler = GraphViewAnimationHandler.shared
|
||||
let animationHandler = WheelAnimationHandler.shared
|
||||
let startAngle = animationHandler.getAnimationStartAngle(object.duration, CACurrentMediaTime())
|
||||
if startAngle == 0.0 {
|
||||
animationHandler.storeAnimation(object.duration, CACurrentMediaTime())
|
||||
}
|
||||
var fromValue = GraphView.getPiValue(0.0 + startAngle), toValue = GraphView.getPiValue(360.0 + startAngle)
|
||||
var fromValue = Wheel.getPiValue(0.0 + startAngle), toValue = Wheel.getPiValue(360.0 + startAngle)
|
||||
if !object.clockwise {
|
||||
fromValue = GraphView.getPiValue(360.0 - startAngle)
|
||||
toValue = GraphView.getPiValue(0.0 - startAngle)
|
||||
fromValue = Wheel.getPiValue(360.0 - startAngle)
|
||||
toValue = Wheel.getPiValue(0.0 - startAngle)
|
||||
}
|
||||
rotation.fromValue = fromValue
|
||||
rotation.toValue = toValue
|
||||
@ -180,7 +180,7 @@ import UIKit
|
||||
}
|
||||
|
||||
|
||||
extension GraphView: CAAnimationDelegate {
|
||||
extension Wheel: CAAnimationDelegate {
|
||||
public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
|
||||
if let object = graphModel {
|
||||
rotationAnimation(object)
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// GraphViewAnimationHandler.swift
|
||||
// WheelAnimationHandler.swift
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Ryan on 10/29/19.
|
||||
@ -8,12 +8,12 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class GraphViewAnimationHandler: NSObject {
|
||||
@objcMembers open class WheelAnimationHandler: NSObject {
|
||||
|
||||
/// duration : CACurrentMediaTime()
|
||||
private var animations = [Double: Double]()
|
||||
|
||||
static let shared = GraphViewAnimationHandler()
|
||||
static let shared = WheelAnimationHandler()
|
||||
|
||||
open func storeAnimation(_ duration: Double, _ currentTime: CFTimeInterval) {
|
||||
guard animations[duration] == nil else {
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// CircleProgressModel.swift
|
||||
// WheelModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 1/13/20.
|
||||
@ -16,9 +16,9 @@ public enum GraphStyle: String, Codable {
|
||||
case unlimited, safetyMode
|
||||
}
|
||||
|
||||
public class CircleProgressModel: MoleculeModelProtocol {
|
||||
public class WheelModel: MoleculeModelProtocol {
|
||||
|
||||
public static var identifier: String = "circleProgress"
|
||||
public static var identifier: String = "wheel"
|
||||
public var style: GraphStyle = .unlimited {
|
||||
didSet {
|
||||
updateStyle()
|
||||
@ -72,7 +72,7 @@ import Foundation
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: DashLine.self, viewModelClass: DashLineModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: MFLoadImageView.self, viewModelClass: ImageViewModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: Wheel.self, viewModelClass: WheelModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self)
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
@objcMembers open class ListRVWheel: TableViewCell {
|
||||
let wheel = GraphView(frame: .zero)
|
||||
let wheel = Wheel(frame: .zero)
|
||||
let leftLabel = Label.commonLabelB1(true)
|
||||
let rightLabel = Label.commonLabelB2(true)
|
||||
var stack: Stack<StackModel>
|
||||
|
||||
@ -11,9 +11,9 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol {
|
||||
public static var identifier: String = "listRVWheel"
|
||||
public var leftLabel: LabelModel
|
||||
public var rightLabel: LabelModel
|
||||
public var wheel : CircleProgressModel
|
||||
public var wheel: WheelModel
|
||||
|
||||
public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: CircleProgressModel) {
|
||||
public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: WheelModel) {
|
||||
self.leftLabel = leftLabel
|
||||
self.rightLabel = rightLabel
|
||||
self.wheel = wheel
|
||||
@ -37,7 +37,7 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
||||
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||
wheel = try typeContainer.decodeIfPresent(CircleProgressModel.self, forKey: .wheel) ?? CircleProgressModel()
|
||||
wheel = try typeContainer.decodeIfPresent(WheelModel.self, forKey: .wheel) ?? WheelModel()
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user