removed static helper size methods
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
e8da41eb70
commit
398ae82151
@ -101,10 +101,7 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
//--------------------------------------------------
|
||||
// Sizes are from InVision design specs.
|
||||
public static var toggleSize = CGSize(width: 52, height: 24)
|
||||
open class func getToggleScaledSize() -> CGSize { return Self.toggleSize }
|
||||
|
||||
public static var knobSize = CGSize(width: 20, height: 20)
|
||||
open class func getKnobScaledSize() -> CGSize { return Self.knobSize }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Computed Properties
|
||||
@ -192,17 +189,17 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
|
||||
let containerSize = Self.getToggleScaledSize()
|
||||
let knobSize = Self.getKnobScaledSize()
|
||||
let toggleSize = Self.toggleSize
|
||||
let knobSize = Self.knobSize
|
||||
|
||||
toggleHeightConstraint?.constant = containerSize.height
|
||||
toggleWidthConstraint?.constant = containerSize.width
|
||||
toggleHeightConstraint?.constant = toggleSize.height
|
||||
toggleWidthConstraint?.constant = toggleSize.width
|
||||
|
||||
knobHeightConstraint?.constant = knobSize.height
|
||||
knobWidthConstraint?.constant = knobSize.width
|
||||
|
||||
toggleView.layer.cornerRadius = containerSize.height / 2.0
|
||||
knobView.layer.cornerRadius = knobSize.height / 2.0
|
||||
toggleView.layer.cornerRadius = toggleSize.height / 2.0
|
||||
knobView.layer.cornerRadius = toggleSize.height / 2.0
|
||||
|
||||
ensureLabel()
|
||||
|
||||
@ -218,16 +215,16 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
|
||||
addSubview(stackView)
|
||||
|
||||
let containerSize = Self.getToggleScaledSize()
|
||||
let knobSize = Self.getKnobScaledSize()
|
||||
|
||||
toggleHeightConstraint = toggleView.heightAnchor.constraint(equalToConstant: containerSize.height)
|
||||
let toggleSize = Self.toggleSize
|
||||
let knobSize = Self.knobSize
|
||||
|
||||
toggleHeightConstraint = toggleView.heightAnchor.constraint(equalToConstant: toggleSize.height)
|
||||
toggleHeightConstraint?.isActive = true
|
||||
|
||||
toggleWidthConstraint = toggleView.widthAnchor.constraint(equalToConstant: containerSize.width)
|
||||
toggleWidthConstraint = toggleView.widthAnchor.constraint(equalToConstant: toggleSize.width)
|
||||
toggleWidthConstraint?.isActive = true
|
||||
|
||||
toggleView.layer.cornerRadius = containerSize.height / 2.0
|
||||
toggleView.layer.cornerRadius = toggleSize.height / 2.0
|
||||
knobView.layer.cornerRadius = knobSize.height / 2.0
|
||||
|
||||
toggleView.backgroundColor = containerTintColor.off
|
||||
@ -343,7 +340,7 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
|
||||
public func knobReformAnimation() {
|
||||
UIView.animate(withDuration: 0.1, animations: {
|
||||
self.knobWidthConstraint?.constant = Self.getKnobScaledSize().width
|
||||
self.knobWidthConstraint?.constant = Self.knobSize.width
|
||||
self.layoutIfNeeded()
|
||||
}, completion: nil)
|
||||
}
|
||||
@ -371,7 +368,7 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
}
|
||||
self.knobTrailingConstraint?.isActive = true
|
||||
self.knobLeadingConstraint?.isActive = true
|
||||
self.knobWidthConstraint?.constant = Self.getKnobScaledSize().width
|
||||
self.knobWidthConstraint?.constant = Self.knobSize.width
|
||||
self.layoutIfNeeded()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user