Commit c0ff3bfa by Daniel Dahan

development: update internal Motion API usage for latest changes with…

development: update internal Motion API usage for latest changes with MotionAnimation struct API approach
parent 24dc7615
Subproject commit 67550d30d5162f59d958c6866e99a91bab158197 Subproject commit 06f6c0cd453ac33bcd9ee90b0f9805ed5659b74f
...@@ -157,6 +157,7 @@ extension CollectionViewLayout { ...@@ -157,6 +157,7 @@ extension CollectionViewLayout {
attributes.frame = CGRect(x: contentEdgeInsets.left, y: offset.y, width: collectionView!.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right, height: h) attributes.frame = CGRect(x: contentEdgeInsets.left, y: offset.y, width: collectionView!.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right, height: h)
} else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.height { } else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.height {
v.updateConstraints()
v.setNeedsLayout() v.setNeedsLayout()
v.layoutIfNeeded() v.layoutIfNeeded()
...@@ -170,6 +171,7 @@ extension CollectionViewLayout { ...@@ -170,6 +171,7 @@ extension CollectionViewLayout {
attributes.frame = CGRect(x: offset.x, y: contentEdgeInsets.top, width: w, height: collectionView!.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom) attributes.frame = CGRect(x: offset.x, y: contentEdgeInsets.top, width: w, height: collectionView!.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom)
} else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.width { } else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.width {
v.updateConstraints()
v.setNeedsLayout() v.setNeedsLayout()
v.layoutIfNeeded() v.layoutIfNeeded()
......
...@@ -639,6 +639,7 @@ extension Layout { ...@@ -639,6 +639,7 @@ extension Layout {
public class func width(parent: UIView, child: UIView, width: CGFloat = 0) { public class func width(parent: UIView, child: UIView, width: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: width)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: width))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -652,6 +653,7 @@ extension Layout { ...@@ -652,6 +653,7 @@ extension Layout {
public class func height(parent: UIView, child: UIView, height: CGFloat = 0) { public class func height(parent: UIView, child: UIView, height: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: height)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: height))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -687,6 +689,7 @@ extension Layout { ...@@ -687,6 +689,7 @@ extension Layout {
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right)) parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right))
} }
for child in children { for child in children {
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -703,6 +706,7 @@ extension Layout { ...@@ -703,6 +706,7 @@ extension Layout {
*/ */
public class func vertically(parent: UIView, children: [UIView], top: CGFloat = 0, bottom: CGFloat = 0, interimSpace: InterimSpace = 0) { public class func vertically(parent: UIView, children: [UIView], top: CGFloat = 0, bottom: CGFloat = 0, interimSpace: InterimSpace = 0) {
prepareForConstraint(parent, children: children) prepareForConstraint(parent, children: children)
if 0 < children.count { if 0 < children.count {
parent.addConstraint(NSLayoutConstraint(item: children[0], attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top)) parent.addConstraint(NSLayoutConstraint(item: children[0], attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top))
for i in 1..<children.count { for i in 1..<children.count {
...@@ -711,7 +715,9 @@ extension Layout { ...@@ -711,7 +715,9 @@ extension Layout {
} }
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom)) parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom))
} }
for child in children { for child in children {
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -726,8 +732,11 @@ extension Layout { ...@@ -726,8 +732,11 @@ extension Layout {
*/ */
public class func horizontally(parent: UIView, child: UIView, left: CGFloat = 0, right: CGFloat = 0) { public class func horizontally(parent: UIView, child: UIView, left: CGFloat = 0, right: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .left, relatedBy: .equal, toItem: parent, attribute: .left, multiplier: 1, constant: left)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .left, relatedBy: .equal, toItem: parent, attribute: .left, multiplier: 1, constant: left))
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -741,8 +750,11 @@ extension Layout { ...@@ -741,8 +750,11 @@ extension Layout {
*/ */
public class func vertically(parent: UIView, child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) { public class func vertically(parent: UIView, child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top))
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -770,7 +782,10 @@ extension Layout { ...@@ -770,7 +782,10 @@ extension Layout {
*/ */
public class func top(parent: UIView, child: UIView, top: CGFloat = 0) { public class func top(parent: UIView, child: UIView, top: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .top, relatedBy: .equal, toItem: parent, attribute: .top, multiplier: 1, constant: top))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -784,7 +799,10 @@ extension Layout { ...@@ -784,7 +799,10 @@ extension Layout {
*/ */
public class func left(parent: UIView, child: UIView, left: CGFloat = 0) { public class func left(parent: UIView, child: UIView, left: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .left, relatedBy: .equal, toItem: parent, attribute: .left, multiplier: 1, constant: left)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .left, relatedBy: .equal, toItem: parent, attribute: .left, multiplier: 1, constant: left))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -798,7 +816,10 @@ extension Layout { ...@@ -798,7 +816,10 @@ extension Layout {
*/ */
public class func bottom(parent: UIView, child: UIView, bottom: CGFloat = 0) { public class func bottom(parent: UIView, child: UIView, bottom: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -812,7 +833,10 @@ extension Layout { ...@@ -812,7 +833,10 @@ extension Layout {
*/ */
public class func right(parent: UIView, child: UIView, right: CGFloat = 0) { public class func right(parent: UIView, child: UIView, right: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -891,7 +915,10 @@ extension Layout { ...@@ -891,7 +915,10 @@ extension Layout {
*/ */
public class func centerHorizontally(parent: UIView, child: UIView, offset: CGFloat = 0) { public class func centerHorizontally(parent: UIView, child: UIView, offset: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .centerX, relatedBy: .equal, toItem: parent, attribute: .centerX, multiplier: 1, constant: offset)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .centerX, relatedBy: .equal, toItem: parent, attribute: .centerX, multiplier: 1, constant: offset))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
...@@ -905,7 +932,10 @@ extension Layout { ...@@ -905,7 +932,10 @@ extension Layout {
*/ */
public class func centerVertically(parent: UIView, child: UIView, offset: CGFloat = 0) { public class func centerVertically(parent: UIView, child: UIView, offset: CGFloat = 0) {
prepareForConstraint(parent, child: child) prepareForConstraint(parent, child: child)
parent.addConstraint(NSLayoutConstraint(item: child, attribute: .centerY, relatedBy: .equal, toItem: parent, attribute: .centerY, multiplier: 1, constant: offset)) parent.addConstraint(NSLayoutConstraint(item: child, attribute: .centerY, relatedBy: .equal, toItem: parent, attribute: .centerY, multiplier: 1, constant: offset))
child.updateConstraints()
child.setNeedsLayout() child.setNeedsLayout()
child.layoutIfNeeded() child.layoutIfNeeded()
} }
......
...@@ -285,7 +285,7 @@ extension CALayer { ...@@ -285,7 +285,7 @@ extension CALayer {
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
} else { } else {
animate(.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath)) animate(.shadow(path: UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath))
} }
} }
} }
...@@ -135,6 +135,7 @@ open class NavigationController: UINavigationController { ...@@ -135,6 +135,7 @@ open class NavigationController: UINavigationController {
/// Calls the layout functions for the view heirarchy. /// Calls the layout functions for the view heirarchy.
open func layoutSubviews() { open func layoutSubviews() {
navigationBar.updateConstraints()
navigationBar.setNeedsLayout() navigationBar.setNeedsLayout()
navigationBar.layoutIfNeeded() navigationBar.layoutIfNeeded()
} }
......
...@@ -145,21 +145,21 @@ public struct Pulse { ...@@ -145,21 +145,21 @@ public struct Pulse {
bLayer.setValue(false, forKey: "animated") bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .center == animation ? 0.16125 : 0.325 let t: TimeInterval = .center == animation ? 0.16125 : 0.325
switch animation { switch animation {
case .centerWithBacking, .backing, .pointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.animate(.backgroundColor(color.withAlphaComponent(opacity / 2)), .duration(duration)) bLayer.animate(.background(color: color.withAlphaComponent(opacity / 2)), .duration(t))
default:break default:break
} }
switch animation { switch animation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking:
pLayer.animate(.scale(1), .duration(duration)) pLayer.animate(.scale(), .duration(t))
default:break default:break
} }
Motion.delay(duration) { Motion.delay(t) {
bLayer.setValue(true, forKey: "animated") bLayer.setValue(true, forKey: "animated")
} }
} }
...@@ -179,21 +179,22 @@ public struct Pulse { ...@@ -179,21 +179,22 @@ public struct Pulse {
return return
} }
let duration = 0.325 let t: TimeInterval = 0.325
switch animation { switch animation {
case .centerWithBacking, .backing, .pointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.animate(.backgroundColor(color.withAlphaComponent(0)), .duration(duration)) bLayer.animate(.background(color: color.withAlphaComponent(0)), .duration(t))
default:break default:break
} }
switch animation { switch animation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking:
pLayer.animate(.scale(.center == animation ? 1 : 1.325), .backgroundColor(color.withAlphaComponent(0))) let v: CGFloat = .center == animation ? 1 : 1.325
pLayer.animate(.scale(x: v, y: v, z: v), .background(color: color.withAlphaComponent(0)))
default:break default:break
} }
Motion.delay(duration) { Motion.delay(t) {
pLayer.removeFromSuperlayer() pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer() bLayer.removeFromSuperlayer()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment