Big Self.
This commit is contained in:
parent
4a49c40b19
commit
14f49882b1
@ -93,7 +93,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
|
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
||||||
self.constrainKnob()
|
self.constrainKnob()
|
||||||
self.knobWidthConstraint?.constant = Toggle.getKnobWidth()
|
self.knobWidthConstraint?.constant = Self.getKnobWidth()
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}, completion: nil)
|
}, completion: nil)
|
||||||
|
|
||||||
@ -128,7 +128,6 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
private var widthConstraint: NSLayoutConstraint?
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
private func constrainKnob() {
|
private func constrainKnob() {
|
||||||
|
|
||||||
knobLeadingConstraint?.isActive = !isOn
|
knobLeadingConstraint?.isActive = !isOn
|
||||||
knobTrailingConstraint?.isActive = isOn
|
knobTrailingConstraint?.isActive = isOn
|
||||||
}
|
}
|
||||||
@ -179,14 +178,14 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
public override func updateView(_ size: CGFloat) {
|
public override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
|
|
||||||
heightConstraint?.constant = Toggle.getContainerHeight()
|
heightConstraint?.constant = Self.getContainerHeight()
|
||||||
widthConstraint?.constant = Toggle.getContainerWidth()
|
widthConstraint?.constant = Self.getContainerWidth()
|
||||||
|
|
||||||
knobHeightConstraint?.constant = Toggle.getKnobHeight()
|
knobHeightConstraint?.constant = Self.getKnobHeight()
|
||||||
knobWidthConstraint?.constant = Toggle.getKnobWidth()
|
knobWidthConstraint?.constant = Self.getKnobWidth()
|
||||||
|
|
||||||
layer.cornerRadius = Toggle.getContainerHeight() / 2.0
|
layer.cornerRadius = Self.getContainerHeight() / 2.0
|
||||||
knobView.layer.cornerRadius = Toggle.getKnobHeight() / 2.0
|
knobView.layer.cornerRadius = Self.getKnobHeight() / 2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func setupView() {
|
public override func setupView() {
|
||||||
@ -194,20 +193,20 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
|
|
||||||
guard subviews.isEmpty else { return }
|
guard subviews.isEmpty else { return }
|
||||||
|
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant: Toggle.containerSize.height)
|
heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
|
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: Toggle.containerSize.width)
|
widthConstraint = widthAnchor.constraint(equalToConstant: Self.containerSize.width)
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
|
|
||||||
layer.cornerRadius = Toggle.containerSize.height / 2.0
|
layer.cornerRadius = Self.containerSize.height / 2.0
|
||||||
backgroundColor = containerTintColor?.off
|
backgroundColor = containerTintColor?.off
|
||||||
|
|
||||||
addSubview(knobView)
|
addSubview(knobView)
|
||||||
|
|
||||||
knobHeightConstraint = knobView.heightAnchor.constraint(equalToConstant: Toggle.knobSize.height)
|
knobHeightConstraint = knobView.heightAnchor.constraint(equalToConstant: Self.knobSize.height)
|
||||||
knobHeightConstraint?.isActive = true
|
knobHeightConstraint?.isActive = true
|
||||||
knobWidthConstraint = knobView.widthAnchor.constraint(equalToConstant: Toggle.knobSize.width)
|
knobWidthConstraint = knobView.widthAnchor.constraint(equalToConstant: Self.knobSize.width)
|
||||||
knobWidthConstraint?.isActive = true
|
knobWidthConstraint?.isActive = true
|
||||||
knobView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
knobView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
knobView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
knobView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
@ -233,23 +232,23 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
class func getContainerWidth() -> CGFloat {
|
class func getContainerWidth() -> CGFloat {
|
||||||
let containerWidth = Toggle.containerSize.width
|
let containerWidth = Self.containerSize.width
|
||||||
return (MFSizeObject(standardSize: containerWidth, standardiPadPortraitSize: CGFloat(Toggle.containerSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerWidth
|
return (MFSizeObject(standardSize: containerWidth, standardiPadPortraitSize: CGFloat(Self.containerSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
class func getContainerHeight() -> CGFloat {
|
class func getContainerHeight() -> CGFloat {
|
||||||
let containerHeight = Toggle.containerSize.height
|
let containerHeight = Self.containerSize.height
|
||||||
return (MFSizeObject(standardSize: containerHeight, standardiPadPortraitSize: CGFloat(Toggle.containerSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerHeight
|
return (MFSizeObject(standardSize: containerHeight, standardiPadPortraitSize: CGFloat(Self.containerSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
class func getKnobWidth() -> CGFloat {
|
class func getKnobWidth() -> CGFloat {
|
||||||
let knobWidth = Toggle.knobSize.width
|
let knobWidth = Self.knobSize.width
|
||||||
return (MFSizeObject(standardSize: knobWidth, standardiPadPortraitSize: CGFloat(Toggle.knobSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobWidth
|
return (MFSizeObject(standardSize: knobWidth, standardiPadPortraitSize: CGFloat(Self.knobSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
class func getKnobHeight() -> CGFloat {
|
class func getKnobHeight() -> CGFloat {
|
||||||
let knobHeight = Toggle.knobSize.width
|
let knobHeight = Self.knobSize.width
|
||||||
return (MFSizeObject(standardSize: knobHeight, standardiPadPortraitSize: CGFloat(Toggle.knobSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobHeight
|
return (MFSizeObject(standardSize: knobHeight, standardiPadPortraitSize: CGFloat(Self.knobSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -326,12 +325,12 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
|
|
||||||
if isAnimated {
|
if isAnimated {
|
||||||
UIView.animate(withDuration: 0.1, animations: {
|
UIView.animate(withDuration: 0.1, animations: {
|
||||||
self.knobWidthConstraint?.constant = Toggle.getKnobWidth()
|
self.knobWidthConstraint?.constant = Self.getKnobWidth()
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}, completion: nil)
|
}, completion: nil)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
knobWidthConstraint?.constant = Toggle.getKnobWidth()
|
knobWidthConstraint?.constant = Self.getKnobWidth()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +401,7 @@ extension Toggle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
return Toggle.getContainerHeight()
|
return Self.getContainerHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func needsToBeConstrained() -> Bool {
|
public func needsToBeConstrained() -> Bool {
|
||||||
|
|||||||
@ -72,6 +72,7 @@ extension Control: MVMCoreViewProtocol {
|
|||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
extension Control: MVMCoreUIMoleculeViewProtocol {
|
extension Control: MVMCoreUIMoleculeViewProtocol {
|
||||||
|
|
||||||
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
self.json = json
|
self.json = json
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user