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
9756078e
Unverified
Commit
9756078e
authored
Sep 23, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added Pulse object to replace pulse behavior
parent
10bbe53e
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
144 additions
and
136 deletions
+144
-136
Examples/Programmatic/Bar/Bar/ViewController.swift
+2
-2
Examples/Programmatic/Button/Button/ViewController.swift
+1
-1
Examples/Programmatic/Card/Card/ViewController.swift
+1
-1
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
+1
-1
Examples/Programmatic/NavigationController/NavigationController/RootViewController.swift
+1
-1
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryCollectionReusableView.swift
+1
-1
Examples/Programmatic/SnackbarController/SnackbarController/RootViewController.swift
+1
-1
Examples/Programmatic/TabBar/TabBar/ViewController.swift
+3
-3
Material.xcodeproj/project.pbxproj
+14
-2
Sources/iOS/Button.swift
+9
-19
Sources/iOS/CollectionReusableView.swift
+9
-19
Sources/iOS/CollectionViewCell.swift
+8
-18
Sources/iOS/Divider.swift
+1
-1
Sources/iOS/FabButton.swift
+2
-2
Sources/iOS/IconButton.swift
+1
-1
Sources/iOS/PageTabBarController.swift
+1
-1
Sources/iOS/Pulse.swift
+47
-0
Sources/iOS/PulseAnimation.swift
+24
-25
Sources/iOS/PulseView.swift
+7
-17
Sources/iOS/Switch.swift
+1
-1
Sources/iOS/TableViewCell.swift
+7
-17
Sources/iOS/TextField.swift
+2
-2
No files found.
Examples/Programmatic/Bar/Bar/ViewController.swift
View file @
9756078e
...
@@ -58,12 +58,12 @@ class ViewController: UIViewController {
...
@@ -58,12 +58,12 @@ class ViewController: UIViewController {
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
white
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
white
)
favoriteButton
.
pulse
C
olor
=
Color
.
white
favoriteButton
.
pulse
.
c
olor
=
Color
.
white
}
}
private
func
prepareShareButton
()
{
private
func
prepareShareButton
()
{
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
white
)
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
white
)
shareButton
.
pulse
C
olor
=
Color
.
white
shareButton
.
pulse
.
c
olor
=
Color
.
white
}
}
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
...
...
Examples/Programmatic/Button/Button/ViewController.swift
View file @
9756078e
...
@@ -80,7 +80,7 @@ class ViewController: UIViewController {
...
@@ -80,7 +80,7 @@ class ViewController: UIViewController {
private
func
prepareRaisedButton
()
{
private
func
prepareRaisedButton
()
{
let
button
=
RaisedButton
(
title
:
"Raised Button"
,
titleColor
:
Color
.
white
)
let
button
=
RaisedButton
(
title
:
"Raised Button"
,
titleColor
:
Color
.
white
)
button
.
pulse
C
olor
=
Color
.
white
button
.
pulse
.
c
olor
=
Color
.
white
button
.
backgroundColor
=
Color
.
blue
.
base
button
.
backgroundColor
=
Color
.
blue
.
base
view
.
layout
(
button
)
view
.
layout
(
button
)
...
...
Examples/Programmatic/Card/Card/ViewController.swift
View file @
9756078e
...
@@ -64,7 +64,7 @@ class ViewController: UIViewController {
...
@@ -64,7 +64,7 @@ class ViewController: UIViewController {
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
blue
.
base
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
blue
.
base
)
favoriteButton
.
pulse
C
olor
=
Color
.
blue
.
base
favoriteButton
.
pulse
.
c
olor
=
Color
.
blue
.
base
}
}
private
func
prepareBottomBar
()
{
private
func
prepareBottomBar
()
{
...
...
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
View file @
9756078e
...
@@ -81,7 +81,7 @@ class ViewController: UIViewController {
...
@@ -81,7 +81,7 @@ class ViewController: UIViewController {
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
grey
.
base
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
grey
.
base
)
favoriteButton
.
pulse
C
olor
=
Color
.
grey
.
base
favoriteButton
.
pulse
.
c
olor
=
Color
.
grey
.
base
}
}
private
func
prepareBottomBar
()
{
private
func
prepareBottomBar
()
{
...
...
Examples/Programmatic/NavigationController/NavigationController/RootViewController.swift
View file @
9756078e
...
@@ -77,7 +77,7 @@ class RootViewController: UIViewController {
...
@@ -77,7 +77,7 @@ class RootViewController: UIViewController {
private
func
prepareNextButton
()
{
private
func
prepareNextButton
()
{
nextButton
=
FlatButton
()
nextButton
=
FlatButton
()
nextButton
.
pulse
A
nimation
=
.
none
nextButton
.
pulse
.
a
nimation
=
.
none
nextButton
.
addTarget
(
self
,
action
:
#selector(
handleNextButton
)
,
for
:
.
touchUpInside
)
nextButton
.
addTarget
(
self
,
action
:
#selector(
handleNextButton
)
,
for
:
.
touchUpInside
)
view
.
layout
(
nextButton
)
.
edges
()
view
.
layout
(
nextButton
)
.
edges
()
}
}
...
...
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryCollectionReusableView.swift
View file @
9756078e
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
PhotoLibraryCollectionViewCell
:
CollectionViewCell
{
class
PhotoLibraryCollectionViewCell
:
CollectionViewCell
{
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
pulse
A
nimation
=
.
backing
pulse
.
a
nimation
=
.
backing
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
}
}
}
}
Examples/Programmatic/SnackbarController/SnackbarController/RootViewController.swift
View file @
9756078e
...
@@ -51,7 +51,7 @@ class RootViewController: UIViewController {
...
@@ -51,7 +51,7 @@ class RootViewController: UIViewController {
private
func
prepareUndoButton
()
{
private
func
prepareUndoButton
()
{
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
Color
.
yellow
.
base
)
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
Color
.
yellow
.
base
)
undoButton
.
pulse
A
nimation
=
.
backing
undoButton
.
pulse
.
a
nimation
=
.
backing
undoButton
.
titleLabel
?
.
font
=
RobotoFont
.
regular
(
with
:
14
)
undoButton
.
titleLabel
?
.
font
=
RobotoFont
.
regular
(
with
:
14
)
}
}
...
...
Examples/Programmatic/TabBar/TabBar/ViewController.swift
View file @
9756078e
...
@@ -48,15 +48,15 @@ class ViewController: UIViewController {
...
@@ -48,15 +48,15 @@ class ViewController: UIViewController {
private
func
prepareButtons
()
{
private
func
prepareButtons
()
{
let
btn1
=
FlatButton
(
title
:
"Library"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn1
=
FlatButton
(
title
:
"Library"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn1
.
pulse
A
nimation
=
.
none
btn1
.
pulse
.
a
nimation
=
.
none
buttons
.
append
(
btn1
)
buttons
.
append
(
btn1
)
let
btn2
=
FlatButton
(
title
:
"Photo"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn2
=
FlatButton
(
title
:
"Photo"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn2
.
pulse
A
nimation
=
.
none
btn2
.
pulse
.
a
nimation
=
.
none
buttons
.
append
(
btn2
)
buttons
.
append
(
btn2
)
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn3
.
pulse
A
nimation
=
.
none
btn3
.
pulse
.
a
nimation
=
.
none
buttons
.
append
(
btn3
)
buttons
.
append
(
btn3
)
}
}
...
...
Material.xcodeproj/project.pbxproj
View file @
9756078e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
962864621D54111D00690B69
/* JSON.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962864611D54111D00690B69
/* JSON.swift */
;
};
962864621D54111D00690B69
/* JSON.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962864611D54111D00690B69
/* JSON.swift */
;
};
962864631D54111D00690B69
/* JSON.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962864611D54111D00690B69
/* JSON.swift */
;
};
962864631D54111D00690B69
/* JSON.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962864611D54111D00690B69
/* JSON.swift */
;
};
9631A7C11D95E3AC00CFB109
/* PresenterCard.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
;
};
9631A7C11D95E3AC00CFB109
/* PresenterCard.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
;
};
9631A7C71D95E5D900CFB109
/* Pulse.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9631A7C61D95E5D900CFB109
/* Pulse.swift */
;
};
96334EF61C8B84660083986B
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EF51C8B84660083986B
/* Assets.xcassets */
;
};
96334EF61C8B84660083986B
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EF51C8B84660083986B
/* Assets.xcassets */
;
};
963832421B88DFD80015F710
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* Material.framework */
;
};
963832421B88DFD80015F710
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* Material.framework */
;
};
963FBEFD1D669510008F8512
/* Snackbar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963FBEFC1D669510008F8512
/* Snackbar.swift */
;
};
963FBEFD1D669510008F8512
/* Snackbar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963FBEFC1D669510008F8512
/* Snackbar.swift */
;
};
...
@@ -228,6 +229,7 @@
...
@@ -228,6 +229,7 @@
9628645E1D540AF300690B69
/* DynamicFontType.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DynamicFontType.swift
;
sourceTree
=
"<group>"
;
};
9628645E1D540AF300690B69
/* DynamicFontType.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DynamicFontType.swift
;
sourceTree
=
"<group>"
;
};
962864611D54111D00690B69
/* JSON.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
JSON.swift
;
sourceTree
=
"<group>"
;
};
962864611D54111D00690B69
/* JSON.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
JSON.swift
;
sourceTree
=
"<group>"
;
};
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PresenterCard.swift
;
sourceTree
=
"<group>"
;
};
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PresenterCard.swift
;
sourceTree
=
"<group>"
;
};
9631A7C61D95E5D900CFB109
/* Pulse.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Pulse.swift
;
sourceTree
=
"<group>"
;
};
96334EF51C8B84660083986B
/* Assets.xcassets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder.assetcatalog
;
path
=
Assets.xcassets
;
sourceTree
=
"<group>"
;
};
96334EF51C8B84660083986B
/* Assets.xcassets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder.assetcatalog
;
path
=
Assets.xcassets
;
sourceTree
=
"<group>"
;
};
963832361B88DFD80015F710
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Material.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832361B88DFD80015F710
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Material.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832411B88DFD80015F710
/* Material.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
Material.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832411B88DFD80015F710
/* Material.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
Material.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
...
@@ -414,6 +416,16 @@
...
@@ -414,6 +416,16 @@
name
=
BottomTabBar
;
name
=
BottomTabBar
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
9631A7C51D95E5C400CFB109
/* Pulse */
=
{
isa
=
PBXGroup
;
children
=
(
9631A7C61D95E5D900CFB109
/* Pulse.swift */
,
96BCB7841CB40DC500C806FE
/* PulseView.swift */
,
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
,
);
name
=
Pulse
;
sourceTree
=
"<group>"
;
};
9638322C1B88DFD80015F710
=
{
9638322C1B88DFD80015F710
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -561,6 +573,7 @@
...
@@ -561,6 +573,7 @@
96BCB8011CB40F1700C806FE
/* Navigation */
,
96BCB8011CB40F1700C806FE
/* Navigation */
,
962DDD071D6FBBB7001C307C
/* Page */
,
962DDD071D6FBBB7001C307C
/* Page */
,
96EA9A411D4E68E60052C74D
/* PhotoLibrary */
,
96EA9A411D4E68E60052C74D
/* PhotoLibrary */
,
9631A7C51D95E5C400CFB109
/* Pulse */
,
96264BE51D833CFF00576F37
/* Reminders */
,
96264BE51D833CFF00576F37
/* Reminders */
,
963FBF031D6696EF008F8512
/* SearchBar */
,
963FBF031D6696EF008F8512
/* SearchBar */
,
963FBEFB1D6694E8008F8512
/* Snackbar */
,
963FBEFB1D6694E8008F8512
/* Snackbar */
,
...
@@ -710,7 +723,6 @@
...
@@ -710,7 +723,6 @@
96BCB76D1CB40DC500C806FE
/* Animation.swift */
,
96BCB76D1CB40DC500C806FE
/* Animation.swift */
,
96BCB78B1CB40DC500C806FE
/* TransitionAnimation.swift */
,
96BCB78B1CB40DC500C806FE
/* TransitionAnimation.swift */
,
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
,
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
,
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
,
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
,
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
,
);
);
name
=
Animation
;
name
=
Animation
;
...
@@ -743,7 +755,6 @@
...
@@ -743,7 +755,6 @@
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB78C1CB40DC500C806FE
/* View.swift */
,
96BCB78C1CB40DC500C806FE
/* View.swift */
,
96BCB7841CB40DC500C806FE
/* PulseView.swift */
,
);
);
name
=
View
;
name
=
View
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -1103,6 +1114,7 @@
...
@@ -1103,6 +1114,7 @@
96BCB7C81CB40DC500C806FE
/* Label.swift in Sources */
,
96BCB7C81CB40DC500C806FE
/* Label.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* CollectionViewDelegate.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* CollectionViewDelegate.swift in Sources */
,
9631A7C71D95E5D900CFB109
/* Pulse.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
...
...
Sources/iOS/Button.swift
View file @
9756078e
...
@@ -40,19 +40,9 @@ open class Button: UIButton {
...
@@ -40,19 +40,9 @@ open class Button: UIButton {
*/
*/
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
/// An Array of pulse layers.
/// A Pulse reference.
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
@IBInspectable
open
internal(set)
lazy
var
pulse
:
Pulse
=
Pulse
()
/// The opacity value for the pulse animation.
@IBInspectable
open
var
pulseOpacity
:
CGFloat
=
0.25
/// The color of the pulse effect.
@IBInspectable
open
var
pulseColor
=
Color
.
grey
.
base
/// The type of PulseAnimation.
public
var
pulseAnimation
=
PulseAnimation
.
pointWithBacking
/// A property that accesses the backing layer's backgroundColor.
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
@IBInspectable
...
@@ -178,13 +168,13 @@ open class Button: UIButton {
...
@@ -178,13 +168,13 @@ open class Button: UIButton {
from the center.
from the center.
*/
*/
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
p
,
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
p
,
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
Color
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
}
}
...
@@ -196,7 +186,7 @@ open class Button: UIButton {
...
@@ -196,7 +186,7 @@ open class Button: UIButton {
*/
*/
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -207,7 +197,7 @@ open class Button: UIButton {
...
@@ -207,7 +197,7 @@ open class Button: UIButton {
*/
*/
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
with
:
event
)
super
.
touchesEnded
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -218,7 +208,7 @@ open class Button: UIButton {
...
@@ -218,7 +208,7 @@ open class Button: UIButton {
*/
*/
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
with
:
event
)
super
.
touchesCancelled
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
...
Sources/iOS/CollectionReusableView.swift
View file @
9756078e
...
@@ -40,19 +40,9 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -40,19 +40,9 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
/// An Array of pulse layers.
/// A Pulse reference.
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
@IBInspectable
open
internal(set)
lazy
var
pulse
:
Pulse
=
Pulse
()
/// The opcaity value for the pulse animation.
@IBInspectable
open
var
pulseOpacity
:
CGFloat
=
0.25
/// The color of the pulse effect.
@IBInspectable
open
var
pulseColor
=
Color
.
grey
.
base
/// The type of PulseAnimation.
open
var
pulseAnimation
=
PulseAnimation
.
pointWithBacking
/**
/**
A property that manages an image for the visualLayer's contents
A property that manages an image for the visualLayer's contents
...
@@ -216,12 +206,12 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -216,12 +206,12 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
p
,
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
p
,
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
Color
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
}
}
...
@@ -233,7 +223,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -233,7 +223,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -244,7 +234,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -244,7 +234,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
with
:
event
)
super
.
touchesEnded
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -255,7 +245,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -255,7 +245,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
with
:
event
)
super
.
touchesCancelled
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -267,7 +257,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -267,7 +257,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
pulse
A
nimation
=
.
none
pulse
.
a
nimation
=
.
none
prepareVisualLayer
()
prepareVisualLayer
()
}
}
...
...
Sources/iOS/CollectionViewCell.swift
View file @
9756078e
...
@@ -43,19 +43,9 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -43,19 +43,9 @@ open class CollectionViewCell: UICollectionViewCell {
*/
*/
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
/// An Array of pulse layers.
/// A Pulse reference.
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
@IBInspectable
open
internal(set)
lazy
var
pulse
:
Pulse
=
Pulse
()
/// The opcaity value for the pulse animation.
@IBInspectable
open
var
pulseOpacity
:
CGFloat
=
0.25
/// The color of the pulse effect.
@IBInspectable
open
var
pulseColor
=
Color
.
grey
.
base
/// The type of PulseAnimation.
open
var
pulseAnimation
=
PulseAnimation
.
pointWithBacking
/**
/**
A property that manages an image for the visualLayer's contents
A property that manages an image for the visualLayer's contents
...
@@ -226,12 +216,12 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -226,12 +216,12 @@ open class CollectionViewCell: UICollectionViewCell {
*/
*/
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
p
,
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
p
,
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
Color
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
}
}
...
@@ -243,7 +233,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -243,7 +233,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/
*/
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -254,7 +244,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -254,7 +244,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/
*/
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
with
:
event
)
super
.
touchesEnded
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -265,7 +255,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -265,7 +255,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/
*/
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
with
:
event
)
super
.
touchesCancelled
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
...
Sources/iOS/Divider.swift
View file @
9756078e
...
@@ -48,7 +48,7 @@ open class Divider {
...
@@ -48,7 +48,7 @@ open class Divider {
/// A reference to the height.
/// A reference to the height.
public
var
height
:
CGFloat
public
var
height
:
CGFloat
///
Divider c
olor.
///
A UIC
olor.
open
var
color
:
UIColor
?
{
open
var
color
:
UIColor
?
{
get
{
get
{
return
line
?
.
backgroundColor
return
line
?
.
backgroundColor
...
...
Sources/iOS/FabButton.swift
View file @
9756078e
...
@@ -42,8 +42,8 @@ open class FabButton: Button {
...
@@ -42,8 +42,8 @@ open class FabButton: Button {
super
.
prepare
()
super
.
prepare
()
depthPreset
=
.
depth1
depthPreset
=
.
depth1
shapePreset
=
.
circle
shapePreset
=
.
circle
pulse
A
nimation
=
.
centerWithBacking
pulse
.
a
nimation
=
.
centerWithBacking
pulse
C
olor
=
Color
.
white
pulse
.
c
olor
=
Color
.
white
tintColor
=
Color
.
white
tintColor
=
Color
.
white
backgroundColor
=
Color
.
red
.
base
backgroundColor
=
Color
.
red
.
base
}
}
...
...
Sources/iOS/IconButton.swift
View file @
9756078e
...
@@ -40,6 +40,6 @@ open class IconButton: Button {
...
@@ -40,6 +40,6 @@ open class IconButton: Button {
*/
*/
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
pulse
A
nimation
=
.
center
pulse
.
a
nimation
=
.
center
}
}
}
}
Sources/iOS/PageTabBarController.swift
View file @
9756078e
...
@@ -36,7 +36,7 @@ private var PageTabBarItemKey: UInt8 = 0
...
@@ -36,7 +36,7 @@ private var PageTabBarItemKey: UInt8 = 0
open
class
PageTabBarItem
:
FlatButton
{
open
class
PageTabBarItem
:
FlatButton
{
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
pulse
A
nimation
=
.
none
pulse
.
a
nimation
=
.
none
}
}
}
}
...
...
Sources/iOS/Pulse.swift
0 → 100644
View file @
9756078e
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
open
class
Pulse
{
/// An Array of layers.
internal
lazy
var
layers
=
[
CAShapeLayer
]()
/// A UIColor.
@IBInspectable
open
var
color
=
Color
.
grey
.
base
/// A reference to the PulseAnimation.
open
var
animation
=
PulseAnimation
.
pointWithBacking
/// The opcaity value for the pulse animation.
@IBInspectable
open
var
opacity
:
CGFloat
=
0.18
}
Sources/iOS/PulseAnimation.swift
View file @
9756078e
...
@@ -46,35 +46,34 @@ internal extension Animation {
...
@@ -46,35 +46,34 @@ internal extension Animation {
/**
/**
Triggers the expanding animation.
Triggers the expanding animation.
- Parameter layer: Container CALayer.
- Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer.
- Parameter visualLayer: A CAShapeLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from.
- Parameter point: A point to pulse from.
- Parameter width: Container width.
- Parameter width: Container width.
- Parameter height: Container height.
- Parameter height: Container height.
- Parameter duration: Animation duration.
- Parameter duration: Animation duration.
- Parameter pulse
Layers: An Array of CAShapeLayers used in the animation
.
- Parameter pulse
: A Pulse instance
.
*/
*/
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
p
ulseColor
:
UIColor
,
pulseOpacity
:
CGFloat
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
pulseLayers
:
inout
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
p
oint
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
pulse
:
inout
Pulse
)
{
guard
.
none
!=
pulse
A
nimation
else
{
guard
.
none
!=
pulse
.
a
nimation
else
{
return
return
}
}
let
n
=
.
center
==
pulse
A
nimation
?
width
<
height
?
width
:
height
:
width
<
height
?
height
:
width
let
n
=
.
center
==
pulse
.
a
nimation
?
width
<
height
?
width
:
height
:
width
<
height
?
height
:
width
let
bLayer
=
CAShapeLayer
()
let
bLayer
=
CAShapeLayer
()
let
pLayer
=
CAShapeLayer
()
let
pLayer
=
CAShapeLayer
()
bLayer
.
addSublayer
(
pLayer
)
bLayer
.
addSublayer
(
pLayer
)
pulse
L
ayers
.
insert
(
bLayer
,
at
:
0
)
pulse
.
l
ayers
.
insert
(
bLayer
,
at
:
0
)
visualLayer
.
addSublayer
(
bLayer
)
visualLayer
.
addSublayer
(
bLayer
)
visualLayer
.
masksToBounds
=
!
(
.
centerRadialBeyondBounds
==
pulse
Animation
||
.
radialBeyondBounds
==
pulseA
nimation
)
visualLayer
.
masksToBounds
=
!
(
.
centerRadialBeyondBounds
==
pulse
.
animation
||
.
radialBeyondBounds
==
pulse
.
a
nimation
)
Animation
.
animationDisabled
(
animations
:
{
Animation
.
animationDisabled
(
animations
:
{
[
visualLayer
=
visualLayer
,
pulse
=
pulse
]
in
bLayer
.
frame
=
visualLayer
.
bounds
bLayer
.
frame
=
visualLayer
.
bounds
pLayer
.
bounds
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
n
,
height
:
n
)
pLayer
.
bounds
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
n
,
height
:
n
)
switch
pulse
A
nimation
{
switch
pulse
.
a
nimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
:
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
:
pLayer
.
position
=
CGPoint
(
x
:
width
/
2
,
y
:
height
/
2
)
pLayer
.
position
=
CGPoint
(
x
:
width
/
2
,
y
:
height
/
2
)
default
:
default
:
...
@@ -82,21 +81,21 @@ internal extension Animation {
...
@@ -82,21 +81,21 @@ internal extension Animation {
}
}
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
backgroundColor
=
pulse
Color
.
withAlphaComponent
(
pulseO
pacity
)
.
cgColor
pLayer
.
backgroundColor
=
pulse
.
color
.
withAlphaComponent
(
pulse
.
o
pacity
)
.
cgColor
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransform
(
scaleX
:
0
,
y
:
0
))
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransform
(
scaleX
:
0
,
y
:
0
))
})
})
bLayer
.
setValue
(
false
,
forKey
:
"animated"
)
bLayer
.
setValue
(
false
,
forKey
:
"animated"
)
let
duration
:
CFTimeInterval
=
.
center
==
pulse
A
nimation
?
0.16125
:
0.325
let
duration
:
CFTimeInterval
=
.
center
==
pulse
.
a
nimation
?
0.16125
:
0.325
switch
pulse
A
nimation
{
switch
pulse
.
a
nimation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
bLayer
.
add
(
Animation
.
backgroundColor
(
color
:
pulse
Color
.
withAlphaComponent
(
pulseO
pacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
bLayer
.
add
(
Animation
.
backgroundColor
(
color
:
pulse
.
color
.
withAlphaComponent
(
pulse
.
o
pacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
default
:
break
}
}
switch
pulse
A
nimation
{
switch
pulse
.
a
nimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
radialBeyondBounds
,
.
point
,
.
pointWithBacking
:
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
radialBeyondBounds
,
.
point
,
.
pointWithBacking
:
pLayer
.
add
(
Animation
.
scale
(
scale
:
1
,
duration
:
duration
),
forKey
:
nil
)
pLayer
.
add
(
Animation
.
scale
(
scale
:
1
,
duration
:
duration
),
forKey
:
nil
)
default
:
break
default
:
break
...
@@ -110,11 +109,11 @@ internal extension Animation {
...
@@ -110,11 +109,11 @@ internal extension Animation {
/**
/**
Triggers the contracting animation.
Triggers the contracting animation.
- Parameter layer: Container CALayer.
- Parameter layer: Container CALayer.
- Parameter
pulseColor: The UIColor for the pulse
.
- Parameter
visualLayer: A CAShapeLayer
.
- Parameter pulse
Layers: An Array of CAShapeLayers used in the animation
.
- Parameter pulse
: A Pulse instance
.
*/
*/
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulse
Color
:
UIColor
,
pulseLayers
:
inout
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulse
:
inout
Pulse
)
{
guard
let
bLayer
=
pulse
L
ayers
.
popLast
()
else
{
guard
let
bLayer
=
pulse
.
l
ayers
.
popLast
()
else
{
return
return
}
}
...
@@ -122,24 +121,24 @@ internal extension Animation {
...
@@ -122,24 +121,24 @@ internal extension Animation {
return
return
}
}
Animation
.
delay
(
time
:
animated
?
0
:
0.15
)
{
Animation
.
delay
(
time
:
animated
?
0
:
0.15
)
{
[
pulse
=
pulse
]
in
guard
let
pLayer
=
bLayer
.
sublayers
?
.
first
as?
CAShapeLayer
else
{
guard
let
pLayer
=
bLayer
.
sublayers
?
.
first
as?
CAShapeLayer
else
{
return
return
}
}
let
duration
=
0.325
let
duration
=
0.325
switch
pulse
A
nimation
{
switch
pulse
.
a
nimation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
bLayer
.
add
(
Animation
.
backgroundColor
(
color
:
pulse
C
olor
.
withAlphaComponent
(
0
),
duration
:
duration
),
forKey
:
nil
)
bLayer
.
add
(
Animation
.
backgroundColor
(
color
:
pulse
.
c
olor
.
withAlphaComponent
(
0
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
default
:
break
}
}
switch
pulse
A
nimation
{
switch
pulse
.
a
nimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
radialBeyondBounds
,
.
point
,
.
pointWithBacking
:
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
radialBeyondBounds
,
.
point
,
.
pointWithBacking
:
pLayer
.
add
(
Animation
.
animationGroup
(
animations
:
[
pLayer
.
add
(
Animation
.
animationGroup
(
animations
:
[
Animation
.
scale
(
scale
:
.
center
==
pulse
A
nimation
?
1
:
1.325
),
Animation
.
scale
(
scale
:
.
center
==
pulse
.
a
nimation
?
1
:
1.325
),
Animation
.
backgroundColor
(
color
:
pulse
C
olor
.
withAlphaComponent
(
0
))
Animation
.
backgroundColor
(
color
:
pulse
.
c
olor
.
withAlphaComponent
(
0
))
],
duration
:
duration
),
forKey
:
nil
)
],
duration
:
duration
),
forKey
:
nil
)
default
:
break
default
:
break
}
}
...
...
Sources/iOS/PulseView.swift
View file @
9756078e
...
@@ -31,19 +31,9 @@
...
@@ -31,19 +31,9 @@
import
UIKit
import
UIKit
open
class
PulseView
:
View
{
open
class
PulseView
:
View
{
/// An Array of pulse layers.
/// A Pulse reference.
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
/// The opcaity value for the pulse animation.
@IBInspectable
open
var
pulseOpacity
:
CGFloat
=
0.25
/// The color of the pulse effect.
@IBInspectable
@IBInspectable
open
var
pulseColor
=
Color
.
grey
.
base
open
internal(set)
lazy
var
pulse
:
Pulse
=
Pulse
()
/// The type of PulseAnimation.
open
var
pulseAnimation
=
PulseAnimation
.
pointWithBacking
/**
/**
Triggers the pulse animation.
Triggers the pulse animation.
...
@@ -52,12 +42,12 @@ open class PulseView: View {
...
@@ -52,12 +42,12 @@ open class PulseView: View {
*/
*/
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
p
,
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
point
:
p
,
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
Color
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
}
}
...
@@ -69,7 +59,7 @@ open class PulseView: View {
...
@@ -69,7 +59,7 @@ open class PulseView: View {
*/
*/
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -80,7 +70,7 @@ open class PulseView: View {
...
@@ -80,7 +70,7 @@ open class PulseView: View {
*/
*/
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
with
:
event
)
super
.
touchesEnded
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -91,6 +81,6 @@ open class PulseView: View {
...
@@ -91,6 +81,6 @@ open class PulseView: View {
*/
*/
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
with
:
event
)
super
.
touchesCancelled
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
}
}
Sources/iOS/Switch.swift
View file @
9756078e
...
@@ -413,7 +413,7 @@ open class Switch: UIControl {
...
@@ -413,7 +413,7 @@ open class Switch: UIControl {
/// Prepares the button.
/// Prepares the button.
private
func
prepareButton
()
{
private
func
prepareButton
()
{
button
.
pulse
A
nimation
=
.
none
button
.
pulse
.
a
nimation
=
.
none
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpInside
)
,
for
:
.
touchUpInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpInside
)
,
for
:
.
touchUpInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchDragInside
)
,
for
:
.
touchDragInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchDragInside
)
,
for
:
.
touchDragInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpOutsideOrCanceled
)
,
for
:
.
touchCancel
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpOutsideOrCanceled
)
,
for
:
.
touchCancel
)
...
...
Sources/iOS/TableViewCell.swift
View file @
9756078e
...
@@ -39,19 +39,9 @@ open class TableViewCell: UITableViewCell {
...
@@ -39,19 +39,9 @@ open class TableViewCell: UITableViewCell {
*/
*/
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
/// An Array of pulse layers.
/// A Pulse reference.
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
/// The opcaity value for the pulse animation.
@IBInspectable
open
var
pulseOpacity
:
CGFloat
=
0.25
/// The color of the pulse effect.
@IBInspectable
@IBInspectable
open
var
pulseColor
=
Color
.
grey
.
base
open
internal(set)
lazy
var
pulse
:
Pulse
=
Pulse
()
/// The type of PulseAnimation.
open
var
pulseAnimation
=
PulseAnimation
.
pointWithBacking
/// A property that accesses the backing layer's backgroundColor.
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
@IBInspectable
...
@@ -100,12 +90,12 @@ open class TableViewCell: UITableViewCell {
...
@@ -100,12 +90,12 @@ open class TableViewCell: UITableViewCell {
*/
*/
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
open
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
let
p
:
CGPoint
=
nil
==
point
?
CGPoint
(
x
:
CGFloat
(
width
/
2
),
y
:
CGFloat
(
height
/
2
))
:
point
!
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
p
,
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
p
,
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
Animation
.
delay
(
time
:
0.35
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
Color
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
}
}
...
@@ -117,7 +107,7 @@ open class TableViewCell: UITableViewCell {
...
@@ -117,7 +107,7 @@ open class TableViewCell: UITableViewCell {
*/
*/
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
ulseColor
:
pulseColor
,
pulseOpacity
:
pulseOpacity
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
p
oint
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -128,7 +118,7 @@ open class TableViewCell: UITableViewCell {
...
@@ -128,7 +118,7 @@ open class TableViewCell: UITableViewCell {
*/
*/
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesEnded
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
with
:
event
)
super
.
touchesEnded
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
@@ -139,7 +129,7 @@ open class TableViewCell: UITableViewCell {
...
@@ -139,7 +129,7 @@ open class TableViewCell: UITableViewCell {
*/
*/
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesCancelled
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
with
:
event
)
super
.
touchesCancelled
(
touches
,
with
:
event
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
Color
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
/**
/**
...
...
Sources/iOS/TextField.swift
View file @
9756078e
...
@@ -207,7 +207,7 @@ open class TextField: UITextField {
...
@@ -207,7 +207,7 @@ open class TextField: UITextField {
if
nil
==
clearIconButton
{
if
nil
==
clearIconButton
{
clearIconButton
=
IconButton
(
image
:
Icon
.
cm
.
clear
,
tintColor
:
placeholderColor
)
clearIconButton
=
IconButton
(
image
:
Icon
.
cm
.
clear
,
tintColor
:
placeholderColor
)
clearIconButton
!.
contentEdgeInsets
=
.
zero
clearIconButton
!.
contentEdgeInsets
=
.
zero
clearIconButton
!.
pulse
A
nimation
=
.
center
clearIconButton
!.
pulse
.
a
nimation
=
.
center
clearButtonMode
=
.
never
clearButtonMode
=
.
never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
whileEditing
rightView
=
clearIconButton
rightView
=
clearIconButton
...
@@ -242,7 +242,7 @@ open class TextField: UITextField {
...
@@ -242,7 +242,7 @@ open class TextField: UITextField {
if
nil
==
visibilityIconButton
{
if
nil
==
visibilityIconButton
{
visibilityIconButton
=
IconButton
(
image
:
Icon
.
visibility
,
tintColor
:
placeholderColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
))
visibilityIconButton
=
IconButton
(
image
:
Icon
.
visibility
,
tintColor
:
placeholderColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
))
visibilityIconButton
!.
contentEdgeInsets
=
.
zero
visibilityIconButton
!.
contentEdgeInsets
=
.
zero
visibilityIconButton
!.
pulse
A
nimation
=
.
center
visibilityIconButton
!.
pulse
.
a
nimation
=
.
center
isSecureTextEntry
=
true
isSecureTextEntry
=
true
clearButtonMode
=
.
never
clearButtonMode
=
.
never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
whileEditing
...
...
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