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
d2cb2d46
Commit
d2cb2d46
authored
Jul 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progression commit
parent
ac53a489
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
247 additions
and
152 deletions
+247
-152
Material.xcodeproj/project.pbxproj
+12
-1
Material.xcodeproj/xcshareddata/xcschemes/Material iOS.xcscheme
+1
-1
Sources/iOS/BottomNavigationController.swift
+1
-1
Sources/iOS/BottomTabBar.swift
+23
-23
Sources/iOS/Button.swift
+1
-1
Sources/iOS/Depth.swift
+7
-12
Sources/iOS/Direction.swift
+36
-0
Sources/iOS/Grid.swift
+4
-4
Sources/iOS/IconButton.swift
+1
-1
Sources/iOS/Material+UIImage+TintColor.swift
+11
-9
Sources/iOS/MaterialAnimation.swift
+1
-1
Sources/iOS/MaterialPulseAnimation.swift
+104
-92
Sources/iOS/Menu.swift
+0
-0
Sources/iOS/NavigationDrawerController.swift
+2
-2
Sources/iOS/Offset.swift
+39
-0
Sources/iOS/RootController.swift
+2
-2
Sources/iOS/TabBar.swift
+1
-1
Sources/iOS/View.swift
+1
-1
No files found.
Material.xcodeproj/project.pbxproj
View file @
d2cb2d46
...
...
@@ -17,6 +17,8 @@
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
;
};
967A48191D0F425A00B8CEB7
/* StatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
;
};
96815B381CA07BA20006CBE2
/* MaterialViewTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
;
};
968C99451D37730B000074FF
/* Direction.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
968C99441D37730B000074FF
/* Direction.swift */
;
};
968C99471D377849000074FF
/* Offset.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
968C99461D377849000074FF
/* Offset.swift */
;
};
96977DA61CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
;
};
96BCB7A11CB40DC500C806FE
/* BottomNavigationController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7581CB40DC500C806FE
/* BottomNavigationController.swift */
;
};
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7591CB40DC500C806FE
/* BottomTabBar.swift */
;
};
...
...
@@ -208,6 +210,8 @@
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialViewTests.swift
;
sourceTree
=
"<group>"
;
};
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+TintColor.swift"
;
sourceTree
=
"<group>"
;
};
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StatusBarController.swift
;
sourceTree
=
"<group>"
;
};
968C99441D37730B000074FF
/* Direction.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Direction.swift
;
sourceTree
=
"<group>"
;
};
968C99461D377849000074FF
/* Offset.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Offset.swift
;
sourceTree
=
"<group>"
;
};
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+FilterBlur.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7581CB40DC500C806FE
/* BottomNavigationController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BottomNavigationController.swift
;
sourceTree
=
"<group>"
;
};
96BCB7591CB40DC500C806FE
/* BottomTabBar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BottomTabBar.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -538,6 +542,8 @@
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
,
96BCB7851CB40DC500C806FE
/* MaterialRadius.swift */
,
96BCB7861CB40DC500C806FE
/* MaterialShape.swift */
,
968C99441D37730B000074FF
/* Direction.swift */
,
968C99461D377849000074FF
/* Offset.swift */
,
);
name
=
Type
;
sourceTree
=
"<group>"
;
...
...
@@ -825,7 +831,7 @@
attributes
=
{
LastSwiftMigration
=
0710
;
LastSwiftUpdateCheck
=
0730
;
LastUpgradeCheck
=
0
7
00
;
LastUpgradeCheck
=
0
8
00
;
ORGANIZATIONNAME
=
"CosmicMind, Inc."
;
TargetAttributes
=
{
963832351B88DFD80015F710
=
{
...
...
@@ -923,6 +929,7 @@
96BCB7C11CB40DC500C806FE
/* Depth.swift in Sources */
,
96BCB7D61CB40DC500C806FE
/* Menu.swift in Sources */
,
96BCB7E61CB40DC500C806FE
/* TextStorage.swift in Sources */
,
968C99451D37730B000074FF
/* Direction.swift in Sources */
,
96BCB7B21CB40DC500C806FE
/* Material+UIImage+Network.swift in Sources */
,
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
,
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
,
...
...
@@ -957,6 +964,7 @@
96BCB7C21CB40DC500C806FE
/* Device.swift in Sources */
,
96BCB7A41CB40DC500C806FE
/* CaptureSession.swift in Sources */
,
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
,
968C99471D377849000074FF
/* Offset.swift in Sources */
,
96BCB7D51CB40DC500C806FE
/* View.swift in Sources */
,
96BCB7DE1CB40DC500C806FE
/* SearchBar.swift in Sources */
,
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
,
...
...
@@ -1170,6 +1178,7 @@
PRODUCT_NAME
=
Material
;
PROVISIONING_PROFILE
=
""
;
SKIP_INSTALL
=
YES
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
};
name
=
Release
;
};
...
...
@@ -1205,6 +1214,7 @@
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
"io.cosmicmind.Material-iOS-Tests"
;
PRODUCT_NAME
=
Material
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
};
name
=
Release
;
};
...
...
@@ -1251,6 +1261,7 @@
PRODUCT_NAME
=
Material
;
SDKROOT
=
macosx
;
SKIP_INSTALL
=
YES
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
};
name
=
Release
;
};
...
...
Material.xcodeproj/xcshareddata/xcschemes/Material iOS.xcscheme
View file @
d2cb2d46
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
Sources/iOS/BottomNavigationController.swift
View file @
d2cb2d46
...
...
@@ -48,7 +48,7 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl
}
}
public
func
transitionDuration
(
transitionContext
:
UIViewControllerContextTransitioning
?)
->
NS
TimeInterval
{
public
func
transitionDuration
(
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0.35
}
}
...
...
Sources/iOS/BottomTabBar.swift
View file @
d2cb2d46
...
...
@@ -33,12 +33,12 @@ import UIKit
public
extension
UITabBarItem
{
/// Sets the color of the title color for a state.
public
func
setTitleColor
(
color
:
UIColor
,
forState
state
:
UIControlState
)
{
setTitleTextAttributes
([
NSForegroundColorAttributeName
:
color
],
for
State
:
state
)
setTitleTextAttributes
([
NSForegroundColorAttributeName
:
color
],
for
:
state
)
}
}
@IBDesignable
public
class
BottomTabBar
:
UITabBar
{
public
class
BottomTabBar
:
UITabBar
{
/// Automatically aligns the BottomNavigationBar to the superview.
public
var
autoLayoutToSuperview
:
Bool
=
true
...
...
@@ -117,7 +117,7 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable
public
var
shadowColor
:
UIColor
?
{
didSet
{
layer
.
shadowColor
=
shadowColor
?
.
CG
Color
layer
.
shadowColor
=
shadowColor
?
.
cg
Color
}
}
...
...
@@ -154,7 +154,7 @@ public class BottomTabBar : UITabBar {
/// A preset property to set the borderWidth.
public
var
borderWidthPreset
:
MaterialBorder
=
.
None
{
didSet
{
borderWidth
=
MaterialBorderToValue
(
borderWidthPreset
)
borderWidth
=
MaterialBorderToValue
(
border
:
border
WidthPreset
)
}
}
...
...
@@ -171,10 +171,10 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the layer.borderColor property.
@IBInspectable
public
var
borderColor
:
UIColor
?
{
get
{
return
nil
==
layer
.
borderColor
?
nil
:
UIColor
(
CG
Color
:
layer
.
borderColor
!
)
return
nil
==
layer
.
borderColor
?
nil
:
UIColor
(
cg
Color
:
layer
.
borderColor
!
)
}
set
(
value
)
{
layer
.
borderColor
=
value
?
.
CG
Color
layer
.
borderColor
=
value
?
.
cg
Color
}
}
...
...
@@ -246,10 +246,10 @@ public class BottomTabBar : UITabBar {
when subclassing.
*/
public
func
prepareView
()
{
depth
=
.
depth1
depth
Preset
=
.
depth1
contentScaleFactor
=
Device
.
scale
backgroundColor
=
Color
.
white
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
Color
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
shadowImage
=
image
backgroundImage
=
image
}
...
...
@@ -260,14 +260,14 @@ private var MaterialAssociatedObjectTabBarKey: UInt8 = 0
public
class
MaterialAssociatedObjectTabBar
{
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public
var
d
epthPreset
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public
var
depthPreset
:
D
epthPreset
public
init
(
d
epthPreset
)
{
self
.
depth
=
depth
public
init
(
depthPreset
:
D
epthPreset
)
{
self
.
depth
Preset
=
depthPreset
}
}
...
...
@@ -276,7 +276,7 @@ public extension UITabBar {
public
internal(set)
var
item
:
MaterialAssociatedObjectTabBar
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialAssociatedObjectTabBarKey
)
{
return
MaterialAssociatedObjectTabBar
(
depth
:
.
none
)
return
MaterialAssociatedObjectTabBar
(
depth
Preset
:
.
none
)
}
}
set
(
value
)
{
...
...
@@ -285,17 +285,17 @@ public extension UITabBar {
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public
var
d
epthPreset
{
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public
var
depthPreset
:
D
epthPreset
{
get
{
return
item
.
depth
return
item
.
depth
Preset
}
set
(
value
)
{
let
v
=
DepthPresetToValue
(
preset
:
value
)
layer
.
shadowOffset
=
v
.
offset
layer
.
shadowOffset
=
v
.
offset
.
asSize
layer
.
shadowOpacity
=
v
.
opacity
layer
.
shadowRadius
=
v
.
radius
}
...
...
Sources/iOS/Button.swift
View file @
d2cb2d46
...
...
@@ -209,7 +209,7 @@ public class Button: UIButton {
*/
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offset
A
sSize
shadowOffset
=
depth
.
offset
.
a
sSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
...
...
Sources/iOS/Depth.swift
View file @
d2cb2d46
...
...
@@ -41,7 +41,7 @@ public enum DepthPreset {
public
struct
Depth
{
/// Offset.
public
var
offset
:
UI
Offset
public
var
offset
:
Offset
/// Opacity.
public
var
opacity
:
Float
...
...
@@ -49,18 +49,13 @@ public struct Depth {
/// Radius.
public
var
radius
:
CGFloat
/// Offset as size.
public
var
offsetAsSize
:
CGSize
{
return
CGSize
(
width
:
offset
.
horizontal
,
height
:
offset
.
vertical
)
}
/**
Initializer.
- Parameter offset: UIOffset.
- Parameter opacity: Float.
- Parameter radius: CGFloat.
*/
public
init
(
offset
:
UIOffset
=
UI
Offset
.
zero
,
opacity
:
Float
=
0
,
radius
:
CGFloat
=
0
)
{
public
init
(
offset
:
Offset
=
Offset
.
zero
,
opacity
:
Float
=
0
,
radius
:
CGFloat
=
0
)
{
self
.
offset
=
offset
self
.
opacity
=
opacity
self
.
radius
=
radius
...
...
@@ -81,14 +76,14 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
case
.
none
:
return
Depth
.
zero
case
.
depth1
:
return
Depth
(
offset
:
UI
Offset
(
horizontal
:
0
,
vertical
:
1
),
opacity
:
0.3
,
radius
:
1
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
1
),
opacity
:
0.3
,
radius
:
1
)
case
.
depth2
:
return
Depth
(
offset
:
UI
Offset
(
horizontal
:
0
,
vertical
:
2
),
opacity
:
0.3
,
radius
:
2
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
2
),
opacity
:
0.3
,
radius
:
2
)
case
.
depth3
:
return
Depth
(
offset
:
UI
Offset
(
horizontal
:
0
,
vertical
:
3
),
opacity
:
0.3
,
radius
:
3
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
3
),
opacity
:
0.3
,
radius
:
3
)
case
.
depth4
:
return
Depth
(
offset
:
UI
Offset
(
horizontal
:
0
,
vertical
:
4
),
opacity
:
0.3
,
radius
:
4
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
4
),
opacity
:
0.3
,
radius
:
4
)
case
.
depth5
:
return
Depth
(
offset
:
UI
Offset
(
horizontal
:
0
,
vertical
:
5
),
opacity
:
0.3
,
radius
:
5
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
5
),
opacity
:
0.3
,
radius
:
5
)
}
}
Sources/iOS/Direction.swift
0 → 100644
View file @
d2cb2d46
/*
* 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.
*/
public
enum
Direction
{
case
up
case
down
case
left
case
right
}
Sources/iOS/Grid.swift
View file @
d2cb2d46
...
...
@@ -171,7 +171,7 @@ public class Grid {
}
/// An Array of UIButtons.
public
var
views
:
Array
<
UIView
>
?
{
public
var
views
:
[
UIView
]
?
{
didSet
{
reload
()
}
...
...
@@ -194,9 +194,9 @@ public class Grid {
/// Reload the button layout.
public
func
reload
()
{
if
let
v
:
Array
<
UIView
>
=
views
{
let
gc
:
Int
=
axis
.
inherited
?
columns
:
axis
.
columns
let
gr
:
Int
=
axis
.
inherited
?
rows
:
axis
.
rows
if
let
v
=
views
{
let
gc
=
axis
.
inherited
?
columns
:
axis
.
columns
let
gr
=
axis
.
inherited
?
rows
:
axis
.
rows
var
n
:
Int
=
0
for
i
in
0
..<
v
.
count
{
let
child
:
UIView
=
v
[
i
]
...
...
Sources/iOS/IconButton.swift
View file @
d2cb2d46
...
...
@@ -41,6 +41,6 @@ public class IconButton: Button {
public
override
func
prepareView
()
{
super
.
prepareView
()
cornerRadiusPreset
=
.
Radius1
pulseAnimation
=
.
C
enter
pulseAnimation
=
.
c
enter
}
}
Sources/iOS/Material+UIImage+TintColor.swift
View file @
d2cb2d46
...
...
@@ -36,21 +36,23 @@ public extension UIImage {
- Parameter color: The UIColor to create the image from.
- Returns: A UIImage that is the color passed in.
*/
public
func
tintWithColor
(
color
:
UIColor
)
->
UIImage
{
public
func
tintWithColor
(
color
:
UIColor
)
->
UIImage
?
{
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
Device
.
scale
)
let
context
=
UIGraphicsGetCurrentContext
()
guard
let
context
=
UIGraphicsGetCurrentContext
()
else
{
return
nil
}
CGContextScaleCTM
(
context
,
1.0
,
-
1.0
)
CGContextTranslateCTM
(
context
,
0.0
,
-
size
.
height
)
context
.
scale
(
x
:
1.0
,
y
:
-
1.0
)
context
.
translate
(
x
:
0.0
,
y
:
-
size
.
height
)
CGContextSetBlendMode
(
context
,
.
M
ultiply
)
context
.
setBlendMode
(
.
m
ultiply
)
let
rect
=
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)
CGContextClipToMask
(
context
,
rect
,
cgImage
)
let
rect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
width
,
height
:
size
.
height
)
context
.
clipToMask
(
rect
,
mask
:
cgImage
!
)
color
.
setFill
()
CGContextFillRect
(
context
,
rect
)
context
.
fill
(
rect
)
let
image
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
let
image
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
!
UIGraphicsEndImageContext
()
return
image
}
...
...
Sources/iOS/MaterialAnimation.swift
View file @
d2cb2d46
...
...
@@ -65,7 +65,7 @@ public typealias MaterialAnimationDelayCancelBlock = (cancel : Bool) -> Void
public
struct
MaterialAnimation
{
/// Delay helper method.
public
static
func
delay
(
time
:
NS
TimeInterval
,
completion
:
()
->
Void
)
->
MaterialAnimationDelayCancelBlock
?
{
public
static
func
delay
(
time
:
TimeInterval
,
completion
:
()
->
Void
)
->
MaterialAnimationDelayCancelBlock
?
{
func
dispatch_later
(
completion
:
()
->
Void
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
Int64
(
time
*
Double
(
NSEC_PER_SEC
))),
dispatch_get_main_queue
(),
completion
)
...
...
Sources/iOS/MaterialPulseAnimation.swift
View file @
d2cb2d46
...
...
@@ -31,102 +31,115 @@
import
UIKit
public
enum
PulseAnimation
{
case
N
one
case
C
enter
case
C
enterWithBacking
case
C
enterRadialBeyondBounds
case
B
acking
case
AtP
oint
case
AtP
ointWithBacking
case
n
one
case
c
enter
case
c
enterWithBacking
case
c
enterRadialBeyondBounds
case
b
acking
case
p
oint
case
p
ointWithBacking
}
internal
extension
MaterialAnimation
{
/**
Triggers the expanding animation.
- Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from.
- Parameter width: Container width.
- Parameter height: Container height.
- Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
pulseOpacity
:
CGFloat
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
if
.
None
!=
pulseAnimation
{
if
let
n
:
CGFloat
=
.
Center
==
pulseAnimation
?
width
<
height
?
width
:
height
:
width
<
height
?
height
:
width
{
let
bLayer
:
CAShapeLayer
=
CAShapeLayer
()
let
pLayer
:
CAShapeLayer
=
CAShapeLayer
()
bLayer
.
addSublayer
(
pLayer
)
pulseLayers
.
insert
(
bLayer
,
atIndex
:
0
)
visualLayer
.
addSublayer
(
bLayer
)
MaterialAnimation
.
animationDisabled
({
bLayer
.
frame
=
visualLayer
.
bounds
pLayer
.
bounds
=
CGRectMake
(
0
,
0
,
n
,
n
)
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
:
pLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
default
:
pLayer
.
position
=
point
}
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
backgroundColor
=
pulseColor
.
colorWithAlphaComponent
(
pulseOpacity
)
.
CGColor
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransformMakeScale
(
0
,
0
))
})
bLayer
.
setValue
(
false
,
forKey
:
"animated"
)
let
duration
:
CFTimeInterval
=
.
Center
==
pulseAnimation
?
0.16125
:
0.325
switch
pulseAnimation
{
case
.
CenterWithBacking
,
.
Backing
,
.
AtPointWithBacking
:
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
pulseOpacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
,
.
AtPoint
,
.
AtPointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
scale
(
1
,
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
duration
,
completion
:
{
bLayer
.
setValue
(
true
,
forKey
:
"animated"
)
})
}
}
Triggers the expanding animation.
- Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from.
- Parameter width: Container width.
- Parameter height: Container height.
- Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
pulseOpacity
:
CGFloat
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
pulseLayers
:
inout
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
guard
.
none
!=
pulseAnimation
else
{
return
}
let
n
=
.
center
==
pulseAnimation
?
width
<
height
?
width
:
height
:
width
<
height
?
height
:
width
let
bLayer
:
CAShapeLayer
=
CAShapeLayer
()
let
pLayer
:
CAShapeLayer
=
CAShapeLayer
()
bLayer
.
addSublayer
(
pLayer
)
pulseLayers
.
insert
(
bLayer
,
at
:
0
)
visualLayer
.
addSublayer
(
bLayer
)
MaterialAnimation
.
animationDisabled
(
animations
:
{
bLayer
.
frame
=
visualLayer
.
bounds
pLayer
.
bounds
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
n
,
height
:
n
)
switch
pulseAnimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
:
pLayer
.
position
=
CGPoint
(
x
:
width
/
2
,
y
:
height
/
2
)
default
:
pLayer
.
position
=
point
}
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
backgroundColor
=
pulseColor
.
withAlphaComponent
(
pulseOpacity
)
.
cgColor
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransform
(
scaleX
:
0
,
y
:
0
))
})
bLayer
.
setValue
(
false
,
forKey
:
"animated"
)
let
duration
:
CFTimeInterval
=
.
center
==
pulseAnimation
?
0.16125
:
0.325
switch
pulseAnimation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
bLayer
.
add
(
MaterialAnimation
.
backgroundColor
(
color
:
pulseColor
.
withAlphaComponent
(
pulseOpacity
/
2
),
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
point
,
.
pointWithBacking
:
pLayer
.
add
(
MaterialAnimation
.
scale
(
scale
:
1
,
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
time
:
duration
,
completion
:
{
bLayer
.
setValue
(
true
,
forKey
:
"animated"
)
})
}
/**
Triggers the contracting animation.
- Parameter layer: Container CALayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
if
let
bLayer
:
CAShapeLayer
=
pulseLayers
.
popLast
()
{
let
animated
:
Bool
?
=
bLayer
.
valueForKey
(
"animated"
)
as?
Bool
MaterialAnimation
.
delay
(
true
==
animated
?
0
:
0.15
)
{
if
let
pLayer
:
CAShapeLayer
=
bLayer
.
sublayers
?
.
first
as?
CAShapeLayer
{
let
duration
:
CFTimeInterval
=
0.325
switch
pulseAnimation
{
case
.
CenterWithBacking
,
.
Backing
,
.
AtPointWithBacking
:
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
0
),
duration
:
0.325
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
,
.
AtPoint
,
.
AtPointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
scale
(
.
Center
==
pulseAnimation
?
1
:
1.325
),
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
0
))
],
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
duration
)
{
pLayer
.
removeFromSuperlayer
()
bLayer
.
removeFromSuperlayer
()
}
}
}
}
Triggers the contracting animation.
- Parameter layer: Container CALayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
pulseLayers
:
inout
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
guard
let
bLayer
:
CAShapeLayer
=
pulseLayers
.
popLast
()
else
{
return
}
let
animated
:
Bool
?
=
bLayer
.
value
(
forKey
:
"animated"
)
as?
Bool
MaterialAnimation
.
delay
(
time
:
true
==
animated
?
0
:
0.15
)
{
if
let
pLayer
:
CAShapeLayer
=
bLayer
.
sublayers
?
.
first
as?
CAShapeLayer
{
let
duration
:
CFTimeInterval
=
0.325
switch
pulseAnimation
{
case
.
centerWithBacking
,
.
backing
,
.
pointWithBacking
:
bLayer
.
add
(
MaterialAnimation
.
backgroundColor
(
color
:
pulseColor
.
withAlphaComponent
(
0
),
duration
:
0.325
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
center
,
.
centerWithBacking
,
.
centerRadialBeyondBounds
,
.
point
,
.
pointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
animationGroup
(
animations
:
[
MaterialAnimation
.
scale
(
scale
:
.
Center
==
pulseAnimation
?
1
:
1.325
),
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
0
))
],
duration
:
duration
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
time
:
duration
,
completion
:
{
pLayer
.
removeFromSuperlayer
()
bLayer
.
removeFromSuperlayer
()
})
}
}
}
}
\ No newline at end of file
}
Sources/iOS/Menu.swift
View file @
d2cb2d46
This diff is collapsed.
Click to expand it.
Sources/iOS/NavigationDrawerController.swift
View file @
d2cb2d46
...
...
@@ -438,7 +438,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
the leftView width change.
*/
public
func
setLeftViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NS
TimeInterval
=
0.5
)
{
public
func
setLeftViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
if
let
v
:
View
=
leftView
{
leftViewWidth
=
width
...
...
@@ -512,7 +512,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
the rightView width change.
*/
public
func
setRightViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NS
TimeInterval
=
0.5
)
{
public
func
setRightViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
if
let
v
:
View
=
rightView
{
rightViewWidth
=
width
...
...
Sources/iOS/Offset.swift
0 → 100644
View file @
d2cb2d46
/*
* 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
public
typealias
Offset
=
UIOffset
public
extension
Offset
{
public
var
asSize
:
CGSize
{
return
CGSize
(
width
:
horizontal
,
height
:
vertical
)
}
}
Sources/iOS/RootController.swift
View file @
d2cb2d46
...
...
@@ -101,7 +101,7 @@ public class RootController : UIViewController {
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter duration: A
NS
TimeInterval that sets the
- Parameter duration: A TimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController
...
...
@@ -113,7 +113,7 @@ public class RootController : UIViewController {
the transition animation from the active rootViewController
to the toViewController has completed.
*/
public
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
NS
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
public
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
rootViewController
.
willMoveToParentViewController
(
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
...
...
Sources/iOS/TabBar.swift
View file @
d2cb2d46
...
...
@@ -82,7 +82,7 @@ public class TabBar : View {
b
.
removeTarget
(
self
,
action
:
#selector(
handleButton(_:)
)
,
forControlEvents
:
.
TouchUpInside
)
b
.
addTarget
(
self
,
action
:
#selector(
handleButton(_:)
)
,
forControlEvents
:
.
TouchUpInside
)
}
grid
.
views
=
v
as
Array
<
UIView
>
grid
.
views
=
v
as
[
UIView
]
line
.
frame
=
CGRectMake
(
0
,
.
Bottom
==
lineAlignment
?
height
-
3
:
0
,
v
.
first
!.
frame
.
width
,
3
)
}
}
...
...
Sources/iOS/View.swift
View file @
d2cb2d46
...
...
@@ -261,7 +261,7 @@ public class View: UIView {
*/
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offset
A
sSize
shadowOffset
=
depth
.
offset
.
a
sSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
...
...
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