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
edfbcb3f
Commit
edfbcb3f
authored
Sep 27, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added pulseView basics
parent
367592c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
249 additions
and
40 deletions
+249
-40
MaterialKit.xcodeproj/project.pbxproj
+13
-1
Source/FlatButton.swift
+0
-1
Source/MaterialButton.swift
+18
-13
Source/MaterialPulseView.swift
+151
-0
Source/MaterialTheme.swift
+37
-4
Source/MaterialView.swift
+30
-20
Source/NavigationBarView.swift
+0
-1
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
edfbcb3f
...
...
@@ -31,6 +31,7 @@
65BDD1681BB7111E006F7F2B
/* FlatButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1581BB6FE3E006F7F2B
/* FlatButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65BDD16A1BB7146B006F7F2B
/* MaterialBorder.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD16C1BB88D1A006F7F2B
/* MaterialShape.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD16B1BB88D1A006F7F2B
/* MaterialShape.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD16E1BB899F2006F7F2B
/* MaterialPulseView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD16D1BB899F2006F7F2B
/* MaterialPulseView.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65DBE4201B9A9244000C804F
/* Roboto-Bold.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
;
};
65DBE4211B9A9244000C804F
/* Roboto-Thin.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
;
};
962F3E531BACA68C0004B8AD
/* NavigationBarView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
;
};
...
...
@@ -67,6 +68,7 @@
65BDD15C1BB70D60006F7F2B
/* MaterialInsets.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialInsets.swift
;
sourceTree
=
"<group>"
;
};
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialBorder.swift
;
sourceTree
=
"<group>"
;
};
65BDD16B1BB88D1A006F7F2B
/* MaterialShape.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialShape.swift
;
sourceTree
=
"<group>"
;
};
65BDD16D1BB899F2006F7F2B
/* MaterialPulseView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialPulseView.swift
;
sourceTree
=
"<group>"
;
};
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Bold.ttf"
;
sourceTree
=
"<group>"
;
};
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Thin.ttf"
;
sourceTree
=
"<group>"
;
};
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationBarView.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -104,7 +106,7 @@
isa
=
PBXGroup
;
children
=
(
65BDD1461BB5B916006F7F2B
/* MaterialView.swift */
,
962F3E521BACA68C0004B8AD
/* NavigationBar
View.swift */
,
65BDD16D1BB899F2006F7F2B
/* MaterialPulse
View.swift */
,
);
name
=
View
;
sourceTree
=
"<group>"
;
...
...
@@ -131,6 +133,14 @@
name
=
Button
;
sourceTree
=
"<group>"
;
};
65BDD16F1BB89A01006F7F2B
/* Navigation */
=
{
isa
=
PBXGroup
;
children
=
(
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
,
);
name
=
Navigation
;
sourceTree
=
"<group>"
;
};
9638322C1B88DFD80015F710
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -157,6 +167,7 @@
96B57D4C1B90AF6A00DE7BBB
/* Theme */
,
9AAC38521B89553800FE6B2D
/* Font */
,
65B965851B8BEEB00055B139
/* View */
,
65BDD16F1BB89A01006F7F2B
/* Navigation */
,
65BDD1551BB6FC60006F7F2B
/* Button */
,
);
path
=
Source
;
...
...
@@ -346,6 +357,7 @@
65BDD14F1BB5EE4A006F7F2B
/* MaterialGravity.swift in Sources */
,
65BDD1541BB6F473006F7F2B
/* MaterialShadow.swift in Sources */
,
65BDD1571BB6FC82006F7F2B
/* MaterialButton.swift in Sources */
,
65BDD16E1BB899F2006F7F2B
/* MaterialPulseView.swift in Sources */
,
65BDD14B1BB5DD02006F7F2B
/* MaterialFont.swift in Sources */
,
65BDD16A1BB7146B006F7F2B
/* MaterialBorder.swift in Sources */
,
65BDD15B1BB7095E006F7F2B
/* MaterialRadius.swift in Sources */
,
...
...
Source/FlatButton.swift
View file @
edfbcb3f
...
...
@@ -37,7 +37,6 @@ public class FlatButton : MaterialButton {
shadowColor
=
MaterialTheme
.
button
.
flat
.
shadowColor
zPosition
=
MaterialTheme
.
button
.
flat
.
zPosition
masksToBounds
=
MaterialTheme
.
button
.
flat
.
masksToBounds
shape
=
MaterialTheme
.
button
.
flat
.
shape
cornerRadius
=
MaterialTheme
.
button
.
flat
.
cornerRadius
borderWidth
=
MaterialTheme
.
button
.
flat
.
borderWidth
borderColor
=
MaterialTheme
.
button
.
flat
.
bordercolor
...
...
Source/MaterialButton.swift
View file @
edfbcb3f
...
...
@@ -34,48 +34,48 @@ public class MaterialButton : UIButton {
/**
:name: x
*/
public
var
x
:
CGFloat
!
{
public
var
x
:
CGFloat
{
get
{
return
layer
.
bounds
.
origin
.
x
return
layer
.
frame
.
origin
.
x
}
set
(
value
)
{
layer
.
bounds
.
origin
.
x
=
value
layer
.
frame
.
origin
.
x
=
value
}
}
/**
:name: y
*/
public
var
y
:
CGFloat
!
{
public
var
y
:
CGFloat
{
get
{
return
layer
.
bounds
.
origin
.
y
return
layer
.
frame
.
origin
.
y
}
set
(
value
)
{
layer
.
bounds
.
origin
.
y
=
value
layer
.
frame
.
origin
.
y
=
value
}
}
/**
:name: width
*/
public
var
width
:
CGFloat
!
{
public
var
width
:
CGFloat
{
get
{
return
layer
.
bounds
.
size
.
width
return
layer
.
frame
.
size
.
width
}
set
(
value
)
{
layer
.
bounds
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
}
}
/**
:name: height
*/
public
var
height
:
CGFloat
!
{
public
var
height
:
CGFloat
{
get
{
return
layer
.
bounds
.
size
.
height
return
layer
.
frame
.
size
.
height
}
set
(
value
)
{
layer
.
bounds
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
}
}
...
...
@@ -136,8 +136,13 @@ public class MaterialButton : UIButton {
/**
:name: shape
*/
public
var
shape
:
MaterialShape
!
{
public
var
shape
:
MaterialShape
?
{
didSet
{
if
width
<
height
{
width
=
height
}
else
{
height
=
width
}
switch
shape
!
{
case
.
Square
:
layer
.
cornerRadius
=
0
...
...
Source/MaterialPulseView.swift
0 → 100644
View file @
edfbcb3f
//
// 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
MaterialPulseView
:
MaterialView
{
/**
:name: width
*/
public
override
var
width
:
CGFloat
{
get
{
return
super
.
width
}
set
(
value
)
{
super
.
width
=
value
pulseLayer
.
frame
.
size
.
width
=
value
if
nil
!=
shape
{
pulseLayer
.
frame
.
size
.
height
=
height
}
}
}
/**
:name: height
*/
public
override
var
height
:
CGFloat
{
get
{
return
super
.
height
}
set
(
value
)
{
super
.
height
=
value
pulseLayer
.
frame
.
size
.
height
=
value
if
nil
!=
shape
{
pulseLayer
.
frame
.
size
.
width
=
width
}
}
}
/**
:name: cornerRadius
*/
public
override
var
cornerRadius
:
MaterialRadius
!
{
didSet
{
super
.
cornerRadius
=
cornerRadius
pulseLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
/**
:name: shape
*/
public
override
var
shape
:
MaterialShape
!
{
didSet
{
prepareShape
()
}
}
//
// :name: pulseLayer
//
internal
lazy
var
pulseLayer
:
CALayer
=
CALayer
()
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectMake
(
MaterialTheme
.
pulseView
.
x
,
MaterialTheme
.
pulseView
.
y
,
MaterialTheme
.
pulseView
.
width
,
MaterialTheme
.
pulseView
.
height
))
}
/**
:name: touchesBegan
*/
public
override
func
touchesBegan
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
withEvent
:
event
)
layer
.
addSublayer
(
pulseLayer
)
}
/**
:name: touchesEnded
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
pulseLayer
.
removeFromSuperlayer
()
}
/**
:name: touchesCancelled
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
}
//
// :name: prepareView
//
internal
override
func
prepareView
()
{
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
pulseView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
pulseView
.
backgroudColor
}
//
// :name: prepareLayer
//
internal
override
func
prepareLayer
()
{
super
.
prepareLayer
()
contentsRect
=
MaterialTheme
.
pulseView
.
contentsRect
contentsCenter
=
MaterialTheme
.
pulseView
.
contentsCenter
contentsScale
=
MaterialTheme
.
pulseView
.
contentsScale
contentsGravity
=
MaterialTheme
.
pulseView
.
contentsGravity
shadowDepth
=
MaterialTheme
.
pulseView
.
shadowDepth
shadowColor
=
MaterialTheme
.
pulseView
.
shadowColor
zPosition
=
MaterialTheme
.
pulseView
.
zPosition
masksToBounds
=
MaterialTheme
.
pulseView
.
masksToBounds
cornerRadius
=
MaterialTheme
.
pulseView
.
cornerRadius
borderWidth
=
MaterialTheme
.
pulseView
.
borderWidth
borderColor
=
MaterialTheme
.
pulseView
.
bordercolor
// pulseLayer
pulseLayer
.
frame
=
CGRectMake
(
0
,
0
,
width
,
height
)
pulseLayer
.
masksToBounds
=
true
pulseLayer
.
backgroundColor
=
MaterialColor
.
blue
.
accent3
.
CGColor
}
//
// :name: prepareShape
//
internal
override
func
prepareShape
()
{
super
.
prepareShape
()
if
nil
!=
shape
{
pulseLayer
.
frame
.
size
.
width
=
width
pulseLayer
.
frame
.
size
.
height
=
height
pulseLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
}
Source/MaterialTheme.swift
View file @
edfbcb3f
...
...
@@ -20,6 +20,7 @@ import UIKit
public
struct
MaterialTheme
{
public
struct
view
{}
public
struct
pulseView
{}
public
struct
navigation
{}
public
struct
button
{
public
struct
fab
{}
...
...
@@ -43,7 +44,6 @@ public extension MaterialTheme.view {
// shape
public
static
let
masksToBounds
:
Bool
=
false
public
static
let
cornerRadius
:
MaterialRadius
=
.
None
public
static
let
shape
:
MaterialShape
=
.
Square
// border
public
static
let
borderWidth
:
MaterialBorder
=
.
None
...
...
@@ -65,6 +65,42 @@ public extension MaterialTheme.view {
public
static
let
zPosition
:
CGFloat
=
0
}
// pulseView
public
extension
MaterialTheme
.
pulseView
{
// frame
public
static
let
x
:
CGFloat
=
MaterialTheme
.
view
.
x
public
static
let
y
:
CGFloat
=
MaterialTheme
.
view
.
y
public
static
let
width
:
CGFloat
=
MaterialTheme
.
view
.
width
public
static
let
height
:
CGFloat
=
MaterialTheme
.
view
.
height
// shadow
public
static
let
shadowDepth
:
MaterialShadow
=
MaterialTheme
.
view
.
shadowDepth
public
static
let
shadowColor
:
UIColor
=
MaterialTheme
.
view
.
shadowColor
// shape
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
// border
public
static
let
borderWidth
:
MaterialBorder
=
MaterialTheme
.
view
.
borderWidth
public
static
let
bordercolor
:
UIColor
=
MaterialTheme
.
view
.
bordercolor
// color
public
static
let
backgroudColor
:
UIColor
=
MaterialColor
.
clear
// interaction
public
static
let
userInteractionEnabled
:
Bool
=
MaterialTheme
.
view
.
userInteractionEnabled
// image
public
static
let
contentsRect
:
CGRect
=
MaterialTheme
.
view
.
contentsRect
public
static
let
contentsCenter
:
CGRect
=
MaterialTheme
.
view
.
contentsCenter
public
static
let
contentsScale
:
CGFloat
=
MaterialTheme
.
view
.
contentsScale
public
static
let
contentsGravity
:
MaterialGravity
=
MaterialTheme
.
view
.
contentsGravity
// position
public
static
let
zPosition
:
CGFloat
=
MaterialTheme
.
view
.
zPosition
}
// navigation
public
extension
MaterialTheme
.
navigation
{
// frame
...
...
@@ -80,7 +116,6 @@ public extension MaterialTheme.navigation {
// shape
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
let
shape
:
MaterialShape
=
MaterialTheme
.
view
.
shape
// border
public
static
let
borderWidth
:
MaterialBorder
=
MaterialTheme
.
view
.
borderWidth
...
...
@@ -112,7 +147,6 @@ public extension MaterialTheme.button {
// shape
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
.
Light
public
static
let
shape
:
MaterialShape
=
MaterialTheme
.
view
.
shape
public
static
let
contentInsets
:
MaterialInsets
=
.
Inset2
// border
...
...
@@ -142,7 +176,6 @@ public extension MaterialTheme.button.flat {
// shape
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
button
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
button
.
cornerRadius
public
static
let
shape
:
MaterialShape
=
MaterialTheme
.
button
.
shape
public
static
let
contentInsets
:
MaterialInsets
=
MaterialTheme
.
button
.
contentInsets
// border
...
...
Source/MaterialView.swift
View file @
edfbcb3f
...
...
@@ -79,48 +79,50 @@ public class MaterialView: UIView {
/**
:name: x
*/
public
var
x
:
CGFloat
!
{
public
var
x
:
CGFloat
{
get
{
return
layer
.
bounds
.
origin
.
x
return
layer
.
frame
.
origin
.
x
}
set
(
value
)
{
layer
.
bounds
.
origin
.
x
=
value
layer
.
frame
.
origin
.
x
=
value
}
}
/**
:name: y
*/
public
var
y
:
CGFloat
!
{
public
var
y
:
CGFloat
{
get
{
return
layer
.
bounds
.
origin
.
y
return
layer
.
frame
.
origin
.
y
}
set
(
value
)
{
layer
.
bounds
.
origin
.
y
=
value
layer
.
frame
.
origin
.
y
=
value
}
}
/**
:name: width
*/
public
var
width
:
CGFloat
!
{
public
var
width
:
CGFloat
{
get
{
return
layer
.
bounds
.
size
.
width
return
layer
.
frame
.
size
.
width
}
set
(
value
)
{
layer
.
bounds
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
prepareShape
()
}
}
/**
:name: height
*/
public
var
height
:
CGFloat
!
{
public
var
height
:
CGFloat
{
get
{
return
layer
.
bounds
.
size
.
height
return
layer
.
frame
.
size
.
height
}
set
(
value
)
{
layer
.
bounds
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
prepareShape
()
}
}
...
...
@@ -181,14 +183,9 @@ public class MaterialView: UIView {
/**
:name: shape
*/
public
var
shape
:
MaterialShape
!
{
public
var
shape
:
MaterialShape
?
{
didSet
{
switch
shape
!
{
case
.
Square
:
layer
.
cornerRadius
=
0
case
.
Circle
:
layer
.
cornerRadius
=
width
/
2
}
prepareShape
()
}
}
...
...
@@ -274,10 +271,23 @@ public class MaterialView: UIView {
shadowColor
=
MaterialTheme
.
view
.
shadowColor
zPosition
=
MaterialTheme
.
view
.
zPosition
masksToBounds
=
MaterialTheme
.
view
.
masksToBounds
shape
=
MaterialTheme
.
view
.
shape
cornerRadius
=
MaterialTheme
.
view
.
cornerRadius
borderWidth
=
MaterialTheme
.
view
.
borderWidth
borderColor
=
MaterialTheme
.
view
.
bordercolor
}
//
// :name: prepareShape
//
internal
func
prepareShape
()
{
if
nil
!=
shape
{
if
width
<
height
{
layer
.
frame
.
size
.
width
=
height
}
else
{
layer
.
frame
.
size
.
height
=
width
}
layer
.
cornerRadius
=
.
Square
==
shape
?
0
:
width
/
2
}
}
}
Source/NavigationBarView.swift
View file @
edfbcb3f
...
...
@@ -58,7 +58,6 @@ public class NavigationBarView: MaterialView {
shadowColor
=
MaterialTheme
.
navigation
.
shadowColor
zPosition
=
MaterialTheme
.
navigation
.
zPosition
masksToBounds
=
MaterialTheme
.
navigation
.
masksToBounds
shape
=
MaterialTheme
.
navigation
.
shape
cornerRadius
=
MaterialTheme
.
navigation
.
cornerRadius
borderWidth
=
MaterialTheme
.
navigation
.
borderWidth
borderColor
=
MaterialTheme
.
navigation
.
bordercolor
...
...
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