Commit 4e2e0f24 by danieldahan

updated to latest

parent 9a2e6a45
......@@ -20,14 +20,14 @@ import UIKit
public class BasicCollectionViewCell : MaterialPanCollectionViewCell {
/**
:name: titleLayer
:name: titleLabel
*/
public private(set) lazy var titleLayer: MaterialTextLayer = MaterialTextLayer()
public private(set) lazy var titleLabel: MaterialLabel = MaterialLabel()
/**
:name: detailLayer
:name: detailLabel
*/
public private(set) lazy var detailLayer: MaterialTextLayer = MaterialTextLayer()
public private(set) lazy var detailLabel: MaterialLabel = MaterialLabel()
/**
:name: prepareView
......@@ -36,9 +36,9 @@ public class BasicCollectionViewCell : MaterialPanCollectionViewCell {
super.prepareView()
// title
layer.addSublayer(titleLayer)
addSubview(titleLabel)
// detail
layer.addSublayer(detailLayer)
addSubview(detailLabel)
}
}
\ No newline at end of file
......@@ -364,9 +364,9 @@ public class MaterialButton : UIButton {
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
})
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
......@@ -393,12 +393,12 @@ public class MaterialButton : UIButton {
let t: CFTimeInterval = 0.25
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.pulseLayer.hidden = false
self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point
self.pulseLayer.cornerRadius = r / d
})
}
pulseLayer.addAnimation(MaterialAnimation.scale(pulseFill ? 3 * d : 1.5 * d, duration: t), forKey: nil)
}
......@@ -416,9 +416,9 @@ public class MaterialButton : UIButton {
if spotlight {
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if layer.containsPoint(point) {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.pulseLayer.position = point
})
}
}
}
}
......
......@@ -254,9 +254,9 @@ public class MaterialLayer : CAShapeLayer {
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
})
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
removeAnimationForKey(a.keyPath!)
......
......@@ -51,14 +51,14 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
private lazy var rightOnDragRelease: Bool = false
/**
:name: leftLayer
:name: leftView
*/
public private(set) lazy var leftLayer: MaterialLayer = MaterialLayer()
public private(set) lazy var leftView: MaterialView = MaterialView()
/**
:name: rightLayer
:name: rightView
*/
public private(set) lazy var rightLayer: MaterialLayer = MaterialLayer()
public private(set) lazy var rightView: MaterialView = MaterialView()
/**
:name: revealed
......@@ -66,6 +66,11 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
public private(set) lazy var revealed: Bool = false
/**
:name: closeAutomatically
*/
public lazy var closeAutomatically: Bool = true
/**
:name: gestureRecognizerShouldBegin
*/
public override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
......@@ -94,8 +99,8 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
borderColor = MaterialTheme.pulseCollectionView.bordercolor
masksToBounds = true
prepareLeftLayer()
prepareRightLayer()
prepareLeftView()
prepareRightView()
preparePanGesture()
}
......@@ -117,20 +122,27 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
}
}
/**
:name: close
*/
public func close() {
animation(MaterialAnimation.position(CGPointMake(width / 2, y + height / 2), duration: 0.25))
}
//
// :name: prepareLeftLayer
// :name: prepareLeftView
//
internal func prepareLeftLayer() {
leftLayer.frame = CGRectMake(-width, 0, width, height)
layer.addSublayer(leftLayer)
internal func prepareLeftView() {
leftView.frame = CGRectMake(-width, 0, width, height)
addSubview(leftView)
}
//
// :name: prepareRightLayer
// :name: prepareRightView
//
internal func prepareRightLayer() {
rightLayer.frame = CGRectMake(width, 0, width, height)
layer.addSublayer(rightLayer)
internal func prepareRightView() {
rightView.frame = CGRectMake(width, 0, width, height)
addSubview(rightView)
}
//
......@@ -150,17 +162,17 @@ public class MaterialPanCollectionViewCell : MaterialPulseCollectionViewCell, UI
case .Began:
originalPosition = position
masksToBounds = false
rightOnDragRelease = x < -width / 2
leftOnDragRelease = x > width / 2
rightOnDragRelease = x < -width / 2
case .Changed:
let translation = recognizer.translationInView(self)
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.position.x = self.originalPosition.x + translation.x
})
}
rightOnDragRelease = x < -width / 2
leftOnDragRelease = x > width / 2
rightOnDragRelease = x < -width / 2
if !revealed && (leftOnDragRelease || rightOnDragRelease) {
revealed = true
......@@ -180,7 +192,11 @@ 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 || !rightOnDragRelease {
close()
} else if closeAutomatically && (leftOnDragRelease || rightOnDragRelease) {
close()
}
default:break
}
......
......@@ -385,9 +385,9 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
})
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
......@@ -411,9 +411,9 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
let t: CFTimeInterval = 0.25
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.pulseLayer.bounds = CGRectMake(0, 0, 2 * w, 2 * h)
})
}
MaterialAnimation.animationWithDuration(t, animations: {
self.pulseLayer.hidden = false
})
......
......@@ -84,12 +84,12 @@ public class MaterialPulseView : MaterialView {
let t: CFTimeInterval = 0.25
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.pulseLayer.hidden = false
self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point
self.pulseLayer.cornerRadius = r / d
})
}
pulseLayer.addAnimation(MaterialAnimation.scale(pulseFill ? 3 * d : d, duration: t), forKey: nil)
}
......@@ -107,9 +107,9 @@ public class MaterialPulseView : MaterialView {
if spotlight {
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if layer.containsPoint(point) {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.pulseLayer.position = point
})
}
}
}
}
......
......@@ -101,10 +101,10 @@ public class MaterialView : UIView {
*/
public var x: CGFloat {
get {
return frame.origin.x
return layer.frame.origin.x
}
set(value) {
frame.origin.x = value
layer.frame.origin.x = value
}
}
......@@ -365,9 +365,9 @@ public class MaterialView : UIView {
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled {
self.layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
})
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
......
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