Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
2017544d
Commit
2017544d
authored
Oct 10, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added delgation methods for MaterialCollectionViewCell
parent
6f3a9732
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
15 deletions
+52
-15
Source/MaterialAnimation.swift
+1
-1
Source/MaterialButton.swift
+3
-3
Source/MaterialCollectionViewCell.swift
+41
-7
Source/MaterialLayer.swift
+4
-1
Source/MaterialView.swift
+3
-3
No files found.
Source/MaterialAnimation.swift
View file @
2017544d
...
...
@@ -19,7 +19,7 @@
import
UIKit
@objc(MaterialAnimationDelegate)
public
protocol
MaterialAnimationDelegate
{
public
protocol
MaterialAnimationDelegate
:
MaterialDelegate
{
/**
:name: materialAnimationDidStart
*/
...
...
Source/MaterialButton.swift
View file @
2017544d
...
...
@@ -33,7 +33,7 @@ public class MaterialButton : UIButton {
/**
:name: delegate
*/
public
weak
var
delegate
:
Material
Animation
Delegate
?
public
weak
var
delegate
:
MaterialDelegate
?
/**
:name: pulseScale
...
...
@@ -355,7 +355,7 @@ public class MaterialButton : UIButton {
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
delegate
?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStart
?(
anim
)
}
/**
...
...
@@ -368,7 +368,7 @@ public class MaterialButton : UIButton {
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
}
delegate
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
Source/MaterialCollectionViewCell.swift
View file @
2017544d
...
...
@@ -18,6 +18,17 @@
import
UIKit
@objc(MaterialCollectionViewCellDelegate)
public
protocol
MaterialCollectionViewCellDelegate
:
MaterialDelegate
{
optional
func
materialCollectionViewCellWillRevealLeftLayer
(
cell
:
MaterialCollectionViewCell
)
optional
func
materialCollectionViewCellWillRevealRightLayer
(
cell
:
MaterialCollectionViewCell
)
optional
func
materialCollectionViewCellDidRevealLeftLayer
(
cell
:
MaterialCollectionViewCell
)
optional
func
materialCollectionViewCellDidRevealRightLayer
(
cell
:
MaterialCollectionViewCell
)
optional
func
materialCollectionViewCellDidCloseLeftLayer
(
cell
:
MaterialCollectionViewCell
)
optional
func
materialCollectionViewCellDidCloseRightLayer
(
cell
:
MaterialCollectionViewCell
)
}
@objc(MaterialCollectionViewCell)
public
class
MaterialCollectionViewCell
:
UICollectionViewCell
,
UIGestureRecognizerDelegate
{
//
// :name: panRecognizer
...
...
@@ -50,9 +61,14 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: revealed
*/
public
private(set)
lazy
var
revealed
:
Bool
=
false
/**
:name: delegate
*/
public
weak
var
delegate
:
Material
Animation
Delegate
?
public
weak
var
delegate
:
MaterialDelegate
?
/**
:name: pulseScale
...
...
@@ -341,7 +357,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
delegate
?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStart
?(
anim
)
}
/**
...
...
@@ -354,7 +370,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
}
delegate
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
@@ -477,17 +493,35 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
rightOnDragRelease
=
x
<
-
width
/
2
leftOnDragRelease
=
x
>
width
/
2
if
!
revealed
&&
(
leftOnDragRelease
||
rightOnDragRelease
)
{
revealed
=
true
if
leftOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellWillRevealLeftLayer
?(
self
)
}
else
if
rightOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellWillRevealRightLayer
?(
self
)
}
}
if
leftOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellDidRevealLeftLayer
?(
self
)
}
else
if
rightOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellDidRevealRightLayer
?(
self
)
}
case
.
Ended
:
revealed
=
false
// snap back
let
a
:
CABasicAnimation
=
MaterialAnimation
.
position
(
CGPointMake
(
width
/
2
,
y
+
height
/
2
),
duration
:
0.25
)
a
.
timingFunction
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
animation
(
a
)
if
righ
tOnDragRelease
{
}
else
if
lef
tOnDragRelease
{
if
lef
tOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellDidCloseLeftLayer
?(
self
)
}
else
if
righ
tOnDragRelease
{
(
delegate
as?
MaterialCollectionViewCellDelegate
)?
.
materialCollectionViewCellDidCloseRightLayer
?(
self
)
}
default
:
break
}
...
...
Source/MaterialLayer.swift
View file @
2017544d
...
...
@@ -18,6 +18,9 @@
import
UIKit
@objc(MaterialDelegate)
public
protocol
MaterialDelegate
{}
@objc(MaterialLayer)
public
class
MaterialLayer
:
CAShapeLayer
{
/**
...
...
@@ -244,7 +247,7 @@ public class MaterialLayer : CAShapeLayer {
public
func
animation
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
if
let
a
:
CABasicAnimation
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentationLayer
()
?
self
:
presentationLayer
()
as!
CALayer
)
.
valueForKeyPath
(
a
.
keyPath
!
)
a
.
fromValue
=
valueForKeyPath
(
a
.
keyPath
!
)
//
(nil == presentationLayer() ? self : presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
}
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
addAnimation
(
a
,
forKey
:
a
.
keyPath
!
)
...
...
Source/MaterialView.swift
View file @
2017544d
...
...
@@ -28,7 +28,7 @@ public class MaterialView : UIView {
/**
:name: visualLayer
*/
public
weak
var
delegate
:
Material
Animation
Delegate
?
public
weak
var
delegate
:
MaterialDelegate
?
/**
:name: image
...
...
@@ -347,7 +347,7 @@ public class MaterialView : UIView {
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
delegate
?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStart
?(
anim
)
}
/**
...
...
@@ -360,7 +360,7 @@ public class MaterialView : UIView {
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
}
delegate
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
(
delegate
as?
MaterialAnimationDelegate
)
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment