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
b061cb71
Commit
b061cb71
authored
Sep 06, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-30' into development
parents
6018a6c9
216bab00
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
253 additions
and
96 deletions
+253
-96
MaterialKit.xcodeproj/project.pbxproj
+17
-9
README.md
+1
-1
Source/BasicCardView.swift
+48
-12
Source/ImageCardView.swift
+46
-15
Source/Info.plist
+5
-3
Source/Layout.swift
+2
-4
Source/MaterialButton.swift
+1
-1
Source/MaterialCardView.swift
+1
-1
Source/MaterialTheme.swift
+16
-1
Source/Roboto-Bold.ttf
+0
-0
Source/Roboto-Thin.ttf
+0
-0
Source/Roboto.swift
+66
-2
Source/SideNavigationViewController.swift
+50
-47
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
b061cb71
...
...
@@ -8,11 +8,13 @@
/* Begin PBXBuildFile section */
657CD02A1B8EE0D3008C0029
/* MaterialCardView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A94D1081B8A3F5100F586A5
/* MaterialCardView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02C1B8EE0D3008C0029
/* SideNav
Controller.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNav
Controller.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02C1B8EE0D3008C0029
/* SideNav
igationViewController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavigationView
Controller.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02D1B8EE0D3008C0029
/* MaterialButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02F1B8EE0D3008C0029
/* ImageCardView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A94D10A1B8A485C00F586A5
/* ImageCardView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65B9657E1B8A7C330055B139
/* MaterialButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
;
};
65B965871B8BEEC60055B139
/* SideNavController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavController.swift */
;
};
65B965871B8BEEC60055B139
/* SideNavigationViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavigationViewController.swift */
;
};
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 */
;
};
963832421B88DFD80015F710
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* MaterialKit.framework */
;
};
9638325A1B88E31A0015F710
/* MaterialKitTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832581B88E31A0015F710
/* MaterialKitTests.swift */
;
};
963832691B88E5BF0015F710
/* Capture.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9638325E1B88E5BF0015F710
/* Capture.swift */
;
};
...
...
@@ -59,7 +61,9 @@
/* Begin PBXFileReference section */
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialButton.swift
;
sourceTree
=
"<group>"
;
};
65B965861B8BEEC60055B139
/* SideNavController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SideNavController.swift
;
sourceTree
=
"<group>"
;
};
65B965861B8BEEC60055B139
/* SideNavigationViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SideNavigationViewController.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>"
;
};
963832361B88DFD80015F710
/* MaterialKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
MaterialKit.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832411B88DFD80015F710
/* MaterialKitTests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
MaterialKitTests.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832541B88E30F0015F710
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
...
...
@@ -111,12 +115,12 @@
name
=
View
;
sourceTree
=
"<group>"
;
};
65B965851B8BEEB00055B139
/* Nav */
=
{
65B965851B8BEEB00055B139
/* Nav
igation
*/
=
{
isa
=
PBXGroup
;
children
=
(
65B965861B8BEEC60055B139
/* SideNavController.swift */
,
65B965861B8BEEC60055B139
/* SideNav
igationView
Controller.swift */
,
);
name
=
Nav
;
name
=
Nav
igation
;
sourceTree
=
"<group>"
;
};
9638322C1B88DFD80015F710
=
{
...
...
@@ -146,7 +150,7 @@
9AAC38521B89553800FE6B2D
/* Font */
,
963832861B8907FE0015F710
/* Layout */
,
65B965731B8A58E60055B139
/* View */
,
65B965851B8BEEB00055B139
/* Nav */
,
65B965851B8BEEB00055B139
/* Nav
igation
*/
,
963832761B88E8990015F710
/* Text */
,
963832751B88E87B0015F710
/* Button */
,
9AAC384B1B89524E00FE6B2D
/* Card */
,
...
...
@@ -239,6 +243,8 @@
9AAC38521B89553800FE6B2D
/* Font */
=
{
isa
=
PBXGroup
;
children
=
(
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
,
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
,
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
,
9AAC38571B8956CF00FE6B2D
/* Roboto-Medium.ttf */
,
9AAC38551B8956C500FE6B2D
/* Roboto-Light.ttf */
,
...
...
@@ -266,7 +272,7 @@
963832851B89070E0015F710
/* CapturePreview.swift in Headers */
,
963832891B89097D0015F710
/* Layout.swift in Headers */
,
657CD02A1B8EE0D3008C0029
/* MaterialCardView.swift in Headers */
,
657CD02C1B8EE0D3008C0029
/* SideNavController.swift in Headers */
,
657CD02C1B8EE0D3008C0029
/* SideNav
igationView
Controller.swift in Headers */
,
657CD02D1B8EE0D3008C0029
/* MaterialButton.swift in Headers */
,
96C910ED1B95804B00E7CE5C
/* MaterialTheme.swift in Headers */
,
657CD02F1B8EE0D3008C0029
/* ImageCardView.swift in Headers */
,
...
...
@@ -354,6 +360,8 @@
files
=
(
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
,
9A94D0FB1B895EA500F586A5
/* Roboto-Regular.ttf in Resources */
,
65DBE4211B9A9244000C804F
/* Roboto-Thin.ttf in Resources */
,
65DBE4201B9A9244000C804F
/* Roboto-Bold.ttf in Resources */
,
9A94D0FC1B895EA500F586A5
/* Roboto-Medium.ttf in Resources */
,
9A94D0FD1B895EA500F586A5
/* Roboto-Light.ttf in Resources */
,
);
...
...
@@ -378,7 +386,7 @@
96B57D4E1B90AF7D00DE7BBB
/* MaterialTheme.swift in Sources */
,
9638326B1B88E5BF0015F710
/* FabButton.swift in Sources */
,
9A94D1091B8A3F5100F586A5
/* MaterialCardView.swift in Sources */
,
65B965871B8BEEC60055B139
/* SideNavController.swift in Sources */
,
65B965871B8BEEC60055B139
/* SideNav
igationView
Controller.swift in Sources */
,
9638326C1B88E5BF0015F710
/* FlatButton.swift in Sources */
,
963832711B88E5BF0015F710
/* MaterialText.swift in Sources */
,
9638326A1B88E5BF0015F710
/* CapturePreview.swift in Sources */
,
...
...
README.md
View file @
b061cb71
...
...
@@ -170,7 +170,7 @@ Add a sleek Side Navigation to give your users a wonderful experience.
```swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
sideNav = SideNavController(mainViewController: MainViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController())
sideNav = SideNav
igationView
Controller(mainViewController: MainViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController())
sideNav!.delegate = self
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = sideNav
...
...
Source/BasicCardView.swift
View file @
b061cb71
...
...
@@ -32,12 +32,12 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
/**
:name: verticalSpace
*/
public
var
verticalSpace
:
CGFloat
=
8
public
var
verticalSpace
:
CGFloat
=
MaterialTheme
.
verticalSpace
/**
:name: horizontalSpace
*/
public
var
horizontalSpace
:
CGFloat
=
8
public
var
horizontalSpace
:
CGFloat
=
MaterialTheme
.
horizontalSpace
/**
:name: titleLabelContainer
...
...
@@ -72,8 +72,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
t
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
t
.
textColor
=
MaterialTheme
.
white
.
color
t
.
backgroundColor
=
MaterialTheme
.
clear
.
color
t
.
font
=
Roboto
.
medium
WithSize
(
18
)
t
.
font
=
Roboto
.
medium
t
.
numberOfLines
=
1
t
.
lineBreakMode
=
.
ByTruncatingTail
prepareCard
()
}
else
{
titleLabelContainer
?
.
removeFromSuperview
()
...
...
@@ -110,9 +111,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
textColor
=
MaterialTheme
.
white
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
font
=
Roboto
.
light
WithSize
(
16
)
l
.
font
=
Roboto
.
light
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
By
WordWrapping
l
.
lineBreakMode
=
.
By
TruncatingTail
prepareCard
()
}
else
{
detailLabelContainer
?
.
removeFromSuperview
()
...
...
@@ -161,7 +162,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
/**
:name: rightButtons
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
...
...
@@ -179,6 +180,39 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
}
/**
:name: init
*/
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
:name: init
*/
public
convenience
init
?(
titleLabel
:
UILabel
?
=
nil
,
detailLabel
:
UILabel
?
=
nil
,
divider
:
UIView
?
=
nil
,
leftButtons
:
Array
<
MaterialButton
>
?
=
nil
,
rightButtons
:
Array
<
MaterialButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
prepareProperties
(
titleLabel
,
detailLabel
:
detailLabel
,
divider
:
divider
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
/**
:name: init
*/
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
CGRectZero
)
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
titleLabel
:
UILabel
?,
detailLabel
:
UILabel
?,
divider
:
UIView
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
self
.
titleLabel
=
titleLabel
self
.
detailLabel
=
detailLabel
self
.
divider
=
divider
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
}
//
// :name: prepareView
//
...
...
@@ -208,9 +242,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
verticalFormat
+=
"[titleLabelContainer]"
views
[
"titleLabelContainer"
]
=
titleLabelContainer
!
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
+
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
// common text
Layout
.
height
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
height
:
1.5
*
titleLabel
!.
font
.
pointSize
)
Layout
.
expandToParentVerticallyWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentHorizontallyWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
}
// detail
...
...
@@ -221,10 +256,11 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
views
[
"detailLabelContainer"
]
=
detailLabelContainer
!
// text
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
[
"detailLabel"
:
detailLabel
!
])
)
Layout
.
expandToParentHorizontallyWithPad
(
detailLabelContainer
!
,
child
:
detailLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailLabelHeight"
:
maximumDetailLabelHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
}
// buttons
if
nil
!=
buttonsContainer
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
...
...
@@ -247,7 +283,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"-(horizontalSpace)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
horizont
alSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
vertic
alSpace
,
bottom
:
verticalSpace
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
buttonViews
))
}
...
...
@@ -261,7 +297,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"[button
\(
i
)
]-(horizontalSpace)-"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
horizont
alSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
vertic
alSpace
,
bottom
:
verticalSpace
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
+
"|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
buttonViews
))
}
...
...
Source/ImageCardView.swift
View file @
b061cb71
...
...
@@ -32,12 +32,12 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: verticalSpace
*/
public
var
verticalSpace
:
CGFloat
=
8
public
var
verticalSpace
:
CGFloat
=
MaterialTheme
.
verticalSpace
/**
:name: horizontalSpace
*/
public
var
horizontalSpace
:
CGFloat
=
8
public
var
horizontalSpace
:
CGFloat
=
MaterialTheme
.
horizontalSpace
/**
:name: shadow
...
...
@@ -113,8 +113,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
titleLabelContainer
!.
addSubview
(
t
)
t
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
t
.
backgroundColor
=
MaterialTheme
.
clear
.
color
t
.
font
=
Roboto
.
medium
WithSize
(
18
)
t
.
font
=
Roboto
.
medium
t
.
numberOfLines
=
1
t
.
lineBreakMode
=
.
ByTruncatingTail
if
nil
==
imageView
{
titleLabelContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
t
.
textColor
=
MaterialTheme
.
black
.
color
...
...
@@ -160,9 +161,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
textColor
=
MaterialTheme
.
black
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
font
=
Roboto
.
light
WithSize
(
16
)
l
.
font
=
Roboto
.
light
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
By
WordWrapping
l
.
lineBreakMode
=
.
By
TruncatingTail
prepareCard
()
}
else
{
detailLabelContainer
?
.
removeFromSuperview
()
...
...
@@ -192,7 +193,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
public
private(set)
var
buttonsContainer
:
UIView
?
/**
:name: leftButtons
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
...
...
@@ -229,6 +230,40 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
}
}
/**
:name: init
*/
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
:name: init
*/
public
convenience
init
?(
imageView
:
UIImageView
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
detailLabel
:
UILabel
?
=
nil
,
divider
:
UIView
?
=
nil
,
leftButtons
:
Array
<
MaterialButton
>
?
=
nil
,
rightButtons
:
Array
<
MaterialButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
prepareProperties
(
imageView
,
titleLabel
:
titleLabel
,
detailLabel
:
detailLabel
,
divider
:
divider
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
/**
:name: init
*/
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
CGRectZero
)
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
imageView
:
UIImageView
?,
titleLabel
:
UILabel
?,
detailLabel
:
UILabel
?,
divider
:
UIView
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
self
.
imageView
=
imageView
self
.
titleLabel
=
titleLabel
self
.
detailLabel
=
detailLabel
self
.
divider
=
divider
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
}
//
// :name: prepareView
//
...
...
@@ -270,21 +305,16 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
layoutConstraints
+=
Layout
.
constraint
(
"H:|[titleLabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabelContainer"
:
titleLabelContainer
!
])
verticalFormat
+=
"[titleLabelContainer]"
views
[
"titleLabelContainer"
]
=
titleLabelContainer
!
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
+
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
}
else
{
//container
Layout
.
alignFromBottomLeft
(
imageViewContainer
!
,
child
:
titleLabelContainer
!
)
Layout
.
expandToParentHorizontally
(
imageViewContainer
!
,
child
:
titleLabelContainer
!
)
Layout
.
height
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
height
:
titleLabel
!.
font
.
pointSize
+
verticalSpace
)
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
+
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
}
// common text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
Layout
.
height
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
height
:
1.5
*
titleLabel
!.
font
.
pointSize
)
Layout
.
expandToParentVerticallyWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentHorizontallyWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
}
// detail
...
...
@@ -295,10 +325,11 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
views
[
"detailLabelContainer"
]
=
detailLabelContainer
!
// text
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
[
"detailLabel"
:
detailLabel
!
])
)
Layout
.
expandToParentHorizontallyWithPad
(
detailLabelContainer
!
,
child
:
detailLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailLabelHeight"
:
maximumDetailLabelHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
}
// buttons
if
nil
!=
buttonsContainer
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
...
...
Source/Info.plist
View file @
b061cb71
...
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.
8
.0
<
/string
>
<
string
>
1.
9
.0
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
@@ -24,9 +24,11 @@
<
string
><
/string
>
<
k
e
y
>
UIAppFonts
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
Roboto-Medium.ttf
<
/string
>
<
string
>
Roboto-Regular.ttf
<
/string
>
<
string
>
Roboto-Thin
<
/string
>
<
string
>
Roboto-Light.ttf
<
/string
>
<
string
>
Roboto-Regular.ttf
<
/string
>
<
string
>
Roboto-Medium.ttf
<
/string
>
<
string
>
Roboto-Bold
<
/string
>
<
/
a
rr
a
y
>
<
/
d
i
c
t
>
<
/plist
>
Source/Layout.swift
View file @
b061cb71
...
...
@@ -132,12 +132,10 @@ public struct Layout {
}
/**
:name: alignAllSides
:name: alignAllSides
*/
public
static
func
alignAllSides
(
parent
:
UIView
,
child
:
UIView
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|[child]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|[child]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
expandToParent
(
parent
,
child
:
child
)
}
/**
...
...
Source/MaterialButton.swift
View file @
b061cb71
...
...
@@ -123,7 +123,7 @@ public class MaterialButton : UIButton {
layer
.
shadowColor
=
MaterialTheme
.
black
.
color
.
CGColor
layer
.
shadowOffset
=
CGSizeMake
(
0.1
,
0.1
)
layer
.
shadowOpacity
=
0.4
layer
.
shadowRadius
=
3
layer
.
shadowRadius
=
2
}
//
...
...
Source/MaterialCardView.swift
View file @
b061cb71
...
...
@@ -122,7 +122,7 @@ public class MaterialCardView : UIView {
layer
.
shadowColor
=
MaterialTheme
.
black
.
color
.
CGColor
layer
.
shadowOffset
=
CGSizeMake
(
0.1
,
0.1
)
layer
.
shadowOpacity
=
0.4
layer
.
shadowRadius
=
3
layer
.
shadowRadius
=
2
}
//
...
...
Source/MaterialTheme.swift
View file @
b061cb71
...
...
@@ -18,7 +18,10 @@
import
UIKit
public
struct
MaterialTheme
{
public
struct
MaterialTheme
{}
// colors
extension
MaterialTheme
{
// clear
public
struct
clear
{
public
static
let
color
:
UIColor
=
UIColor
.
clearColor
()
...
...
@@ -366,3 +369,14 @@ public struct MaterialTheme {
public
static
let
darken4
:
UIColor
=
UIColor
(
red
:
38
/
255
,
green
:
50
/
255
,
blue
:
56
/
255
,
alpha
:
1
)
}
}
// spacing
extension
MaterialTheme
{
public
static
var
verticalSpace
:
CGFloat
=
8
public
static
var
horizontalSpace
:
CGFloat
=
2
*
verticalSpace
}
// fonts
extension
MaterialTheme
{
public
static
var
textFontSize
:
CGFloat
=
16
}
\ No newline at end of file
Source/Roboto-Bold.ttf
0 → 100644
View file @
b061cb71
File added
Source/Roboto-Thin.ttf
0 → 100644
View file @
b061cb71
File added
Source/Roboto.swift
View file @
b061cb71
...
...
@@ -19,24 +19,88 @@
import
UIKit
public
struct
Roboto
{
/**
:name: thin
*/
public
static
var
thin
:
UIFont
{
return
thinWithSize
(
MaterialTheme
.
textFontSize
)
}
/**
:name: thinWithSize
*/
public
static
func
thinWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
/**
:name: light
*/
public
static
var
light
:
UIFont
{
return
lightWithSize
(
MaterialTheme
.
textFontSize
)
}
/**
:name: lightWithSize
*/
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
/**
:name: regular
*/
public
static
var
regular
:
UIFont
{
return
regularWithSize
(
MaterialTheme
.
textFontSize
)
}
/**
:name: mediumWithSize
*/
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
/**
:name: medium
*/
public
static
var
medium
:
UIFont
{
return
mediumWithSize
(
MaterialTheme
.
textFontSize
)
}
/**
:name: regularWithSize
*/
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
/**
:name: bold
*/
public
static
var
bold
:
UIFont
{
return
boldWithSize
(
MaterialTheme
.
textFontSize
)
}
/**
:name: boldWithSize
*/
public
static
func
boldWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
}
Source/SideNavController.swift
→
Source/SideNav
igationView
Controller.swift
View file @
b061cb71
...
...
@@ -19,29 +19,32 @@
import
UIKit
extension
UIViewController
{
public
func
sideNavController
()
->
SideNavController
?
{
/**
:name: sideNavigationViewController
*/
public
var
sideNavigationViewController
:
SideNavigationViewController
?
{
var
viewController
:
UIViewController
?
=
self
while
viewController
!=
nil
{
if
viewController
is
SideNavController
{
return
viewController
as?
SideNavController
while
nil
!=
viewController
{
if
viewController
is
SideNav
igationView
Controller
{
return
viewController
as?
SideNav
igationView
Controller
}
viewController
=
viewController
?
.
parentViewController
}
return
nil
;
return
nil
}
}
public
enum
SideNavState
{
public
enum
SideNav
igationView
State
{
case
Opened
case
Closed
}
@objc(SideNavContainer)
public
class
SideNavContainer
:
Printable
{
@objc(SideNav
igationView
Container)
public
class
SideNav
igationView
Container
:
Printable
{
/**
:name: state
*/
public
private(set)
var
state
:
SideNavState
public
private(set)
var
state
:
SideNav
igationView
State
/**
:name: point
...
...
@@ -64,50 +67,50 @@ public class SideNavContainer : Printable {
/**
:name: init
*/
public
init
(
state
:
SideNavState
,
point
:
CGPoint
,
frame
:
CGRect
)
{
public
init
(
state
:
SideNav
igationView
State
,
point
:
CGPoint
,
frame
:
CGRect
)
{
self
.
state
=
state
self
.
point
=
point
self
.
frame
=
frame
}
}
@objc(SideNavDelegate)
public
protocol
SideNavDelegate
{
@objc(SideNav
igationView
Delegate)
public
protocol
SideNav
igationView
Delegate
{
// left
optional
func
sideNavDidBeginLeftPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidChangeLeftPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidEndLeftPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidOpenLeftViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidCloseLeftViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidTapLeft
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidBeginLeftPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidChangeLeftPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidEndLeftPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidOpenLeftViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidCloseLeftViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidTapLeft
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
// right
optional
func
sideNavDidBeginRightPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidChangeRightPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidEndRightPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidOpenRightViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidCloseRightViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidTapRight
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidBeginRightPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidChangeRightPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidEndRightPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidOpenRightViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidCloseRightViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidTapRight
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
// bottom
optional
func
sideNavDidBeginBottomPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidChangeBottomPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidEndBottomPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidOpenBottomViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidCloseBottomViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidTapBottom
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidBeginBottomPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidChangeBottomPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidEndBottomPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidOpenBottomViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidCloseBottomViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidTapBottom
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
// top
optional
func
sideNavDidBeginTopPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidChangeTopPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidEndTopPan
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidOpenTopViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidCloseTopViewContainer
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidTapTop
(
nav
:
SideNav
Controller
,
container
:
SideNav
Container
)
optional
func
sideNavDidBeginTopPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidChangeTopPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidEndTopPan
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidOpenTopViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidCloseTopViewContainer
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
optional
func
sideNavDidTapTop
(
nav
:
SideNav
igationViewController
,
container
:
SideNavigationView
Container
)
}
@objc(SideNavController)
public
class
SideNavController
:
UIViewController
,
UIGestureRecognizerDelegate
{
@objc(SideNav
igationView
Controller)
public
class
SideNav
igationView
Controller
:
UIViewController
,
UIGestureRecognizerDelegate
{
/**
:name: default options
*/
...
...
@@ -152,7 +155,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
/**
:name: delegate
*/
public
weak
var
delegate
:
SideNavDelegate
?
public
weak
var
delegate
:
SideNav
igationView
Delegate
?
/**
:name: isViewBasedAppearance
...
...
@@ -246,22 +249,22 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
/**
:name: leftContainer
*/
public
private(set)
var
leftContainer
:
SideNavContainer
?
public
private(set)
var
leftContainer
:
SideNav
igationView
Container
?
/**
:name: rightContainer
*/
public
private(set)
var
rightContainer
:
SideNavContainer
?
public
private(set)
var
rightContainer
:
SideNav
igationView
Container
?
/**
:name: bottomContainer
*/
public
private(set)
var
bottomContainer
:
SideNavContainer
?
public
private(set)
var
bottomContainer
:
SideNav
igationView
Container
?
/**
:name: topContainer
*/
public
private(set)
var
topContainer
:
SideNavContainer
?
public
private(set)
var
topContainer
:
SideNav
igationView
Container
?
/**
:name: mainViewController
...
...
@@ -1290,8 +1293,8 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
//
// :name: prepareContainer
//
private
func
prepareContainer
(
inout
container
:
SideNavContainer
?,
inout
viewContainer
:
UIView
?,
originX
:
CGFloat
,
originY
:
CGFloat
,
width
:
CGFloat
,
height
:
CGFloat
)
{
container
=
SideNavContainer
(
state
:
.
Closed
,
point
:
CGPointZero
,
frame
:
CGRectZero
)
private
func
prepareContainer
(
inout
container
:
SideNav
igationView
Container
?,
inout
viewContainer
:
UIView
?,
originX
:
CGFloat
,
originY
:
CGFloat
,
width
:
CGFloat
,
height
:
CGFloat
)
{
container
=
SideNav
igationView
Container
(
state
:
.
Closed
,
point
:
CGPointZero
,
frame
:
CGRectZero
)
var
b
:
CGRect
=
view
.
bounds
b
.
size
.
width
=
width
b
.
size
.
height
=
height
...
...
@@ -1306,7 +1309,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
//
// :name: prepareContainerToOpen
//
private
func
prepareContainerToOpen
(
inout
viewController
:
UIViewController
?,
inout
viewContainer
:
UIView
?,
state
:
SideNavState
)
{
private
func
prepareContainerToOpen
(
inout
viewController
:
UIViewController
?,
inout
viewContainer
:
UIView
?,
state
:
SideNav
igationView
State
)
{
addShadow
(
&
viewContainer
)
toggleStatusBar
(
hide
:
true
)
}
...
...
@@ -1314,7 +1317,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
//
// :name: prepareContainerToClose
//
private
func
prepareContainerToClose
(
inout
viewController
:
UIViewController
?,
state
:
SideNavState
)
{
private
func
prepareContainerToClose
(
inout
viewController
:
UIViewController
?,
state
:
SideNav
igationView
State
)
{
toggleStatusBar
()
}
...
...
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