Commit 8333cdd2 by Daniel Dahan

updated delegation calls in Material CollectionViewCell

parent 7fbb656d
......@@ -81,24 +81,42 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
*/
public override func prepareView() {
super.prepareView()
userInteractionEnabled = MaterialTheme.flatButton.userInteractionEnabled
backgroundColor = MaterialTheme.flatButton.backgroundColor
pulseColorOpacity = MaterialTheme.flatButton.pulseColorOpacity
pulseColor = MaterialTheme.flatButton.pulseColor
shadowDepth = MaterialTheme.flatButton.shadowDepth
shadowColor = MaterialTheme.flatButton.shadowColor
zPosition = MaterialTheme.flatButton.zPosition
cornerRadius = MaterialTheme.flatButton.cornerRadius
borderWidth = MaterialTheme.flatButton.borderWidth
borderColor = MaterialTheme.flatButton.bordercolor
shape = MaterialTheme.flatButton.shape
userInteractionEnabled = MaterialTheme.pulseCollectionView.userInteractionEnabled
backgroundColor = MaterialTheme.pulseCollectionView.backgroundColor
pulseColorOpacity = MaterialTheme.pulseCollectionView.pulseColorOpacity
pulseColor = MaterialTheme.pulseCollectionView.pulseColor
shadowDepth = MaterialTheme.pulseCollectionView.shadowDepth
shadowColor = MaterialTheme.pulseCollectionView.shadowColor
zPosition = MaterialTheme.pulseCollectionView.zPosition
borderWidth = MaterialTheme.pulseCollectionView.borderWidth
borderColor = MaterialTheme.pulseCollectionView.bordercolor
masksToBounds = true
prepareLeftLayer()
prepareRightLayer()
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
//
......@@ -124,7 +142,6 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
addGestureRecognizer(panRecognizer)
}
//
// :name: handlePanGesture
//
......@@ -132,7 +149,7 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
switch recognizer.state {
case .Began:
originalPosition = position
masksToBounds = false
rightOnDragRelease = x < -width / 2
leftOnDragRelease = x > width / 2
......@@ -162,16 +179,9 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
case .Ended:
revealed = false
// snap back
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
}
}
......
......@@ -256,6 +256,8 @@ public extension MaterialTheme.pulseCollectionView {
// color
public static var backgroundColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.blueGrey.lighten4
public static var pulseColorOpacity: CGFloat = 0.25
// interaction
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