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