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