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
62c42c52
Commit
62c42c52
authored
Sep 29, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated animation values to match default iOS layer animation durations
parent
7a238cd1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
381 additions
and
46 deletions
+381
-46
MaterialKit.xcodeproj/project.pbxproj
+18
-6
Source/BasicCardView.swift
+249
-0
Source/MaterialAnimation.swift
+1
-1
Source/MaterialButton.swift
+15
-7
Source/MaterialInsets.swift
+25
-10
Source/MaterialPulseView.swift
+13
-4
Source/MaterialTheme.swift
+49
-7
Source/NavigationBarView.swift
+0
-1
Source/SideNavigationView.swift
+11
-10
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
62c42c52
...
...
@@ -45,18 +45,19 @@
9638325A1B88E31A0015F710
/* MaterialKitTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832581B88E31A0015F710
/* MaterialKitTests.swift */
;
};
964B17B41BBA447F002A9CA0
/* MaterialLayout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17B31BBA447F002A9CA0
/* MaterialLayout.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
964B17B61BBA4BEA002A9CA0
/* MaterialStatusBarStyle.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17B51BBA4BEA002A9CA0
/* MaterialStatusBarStyle.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
964B17CB1BBB30B0002A9CA0
/* SideNavigationView
Controller.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17CA1BBB30B0002A9CA0
/* SideNavigationViewController
.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
964B17CB1BBB30B0002A9CA0
/* SideNavigationView
.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17CA1BBB30B0002A9CA0
/* SideNavigationView
.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
964B17CC1BBB31C2002A9CA0
/* MaterialBorder.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17CD1BBB31C2002A9CA0
/* MaterialShape.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD16B1BB88D1A006F7F2B
/* MaterialShape.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17CE1BBB31C2002A9CA0
/* MaterialSize.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1761BB98E31006F7F2B
/* MaterialSize.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17CF1BBB31C2002A9CA0
/* MaterialStatusBarStyle.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17B51BBA4BEA002A9CA0
/* MaterialStatusBarStyle.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D01BBB31C2002A9CA0
/* MaterialPulseView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD16D1BB899F2006F7F2B
/* MaterialPulseView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D11BBB31C2002A9CA0
/* SideNavigationView
Controller.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17CA1BBB30B0002A9CA0
/* SideNavigationViewController
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D11BBB31C2002A9CA0
/* SideNavigationView
.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17CA1BBB30B0002A9CA0
/* SideNavigationView
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D21BBB31C2002A9CA0
/* MaterialLabel.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1711BB8CD77006F7F2B
/* MaterialLabel.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D31BBB31C2002A9CA0
/* RaisedButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1781BB99C0F006F7F2B
/* RaisedButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D41BBB31C2002A9CA0
/* FabButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD17B1BB99E29006F7F2B
/* FabButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D51BBB31C2002A9CA0
/* MaterialAnimation.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1731BB8D443006F7F2B
/* MaterialAnimation.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D61BBB31C2002A9CA0
/* MaterialLayout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17B31BBA447F002A9CA0
/* MaterialLayout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
964B17D91BBB3911002A9CA0
/* BasicCardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
9A94D0FB1B895EA500F586A5
/* Roboto-Regular.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
;
};
9A94D0FC1B895EA500F586A5
/* Roboto-Medium.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38571B8956CF00FE6B2D
/* Roboto-Medium.ttf */
;
};
...
...
@@ -104,7 +105,8 @@
963832631B88E5BF0015F710
/* LICENSE */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text
;
path
=
LICENSE
;
sourceTree
=
"<group>"
;
};
964B17B31BBA447F002A9CA0
/* MaterialLayout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialLayout.swift
;
sourceTree
=
"<group>"
;
};
964B17B51BBA4BEA002A9CA0
/* MaterialStatusBarStyle.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialStatusBarStyle.swift
;
sourceTree
=
"<group>"
;
};
964B17CA1BBB30B0002A9CA0
/* SideNavigationViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SideNavigationViewController.swift
;
sourceTree
=
"<group>"
;
};
964B17CA1BBB30B0002A9CA0
/* SideNavigationView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SideNavigationView.swift
;
sourceTree
=
"<group>"
;
};
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCardView.swift
;
sourceTree
=
"<group>"
;
};
9AAC38551B8956C500FE6B2D
/* Roboto-Light.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Light.ttf"
;
sourceTree
=
"<group>"
;
};
9AAC38571B8956CF00FE6B2D
/* Roboto-Medium.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Medium.ttf"
;
sourceTree
=
"<group>"
;
};
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Regular.ttf"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -166,7 +168,7 @@
isa
=
PBXGroup
;
children
=
(
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
,
964B17CA1BBB30B0002A9CA0
/* SideNavigationView
Controller
.swift */
,
964B17CA1BBB30B0002A9CA0
/* SideNavigationView.swift */
,
);
name
=
Navigation
;
sourceTree
=
"<group>"
;
...
...
@@ -214,6 +216,7 @@
9AAC38521B89553800FE6B2D
/* Font */
,
65B965851B8BEEB00055B139
/* View */
,
65BDD16F1BB89A01006F7F2B
/* Navigation */
,
964B17D71BBB38E2002A9CA0
/* Card */
,
65BDD1701BB8CD56006F7F2B
/* Label */
,
65BDD1551BB6FC60006F7F2B
/* Button */
,
65BDD1751BB8D44B006F7F2B
/* Animation */
,
...
...
@@ -255,6 +258,14 @@
name
=
Layout
;
sourceTree
=
"<group>"
;
};
964B17D71BBB38E2002A9CA0
/* Card */
=
{
isa
=
PBXGroup
;
children
=
(
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
,
);
name
=
Card
;
sourceTree
=
"<group>"
;
};
96B57D4C1B90AF6A00DE7BBB
/* Theme */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -305,7 +316,7 @@
964B17CE1BBB31C2002A9CA0
/* MaterialSize.swift in Headers */
,
964B17CF1BBB31C2002A9CA0
/* MaterialStatusBarStyle.swift in Headers */
,
964B17D01BBB31C2002A9CA0
/* MaterialPulseView.swift in Headers */
,
964B17D11BBB31C2002A9CA0
/* SideNavigationView
Controller
.swift in Headers */
,
964B17D11BBB31C2002A9CA0
/* SideNavigationView.swift in Headers */
,
964B17D21BBB31C2002A9CA0
/* MaterialLabel.swift in Headers */
,
964B17D31BBB31C2002A9CA0
/* RaisedButton.swift in Headers */
,
964B17D41BBB31C2002A9CA0
/* FabButton.swift in Headers */
,
...
...
@@ -419,10 +430,11 @@
buildActionMask
=
2147483647
;
files
=
(
65BDD15D1BB70D60006F7F2B
/* MaterialInsets.swift in Sources */
,
964B17CB1BBB30B0002A9CA0
/* SideNavigationView
Controller
.swift in Sources */
,
964B17CB1BBB30B0002A9CA0
/* SideNavigationView.swift in Sources */
,
65BDD1471BB5B916006F7F2B
/* MaterialView.swift in Sources */
,
65BDD16C1BB88D1A006F7F2B
/* MaterialShape.swift in Sources */
,
65BDD1521BB6EE7C006F7F2B
/* RobotoFont.swift in Sources */
,
964B17D91BBB3911002A9CA0
/* BasicCardView.swift in Sources */
,
65BDD1591BB6FE3E006F7F2B
/* FlatButton.swift in Sources */
,
65BDD1791BB99C0F006F7F2B
/* RaisedButton.swift in Sources */
,
964B17B41BBA447F002A9CA0
/* MaterialLayout.swift in Sources */
,
...
...
Source/BasicCardView.swift
0 → 100644
View file @
62c42c52
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
class
BasicCardView
:
MaterialPulseView
{
/**
:name: titleInsets
*/
public
var
titleInsets
:
MaterialInsets
?
{
didSet
{
titleInsetsRef
=
nil
==
titleInsets
?
nil
:
MaterialInsetsToValue
(
titleInsets
!
)
}
}
/**
:name: titleInsetsRef
*/
public
var
titleInsetsRef
:
MaterialInsetsType
!
{
didSet
{
titleInsetsRef
=
nil
==
titleInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
titleInsetsRef
!
reloadView
()
}
}
/**
:name: titleLabel
*/
public
var
titleLabel
:
UILabel
?
{
didSet
{
if
let
v
=
titleLabel
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
}
reloadView
()
}
}
/**
:name: leftButtonsInsets
*/
public
var
leftButtonsInsets
:
MaterialInsets
?
{
didSet
{
leftButtonsInsetsRef
=
nil
==
leftButtonsInsets
?
nil
:
MaterialInsetsToValue
(
leftButtonsInsets
!
)
}
}
/**
:name: leftButtonsInsetsRef
*/
public
var
leftButtonsInsetsRef
:
MaterialInsetsType
!
{
didSet
{
leftButtonsInsetsRef
=
nil
==
leftButtonsInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
leftButtonsInsetsRef
!
reloadView
()
}
}
/**
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
let
v
=
leftButtons
{
for
b
in
v
{
b
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
reloadView
()
}
}
/**
:name: rightButtonsInsets
*/
public
var
rightButtonsInsets
:
MaterialInsets
?
{
didSet
{
rightButtonsInsetsRef
=
nil
==
rightButtonsInsets
?
nil
:
MaterialInsetsToValue
(
rightButtonsInsets
!
)
}
}
/**
:name: rightButtonsInsetsRef
*/
public
var
rightButtonsInsetsRef
:
MaterialInsetsType
!
{
didSet
{
rightButtonsInsetsRef
=
nil
==
rightButtonsInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
rightButtonsInsetsRef
!
reloadView
()
}
}
/**
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
let
v
=
rightButtons
{
for
b
in
v
{
b
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
reloadView
()
}
}
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
:name: init
*/
public
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
}
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectZero
)
}
/**
:name: init
*/
public
convenience
init
?(
titleLabel
:
UILabel
?
=
nil
,
leftButtons
:
Array
<
MaterialButton
>
?
=
nil
,
rightButtons
:
Array
<
MaterialButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
self
.
prepareProperties
(
titleLabel
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
/**
:name: reloadView
*/
public
func
reloadView
()
{
// clear constraints so new ones do not conflict
removeConstraints
(
constraints
)
for
v
in
subviews
{
v
.
removeFromSuperview
()
}
var
verticalFormat
:
String
=
"V:|"
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
metrics
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
// title
if
let
v
=
titleLabel
{
verticalFormat
+=
"-(titleLabelTopInset)-[titleLabel]-(titleLabelBottomInset)-"
views
[
"titleLabel"
]
=
titleLabel
metrics
[
"titleLabelTopInset"
]
=
titleInsetsRef
!.
top
metrics
[
"titleLabelBottomInset"
]
=
titleInsetsRef
!.
bottom
addSubview
(
v
)
v
.
layer
.
zPosition
=
2000
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
titleInsetsRef
!.
left
,
right
:
titleInsetsRef
!.
right
)
}
// leftButtons
if
let
v
=
leftButtons
{
var
h
:
String
=
"H:|"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
0
for
b
in
v
{
let
k
:
String
=
"b
\(
i
++
)
"
d
[
k
]
=
b
h
+=
"-(left)-[
\(
k
)
]"
insertSubview
(
b
,
atIndex
:
1
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
leftButtonsInsetsRef
!.
bottom
)
}
addConstraints
(
MaterialLayout
.
constraint
(
h
,
options
:
[],
metrics
:
[
"left"
:
leftButtonsInsetsRef
!.
left
],
views
:
d
))
}
// rightButtons
if
let
v
=
rightButtons
{
var
h
:
String
=
"H:"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
0
for
b
in
v
{
let
k
:
String
=
"b
\(
i
++
)
"
d
[
k
]
=
b
h
+=
"[
\(
k
)
]-(right)-"
insertSubview
(
b
,
atIndex
:
1
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
rightButtonsInsetsRef
!.
bottom
)
}
addConstraints
(
MaterialLayout
.
constraint
(
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
rightButtonsInsetsRef
!.
right
],
views
:
d
))
}
if
0
<
views
.
count
{
verticalFormat
+=
"|"
addConstraints
(
MaterialLayout
.
constraint
(
verticalFormat
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
titleLabel
:
UILabel
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
self
.
titleLabel
=
titleLabel
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
}
//
// :name: prepareView
//
internal
override
func
prepareView
()
{
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
basicCardView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
basicCardView
.
backgroudColor
titleInsetsRef
=
MaterialTheme
.
basicCardView
.
titleInsetsRef
leftButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
leftButtonsInsetsRef
rightButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
rightButtonsInsetsRef
contentsRect
=
MaterialTheme
.
basicCardView
.
contentsRect
contentsCenter
=
MaterialTheme
.
basicCardView
.
contentsCenter
contentsScale
=
MaterialTheme
.
basicCardView
.
contentsScale
contentsGravity
=
MaterialTheme
.
basicCardView
.
contentsGravity
shadowDepth
=
MaterialTheme
.
basicCardView
.
shadowDepth
shadowColor
=
MaterialTheme
.
basicCardView
.
shadowColor
zPosition
=
MaterialTheme
.
basicCardView
.
zPosition
masksToBounds
=
MaterialTheme
.
basicCardView
.
masksToBounds
cornerRadius
=
MaterialTheme
.
basicCardView
.
cornerRadius
borderWidth
=
MaterialTheme
.
basicCardView
.
borderWidth
borderColor
=
MaterialTheme
.
basicCardView
.
bordercolor
}
}
Source/MaterialAnimation.swift
View file @
62c42c52
...
...
@@ -22,7 +22,7 @@ public struct MaterialAnimation {
/**
:name: spin
*/
public
static
func
spin
(
view
:
UIView
,
duration
:
CFTimeInterval
,
rotations
:
Int
=
1
,
completion
:
(()
->
Void
)?
=
nil
)
{
public
static
func
spin
(
view
:
UIView
,
duration
:
CFTimeInterval
=
1
,
rotations
:
Int
=
1
,
completion
:
(()
->
Void
)?
=
nil
)
{
let
a
:
CABasicAnimation
=
CABasicAnimation
()
a
.
keyPath
=
"transform.rotation"
a
.
duration
=
duration
...
...
Source/MaterialButton.swift
View file @
62c42c52
...
...
@@ -39,7 +39,8 @@ public class MaterialButton : UIButton {
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
didSet
{
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.5
:
pulseColorOpacity
!
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.25
:
pulseColorOpacity
!
preparePulseLayer
()
}
}
...
...
@@ -48,7 +49,7 @@ public class MaterialButton : UIButton {
*/
public
var
pulseColor
:
UIColor
?
{
didSet
{
p
ulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
!
)
.
CGColor
p
reparePulseLayer
()
}
}
...
...
@@ -235,7 +236,7 @@ public class MaterialButton : UIButton {
*/
public
var
contentInsets
:
MaterialInsets
!
{
didSet
{
let
value
:
MaterialInsetsType
=
MaterialInsetsToValue
(
nil
==
contentInsets
?
.
Inset
0
:
contentInsets
)
let
value
:
MaterialInsetsType
=
MaterialInsetsToValue
(
nil
==
contentInsets
?
.
Rectangle
0
:
contentInsets
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
value
.
top
,
value
.
left
,
value
.
bottom
,
value
.
right
)
}
}
...
...
@@ -299,8 +300,8 @@ public class MaterialButton : UIButton {
// expand
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0.
3
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
2.5
,
2.5
,
2.5
)
CATransaction
.
setAnimationDuration
(
0.
25
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
CATransaction
.
commit
()
}
...
...
@@ -337,7 +338,7 @@ public class MaterialButton : UIButton {
layer
.
addSublayer
(
visualLayer
)
// touchesLayer
touchesLayer
.
zPosition
=
1000
touchesLayer
.
zPosition
=
-
1
touchesLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
touchesLayer
)
...
...
@@ -354,11 +355,18 @@ public class MaterialButton : UIButton {
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
!
)
.
CGColor
}
//
// :name: shrink
//
internal
func
shrink
()
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0.
3
)
CATransaction
.
setAnimationDuration
(
0.
25
)
pulseLayer
.
hidden
=
true
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
...
...
Source/MaterialInsets.swift
View file @
62c42c52
...
...
@@ -21,11 +21,16 @@ import UIKit
public
typealias
MaterialInsetsType
=
(
top
:
CGFloat
,
left
:
CGFloat
,
bottom
:
CGFloat
,
right
:
CGFloat
)
public
enum
MaterialInsets
{
case
Inset0
case
Inset1
case
Inset2
case
Inset3
case
Inset4
case
Square0
case
Square1
case
Square2
case
Square3
case
Square4
case
Rectangle0
case
Rectangle1
case
Rectangle2
case
Rectangle3
case
Rectangle4
}
/**
...
...
@@ -33,15 +38,25 @@ public enum MaterialInsets {
*/
public
func
MaterialInsetsToValue
(
inset
:
MaterialInsets
)
->
MaterialInsetsType
{
switch
inset
{
case
.
Inset
0
:
case
.
Square
0
:
return
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
case
.
Inset1
:
case
.
Square1
:
return
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
case
.
Square2
:
return
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
case
.
Square3
:
return
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
case
.
Square4
:
return
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
case
.
Rectangle0
:
return
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
case
.
Rectangle1
:
return
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
case
.
Inset
2
:
case
.
Rectangle
2
:
return
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
case
.
Inset
3
:
case
.
Rectangle
3
:
return
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
case
.
Inset
4
:
case
.
Rectangle
4
:
return
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
}
}
Source/MaterialPulseView.swift
View file @
62c42c52
...
...
@@ -34,7 +34,8 @@ public class MaterialPulseView: MaterialView {
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
didSet
{
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.5
:
pulseColorOpacity
!
pulseColorOpacity
=
nil
==
pulseColorOpacity
?
0.25
:
pulseColorOpacity
!
preparePulseLayer
()
}
}
...
...
@@ -44,6 +45,7 @@ public class MaterialPulseView: MaterialView {
public
var
pulseColor
:
UIColor
?
{
didSet
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
!
)
.
CGColor
preparePulseLayer
()
}
}
...
...
@@ -82,8 +84,8 @@ public class MaterialPulseView: MaterialView {
// expand
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0.
3
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
2.5
,
2.5
,
2.5
)
CATransaction
.
setAnimationDuration
(
0.
25
)
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
CATransaction
.
commit
()
}
...
...
@@ -144,11 +146,18 @@ public class MaterialPulseView: MaterialView {
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
!
)
.
CGColor
}
//
// :name: shrink
//
internal
func
shrink
()
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0.
3
)
CATransaction
.
setAnimationDuration
(
0.
25
)
pulseLayer
.
hidden
=
true
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
...
...
Source/MaterialTheme.swift
View file @
62c42c52
...
...
@@ -21,6 +21,7 @@ import UIKit
public
struct
MaterialTheme
{
public
struct
view
{}
public
struct
pulseView
{}
public
struct
basicCardView
{}
public
struct
navigationBarView
{}
public
struct
label
{}
public
struct
flatButton
{}
...
...
@@ -87,7 +88,48 @@ public extension MaterialTheme.pulseView {
// color
public
static
var
backgroudColor
:
UIColor
=
MaterialColor
.
clear
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColorOpacity
:
CGFloat
=
0.5
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
// interaction
public
static
var
userInteractionEnabled
:
Bool
=
MaterialTheme
.
view
.
userInteractionEnabled
// image
public
static
var
contentsRect
:
CGRect
=
MaterialTheme
.
view
.
contentsRect
public
static
var
contentsCenter
:
CGRect
=
MaterialTheme
.
view
.
contentsCenter
public
static
var
contentsScale
:
CGFloat
=
MaterialTheme
.
view
.
contentsScale
public
static
var
contentsGravity
:
MaterialGravity
=
MaterialTheme
.
view
.
contentsGravity
// position
public
static
var
zPosition
:
CGFloat
=
MaterialTheme
.
view
.
zPosition
}
// basicCardView
public
extension
MaterialTheme
.
basicCardView
{
// frame
public
static
var
x
:
CGFloat
=
MaterialTheme
.
view
.
x
public
static
var
y
:
CGFloat
=
MaterialTheme
.
view
.
y
public
static
var
width
:
CGFloat
=
MaterialTheme
.
view
.
width
public
static
var
height
:
CGFloat
=
MaterialTheme
.
view
.
height
// shadow
public
static
var
shadowDepth
:
MaterialDepth
=
MaterialTheme
.
view
.
shadowDepth
public
static
var
shadowColor
:
UIColor
=
MaterialTheme
.
view
.
shadowColor
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
10
,
right
:
8
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
// border
public
static
var
borderWidth
:
MaterialBorder
=
MaterialTheme
.
view
.
borderWidth
public
static
var
bordercolor
:
UIColor
=
MaterialTheme
.
view
.
bordercolor
// color
public
static
var
backgroudColor
:
UIColor
=
MaterialColor
.
clear
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
// interaction
public
static
var
userInteractionEnabled
:
Bool
=
MaterialTheme
.
view
.
userInteractionEnabled
...
...
@@ -117,9 +159,9 @@ public extension MaterialTheme.navigationBarView {
// shape
public
static
var
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
10
,
right
:
8
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
8
,
right
:
0
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
0
,
bottom
:
8
,
right
:
8
)
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
// border
public
static
var
borderWidth
:
MaterialBorder
=
MaterialTheme
.
view
.
borderWidth
...
...
@@ -164,7 +206,7 @@ public extension MaterialTheme.flatButton {
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius1
public
static
var
contentInsets
:
MaterialInsets
=
.
Inset
2
public
static
var
contentInsets
:
MaterialInsets
=
.
Rectangle
2
public
static
var
shape
:
MaterialShape
?
=
nil
// border
...
...
@@ -196,7 +238,7 @@ public extension MaterialTheme.raisedButton {
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius1
public
static
var
contentInsets
:
MaterialInsets
=
.
Inset
2
public
static
var
contentInsets
:
MaterialInsets
=
.
Rectangle
2
public
static
var
shape
:
MaterialShape
?
=
nil
// border
...
...
@@ -229,7 +271,7 @@ public extension MaterialTheme.fabButton {
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius0
public
static
var
contentInsets
:
MaterialInsets
=
.
Inset
0
public
static
var
contentInsets
:
MaterialInsets
=
.
Rectangle
0
public
static
var
shape
:
MaterialShape
?
=
.
Circle
// border
...
...
Source/NavigationBarView.swift
View file @
62c42c52
...
...
@@ -106,7 +106,6 @@ public class NavigationBarView: MaterialView {
*/
public
var
rightButtonsInsetsRef
:
MaterialInsetsType
!
{
didSet
{
rightButtonsInsetsRef
=
nil
==
rightButtonsInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
rightButtonsInsetsRef
!
reloadView
()
}
}
...
...
Source/SideNavigationView
Controller
.swift
→
Source/SideNavigationView.swift
View file @
62c42c52
...
...
@@ -18,23 +18,23 @@
import
UIKit
public
extension
UIView
Controller
{
public
extension
UIView
{
/**
:name: sideNavigationView
Controller
:name: sideNavigationView
*/
public
var
sideNavigationView
Controller
:
SideNavigationViewController
?
{
var
v
iewController
:
UIViewController
?
=
self
while
nil
!=
v
iewController
{
if
v
iewController
is
SideNavigationViewController
{
return
v
iewController
as?
SideNavigationViewController
public
var
sideNavigationView
:
SideNavigationView
?
{
var
v
:
UIView
?
=
self
while
nil
!=
v
{
if
v
is
SideNavigationView
{
return
v
as?
SideNavigationView
}
v
iewController
=
viewController
?
.
parentViewController
v
=
v
?
.
superview
}
return
nil
}
}
@objc(SideNavigationView
Controller
)
public
class
SideNavigationView
Controller
:
UIViewController
,
UIGestureRecognizerDelegate
{
@objc(SideNavigationView)
public
class
SideNavigationView
:
MaterialView
,
UIGestureRecognizerDelegate
{
}
\ No newline at end of file
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