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
77cd0908
Commit
77cd0908
authored
Sep 29, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
experimental: updated MaterialLable and working on NavigationBarView
parent
4e7853bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
319 additions
and
4 deletions
+319
-4
MaterialKit.xcodeproj/project.pbxproj
+12
-0
Source/MaterialInsets.swift
+4
-4
Source/MaterialLabel.swift
+54
-0
Source/MaterialLayout.swift
+174
-0
Source/NavigationBarView.swift
+75
-0
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
77cd0908
...
...
@@ -43,6 +43,7 @@
962F3E541BACA7FB0004B8AD
/* NavigationBarView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
963832421B88DFD80015F710
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* MaterialKit.framework */
;
};
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
=
();
};
};
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 */
;
};
...
...
@@ -88,6 +89,7 @@
963832581B88E31A0015F710
/* MaterialKitTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKitTests.swift
;
sourceTree
=
"<group>"
;
};
963832591B88E31A0015F710
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
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>"
;
};
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>"
;
};
...
...
@@ -199,6 +201,7 @@
65BDD1701BB8CD56006F7F2B
/* Label */
,
65BDD1551BB6FC60006F7F2B
/* Button */
,
65BDD1751BB8D44B006F7F2B
/* Animation */
,
964B17B21BBA445D002A9CA0
/* Layout */
,
);
path
=
Source
;
sourceTree
=
"<group>"
;
...
...
@@ -228,6 +231,14 @@
name
=
"Supporting Files"
;
sourceTree
=
"<group>"
;
};
964B17B21BBA445D002A9CA0
/* Layout */
=
{
isa
=
PBXGroup
;
children
=
(
964B17B31BBA447F002A9CA0
/* MaterialLayout.swift */
,
);
name
=
Layout
;
sourceTree
=
"<group>"
;
};
96B57D4C1B90AF6A00DE7BBB
/* Theme */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -385,6 +396,7 @@
65BDD1521BB6EE7C006F7F2B
/* RobotoFont.swift in Sources */
,
65BDD1591BB6FE3E006F7F2B
/* FlatButton.swift in Sources */
,
65BDD1791BB99C0F006F7F2B
/* RaisedButton.swift in Sources */
,
964B17B41BBA447F002A9CA0
/* MaterialLayout.swift in Sources */
,
962F3E531BACA68C0004B8AD
/* NavigationBarView.swift in Sources */
,
65BDD14F1BB5EE4A006F7F2B
/* MaterialGravity.swift in Sources */
,
65BDD1771BB98E31006F7F2B
/* MaterialSize.swift in Sources */
,
...
...
Source/MaterialInsets.swift
View file @
77cd0908
...
...
@@ -36,12 +36,12 @@ public func MaterialInsetsToValue(inset: MaterialInsets) -> MaterialInsetsType {
case
.
Inset0
:
return
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
case
.
Inset1
:
return
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
return
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
case
.
Inset2
:
return
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
return
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
case
.
Inset3
:
return
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
return
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
case
.
Inset4
:
return
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
return
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
}
}
Source/MaterialLabel.swift
View file @
77cd0908
...
...
@@ -25,4 +25,57 @@ public class MaterialLabel : UILabel {
public
override
class
func
layerClass
()
->
AnyClass
{
return
CATextLayer
.
self
}
/**
:name: textLayer
*/
public
var
textLayer
:
CATextLayer
{
return
layer
as!
CATextLayer
}
/**
:name: text
*/
public
override
var
text
:
String
?
{
didSet
{
textLayer
.
string
=
text
}
}
/**
:name: textColor
*/
public
override
var
textColor
:
UIColor
?
{
didSet
{
textLayer
.
foregroundColor
=
textColor
?
.
CGColor
}
}
/**
:name: font
*/
public
override
var
font
:
UIFont
?
{
didSet
{
if
let
v
=
font
{
textLayer
.
font
=
CGFontCreateWithFontName
(
v
.
fontName
as
CFStringRef
)
!
textLayer
.
fontSize
=
v
.
pointSize
}
}
}
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
:name: init
*/
public
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
textLayer
.
wrapped
=
true
textLayer
.
contentsScale
=
UIScreen
.
mainScreen
()
.
scale
}
}
\ No newline at end of file
Source/MaterialLayout.swift
0 → 100644
View file @
77cd0908
//
// 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
struct
MaterialLayout
{
/**
:name: width
*/
public
static
func
width
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"width"
:
width
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child(width)]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: height
*/
public
static
func
height
(
parent
:
UIView
,
child
:
UIView
,
height
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"height"
:
height
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"V:[child(height)]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: size
*/
public
static
func
size
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
height
:
CGFloat
=
0
)
{
MaterialLayout
.
width
(
parent
,
child
:
child
,
width
:
width
)
MaterialLayout
.
height
(
parent
,
child
:
child
,
height
:
height
)
}
/**
:name: alignToParent
*/
public
static
func
alignToParent
(
parent
:
UIView
,
child
:
UIView
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|[child]|"
,
options
:
[],
metrics
:
nil
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|[child]|"
,
options
:
[],
metrics
:
nil
,
views
:
views
))
}
/**
:name: alignToParentHorizontally
*/
public
static
func
alignToParentHorizontally
(
parent
:
UIView
,
child
:
UIView
)
{
alignToParentHorizontallyWithPad
(
parent
,
child
:
child
,
left
:
0
,
right
:
0
)
}
/**
:name: alignToParentHorizontallyWithPad
*/
public
static
func
alignToParentHorizontallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
[],
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParentVertically
*/
public
static
func
alignToParentVertically
(
parent
:
UIView
,
child
:
UIView
)
{
alignToParentVerticallyWithPad
(
parent
,
child
:
child
,
top
:
0
,
bottom
:
0
)
}
/**
:name: alignToParentVerticallyWithPad
*/
public
static
func
alignToParentVerticallyWithPad
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
[],
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParentWithPad
*/
public
static
func
alignToParentWithPad
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
[],
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
[],
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
views
))
}
/**
:name: alignFromTopLeft
*/
public
static
func
alignFromTopLeft
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"top"
:
top
,
"left"
:
left
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: alignFromTopRight
*/
public
static
func
alignFromTopRight
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"top"
:
top
,
"right"
:
right
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: alignFromBottomLeft
*/
public
static
func
alignFromBottomLeft
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
left
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"bottom"
:
bottom
,
"left"
:
left
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:[child]-(bottom)-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: alignFromBottomRight
*/
public
static
func
alignFromBottomRight
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
let
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"bottom"
:
bottom
,
"right"
:
right
]
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:[child]-(bottom)-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
:name: alignFromTop
*/
public
static
func
alignFromTop
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]"
,
options
:
[],
metrics
:
[
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromLeft
*/
public
static
func
alignFromLeft
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]"
,
options
:
[],
metrics
:
[
"left"
:
left
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromBottom
*/
public
static
func
alignFromBottom
(
parent
:
UIView
,
child
:
UIView
,
bottom
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"V:[child]-(bottom)-|"
,
options
:
[],
metrics
:
[
"bottom"
:
bottom
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignFromRight
*/
public
static
func
alignFromRight
(
parent
:
UIView
,
child
:
UIView
,
right
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
[],
metrics
:
[
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: constraint
*/
public
static
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
Dictionary
<
String
,
AnyObject
>
?,
views
:
Dictionary
<
String
,
AnyObject
>
)
->
Array
<
NSLayoutConstraint
>
{
return
NSLayoutConstraint
.
constraintsWithVisualFormat
(
format
,
options
:
options
,
metrics
:
metrics
,
views
:
views
)
}
}
\ No newline at end of file
Source/NavigationBarView.swift
View file @
77cd0908
...
...
@@ -29,10 +29,85 @@ public class NavigationBarView: MaterialView {
}
/**
:name: contentInsets
*/
public
var
contentInsets
:
MaterialInsets
?
{
didSet
{
contentInsetsRef
=
MaterialInsetsToValue
(
nil
==
contentInsets
?
.
Inset0
:
contentInsets
!
)
}
}
/**
:name: contentInsetsRef
*/
public
var
contentInsetsRef
:
MaterialInsetsType
!
{
didSet
{
layoutSubviews
()
}
}
/**
:name: titleLabel
*/
public
var
titleLabel
:
MaterialLabel
?
{
didSet
{
if
let
v
=
titleLabel
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
addSubview
(
v
)
}
}
}
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
:name: init
*/
public
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
contentInsets
=
.
Inset3
}
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectMake
(
MaterialTheme
.
navigation
.
x
,
MaterialTheme
.
navigation
.
y
,
MaterialTheme
.
navigation
.
width
,
MaterialTheme
.
navigation
.
height
))
contentInsets
=
.
Inset3
}
/**
:name: init
*/
public
convenience
init
?(
titleLabel
:
MaterialLabel
?
=
nil
)
{
self
.
init
(
frame
:
CGRectMake
(
MaterialTheme
.
navigation
.
x
,
MaterialTheme
.
navigation
.
y
,
MaterialTheme
.
navigation
.
width
,
MaterialTheme
.
navigation
.
height
))
self
.
prepareProperties
(
titleLabel
)
}
/**
:name: layoutSubviews
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
nil
!=
contentInsetsRef
{
removeConstraints
(
constraints
)
MaterialLayout
.
alignToParentHorizontallyWithPad
(
self
,
child
:
titleLabel
!
,
left
:
contentInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
titleLabel
!
,
bottom
:
contentInsetsRef
!.
bottom
)
}
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
titleLabel
:
MaterialLabel
?)
{
self
.
titleLabel
=
titleLabel
}
//
...
...
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