Commit 8333cdd2 by Daniel Dahan

updated delegation calls in Material CollectionViewCell

parent 7fbb656d
...@@ -81,24 +81,42 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI ...@@ -81,24 +81,42 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
userInteractionEnabled = MaterialTheme.flatButton.userInteractionEnabled
backgroundColor = MaterialTheme.flatButton.backgroundColor userInteractionEnabled = MaterialTheme.pulseCollectionView.userInteractionEnabled
pulseColorOpacity = MaterialTheme.flatButton.pulseColorOpacity backgroundColor = MaterialTheme.pulseCollectionView.backgroundColor
pulseColor = MaterialTheme.flatButton.pulseColor pulseColorOpacity = MaterialTheme.pulseCollectionView.pulseColorOpacity
pulseColor = MaterialTheme.pulseCollectionView.pulseColor
shadowDepth = MaterialTheme.flatButton.shadowDepth
shadowColor = MaterialTheme.flatButton.shadowColor shadowDepth = MaterialTheme.pulseCollectionView.shadowDepth
zPosition = MaterialTheme.flatButton.zPosition shadowColor = MaterialTheme.pulseCollectionView.shadowColor
cornerRadius = MaterialTheme.flatButton.cornerRadius zPosition = MaterialTheme.pulseCollectionView.zPosition
borderWidth = MaterialTheme.flatButton.borderWidth borderWidth = MaterialTheme.pulseCollectionView.borderWidth
borderColor = MaterialTheme.flatButton.bordercolor borderColor = MaterialTheme.pulseCollectionView.bordercolor
shape = MaterialTheme.flatButton.shape masksToBounds = true
prepareLeftLayer() prepareLeftLayer()
prepareRightLayer() prepareRightLayer()
preparePanGesture() preparePanGesture()
} }
/**
:name: animationDidStop
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
super.animationDidStop(anim, finished: flag)
if let a: CABasicAnimation = anim as? CABasicAnimation {
if "position" == a.keyPath {
masksToBounds = true
if leftOnDragRelease {
(delegate as? MaterialPanCollectionViewCellDelegate)?.materialCollectionViewCellDidCloseLeftLayer?(self)
} else if rightOnDragRelease {
(delegate as? MaterialPanCollectionViewCellDelegate)?.materialCollectionViewCellDidCloseRightLayer?(self)
}
}
}
}
// //
// :name: prepareLeftLayer // :name: prepareLeftLayer
// //
...@@ -124,7 +142,6 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI ...@@ -124,7 +142,6 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
addGestureRecognizer(panRecognizer) addGestureRecognizer(panRecognizer)
} }
// //
// :name: handlePanGesture // :name: handlePanGesture
// //
...@@ -132,7 +149,7 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI ...@@ -132,7 +149,7 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
switch recognizer.state { switch recognizer.state {
case .Began: case .Began:
originalPosition = position originalPosition = position
masksToBounds = false
rightOnDragRelease = x < -width / 2 rightOnDragRelease = x < -width / 2
leftOnDragRelease = x > width / 2 leftOnDragRelease = x > width / 2
...@@ -162,16 +179,9 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI ...@@ -162,16 +179,9 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
case .Ended: case .Ended:
revealed = false revealed = false
// snap back // snap back
animation(MaterialAnimation.position(CGPointMake(width / 2, y + height / 2), duration: 0.25)) animation(MaterialAnimation.position(CGPointMake(width / 2, y + height / 2), duration: 0.25))
if leftOnDragRelease {
(delegate as? MaterialPanCollectionViewCellDelegate)?.materialCollectionViewCellDidCloseLeftLayer?(self)
} else if rightOnDragRelease {
(delegate as? MaterialPanCollectionViewCellDelegate)?.materialCollectionViewCellDidCloseRightLayer?(self)
}
default:break default:break
} }
} }
......
...@@ -256,6 +256,8 @@ public extension MaterialTheme.pulseCollectionView { ...@@ -256,6 +256,8 @@ public extension MaterialTheme.pulseCollectionView {
// color // color
public static var backgroundColor: UIColor = MaterialColor.white public static var backgroundColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.blueGrey.lighten4
public static var pulseColorOpacity: CGFloat = 0.25
// interaction // interaction
public static var userInteractionEnabled: Bool = true public static var userInteractionEnabled: Bool = true
......
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