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
12fd3d0c
Commit
12fd3d0c
authored
Sep 01, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: progression updates
parent
4683c8fa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
211 additions
and
113 deletions
+211
-113
MaterialKit.xcodeproj/project.pbxproj
+4
-2
Source/BasicCard.swift
+23
-3
Source/ImageCard.swift
+175
-99
Source/Layout.swift
+1
-1
Source/Roboto.swift
+6
-6
Source/TextView.swift
+2
-2
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
12fd3d0c
...
...
@@ -10,7 +10,6 @@
657CD02A1B8EE0D3008C0029
/* MaterialCard.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A94D1081B8A3F5100F586A5
/* MaterialCard.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02C1B8EE0D3008C0029
/* SideNavController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02D1B8EE0D3008C0029
/* MaterialButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02E1B8EE0D3008C0029
/* (null) in Headers */
=
{
isa
=
PBXBuildFile
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
657CD02F1B8EE0D3008C0029
/* ImageCard.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A94D10A1B8A485C00F586A5
/* ImageCard.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 */
;
};
...
...
@@ -35,6 +34,8 @@
963832881B8908180015F710
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
};
963832891B89097D0015F710
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96B57D4E1B90AF7D00DE7BBB
/* MaterialTheme.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96B57D4D1B90AF7D00DE7BBB
/* MaterialTheme.swift */
;
};
96C910ED1B95804B00E7CE5C
/* MaterialTheme.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96B57D4D1B90AF7D00DE7BBB
/* MaterialTheme.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96C910EE1B95804B00E7CE5C
/* ImageRevealCard.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3A3B6F1B8EB582005F16BC
/* ImageRevealCard.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A3A3B701B8EB582005F16BC
/* ImageRevealCard.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3A3B6F1B8EB582005F16BC
/* ImageRevealCard.swift */
;
};
9A94D0F91B895C8C00F586A5
/* Roboto.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38531B89559900FE6B2D
/* Roboto.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
...
...
@@ -271,7 +272,8 @@
657CD02A1B8EE0D3008C0029
/* MaterialCard.swift in Headers */
,
657CD02C1B8EE0D3008C0029
/* SideNavController.swift in Headers */
,
657CD02D1B8EE0D3008C0029
/* MaterialButton.swift in Headers */
,
657CD02E1B8EE0D3008C0029
/* (null) in Headers */
,
96C910ED1B95804B00E7CE5C
/* MaterialTheme.swift in Headers */
,
96C910EE1B95804B00E7CE5C
/* ImageRevealCard.swift in Headers */
,
657CD02F1B8EE0D3008C0029
/* ImageCard.swift in Headers */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
Source/BasicCard.swift
View file @
12fd3d0c
...
...
@@ -18,7 +18,7 @@
import
UIKit
public
class
BasicCard
:
MaterialCard
{
public
class
BasicCard
:
MaterialCard
,
Comparable
,
Equatable
{
//
// :name: layoutConstraints
//
...
...
@@ -104,7 +104,7 @@ public class BasicCard : MaterialCard {
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
textColor
=
MaterialTheme
.
white
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
font
=
Roboto
.
lightWithSize
(
1
2
)
l
.
font
=
Roboto
.
lightWithSize
(
1
6
)
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
...
...
@@ -204,7 +204,7 @@ public class BasicCard : MaterialCard {
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
],
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
!
]))
}
// detail
...
...
@@ -270,3 +270,23 @@ public class BasicCard : MaterialCard {
}
}
}
public
func
==
(
lhs
:
BasicCard
,
rhs
:
BasicCard
)
->
Bool
{
return
lhs
.
tag
==
rhs
.
tag
}
public
func
<=
(
lhs
:
BasicCard
,
rhs
:
BasicCard
)
->
Bool
{
return
lhs
.
tag
<=
rhs
.
tag
}
public
func
>=
(
lhs
:
BasicCard
,
rhs
:
BasicCard
)
->
Bool
{
return
lhs
.
tag
>=
rhs
.
tag
}
public
func
>
(
lhs
:
BasicCard
,
rhs
:
BasicCard
)
->
Bool
{
return
lhs
.
tag
>
rhs
.
tag
}
public
func
<
(
lhs
:
BasicCard
,
rhs
:
BasicCard
)
->
Bool
{
return
lhs
.
tag
<
rhs
.
tag
}
Source/ImageCard.swift
View file @
12fd3d0c
...
...
@@ -18,7 +18,7 @@
import
UIKit
public
class
ImageCard
:
MaterialCard
{
public
class
ImageCard
:
MaterialCard
,
Comparable
,
Equatable
{
//
// :name: layoutConstraints
//
...
...
@@ -29,99 +29,147 @@ public class ImageCard : MaterialCard {
//
internal
lazy
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
/
/
// :name: detailTextContainer
/
/
internal
var
detailTextContainer
:
UIView
?
/
**
:name: verticalSpace
*
/
public
var
verticalSpace
:
CGFloat
=
8
//
// :name: buttonsContainer
//
internal
var
buttonsContainer
:
UIView
?
/**
:name: maximumDetailHeight
*/
public
var
maximumDetailHeight
:
CGFloat
=
144
/**
:name: titleLabelContainer
*/
public
private(set)
var
titleLabelContainer
:
UIView
?
/**
:name: imageVie
w
:name: shado
w
*/
public
var
imageView
:
UIImageView
?
{
public
var
shadow
:
Bool
=
true
{
didSet
{
imageView
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
imageView
!.
contentMode
=
.
ScaleAspectFill
imageView
!.
userInteractionEnabled
=
false
imageView
!.
clipsToBounds
=
true
insertSubview
(
imageView
!
,
belowSubview
:
backgroundColorView
)
if
nil
!=
titleLabel
{
titleLabel
!.
removeFromSuperview
()
imageView
!.
addSubview
(
titleLabel
!
)
}
prepareCard
()
false
==
shadow
?
removeShadow
()
:
prepareShadow
()
}
}
/**
:name: titleLabel
:name: titleLabel
*/
public
var
titleLabel
:
UILabel
?
{
didSet
{
titleLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
titleLabel
!.
textColor
=
MaterialTheme
.
white
.
color
titleLabel
!.
font
=
Roboto
.
regularWithSize
(
22
)
if
nil
==
imageView
{
addSubview
(
titleLabel
!
)
if
let
t
=
titleLabel
{
// container
if
nil
==
titleLabelContainer
{
titleLabelContainer
=
UIView
()
titleLabelContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
titleLabelContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
titleLabelContainer
!
)
}
// text
titleLabelContainer
!.
addSubview
(
t
)
t
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
t
.
textColor
=
MaterialTheme
.
white
.
color
t
.
backgroundColor
=
MaterialTheme
.
clear
.
color
t
.
font
=
Roboto
.
mediumWithSize
(
18
)
t
.
numberOfLines
=
1
}
else
{
imageView
!.
addSubview
(
titleLabel
!
)
titleLabelContainer
?
.
removeFromSuperview
(
)
}
prepareCard
()
}
}
/**
:name: detailTextLabel
:name: detailLabelContainer
*/
public
var
detailTextLabel
:
UILabel
?
{
public
private(set)
var
detailLabelContainer
:
UIView
?
/**
:name: detailLabel
*/
public
var
detailLabel
:
UILabel
?
{
didSet
{
// container
if
nil
==
detailTextContainer
{
detailTextContainer
=
UIView
()
detailTextContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailTextContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
addSubview
(
detailTextContainer
!
)
if
let
l
=
detailLabel
{
// container
if
nil
==
detailLabelContainer
{
detailLabelContainer
=
UIView
()
detailLabelContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailLabelContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
detailLabelContainer
!
)
}
// text
detailLabelContainer
!.
addSubview
(
l
)
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
textColor
=
MaterialTheme
.
white
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
font
=
Roboto
.
lightWithSize
(
12
)
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
}
else
{
detailLabelContainer
?
.
removeFromSuperview
()
}
// text
detailTextContainer
!.
addSubview
(
detailTextLabel
!
)
detailTextLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailTextLabel
!.
textColor
=
MaterialTheme
.
black
.
color
detailTextLabel
!.
font
=
Roboto
.
lightWithSize
(
16
)
detailTextLabel
!.
numberOfLines
=
0
detailTextLabel
!.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
}
}
/**
:name: divider
:name: divider
*/
public
var
divider
:
UIView
?
{
didSet
{
divider
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
divider
!.
backgroundColor
=
MaterialTheme
.
blueGrey
.
lighten4
addSubview
(
divider
!
)
prepareCard
()
if
let
d
=
divider
{
d
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
d
.
backgroundColor
=
MaterialTheme
.
blueGrey
.
color
addSubview
(
d
)
prepareCard
()
}
else
{
divider
?
.
removeFromSuperview
()
}
}
}
/**
:name: buttons
:name: buttonsContainer
*/
public
var
buttons
:
Array
<
MaterialButton
>
?
{
public
private(set)
var
buttonsContainer
:
UIView
?
/**
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
addSubview
(
buttonsContainer
!
)
if
let
b
=
leftButtons
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
}
}
/**
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
let
b
=
rightButtons
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
...
...
@@ -131,7 +179,7 @@ public class ImageCard : MaterialCard {
internal
override
func
prepareView
()
{
super
.
prepareView
()
prepareShadow
()
backgroundColor
=
MaterialTheme
.
clear
.
color
backgroundColor
=
MaterialTheme
.
blueGrey
.
darken1
}
//
...
...
@@ -139,6 +187,7 @@ public class ImageCard : MaterialCard {
//
internal
override
func
prepareCard
()
{
super
.
prepareCard
()
// deactivate and clear all constraints
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
layoutConstraints
.
removeAll
(
keepCapacity
:
false
)
...
...
@@ -146,67 +195,74 @@ public class ImageCard : MaterialCard {
// detect all components and create constraints
var
verticalFormat
:
String
=
"V:|"
if
nil
!=
imageView
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|[imageView]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"imageView"
:
imageView
!
])
verticalFormat
+=
"[imageView(200)]"
views
[
"imageView"
]
=
imageView
!
}
// title
if
nil
!=
titleLabel
{
if
nil
==
imageView
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|-(16)-[titleLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabel"
:
titleLabel
!
])
verticalFormat
+=
"-(16)-[titleLabel(22)
]"
}
else
{
layoutConstraints
+=
Layout
.
constraint
(
"H:[titleLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabel"
:
titleLabel
!
])
Layout
.
alignFromBottomLeft
(
imageView
!
,
child
:
titleLabel
!
,
bottom
:
16
,
left
:
16
)
}
views
[
"titleLabel"
]
=
titleLabel
!
if
nil
!=
titleLabel
Container
&&
nil
!=
titleLabel
{
// container
layoutConstraints
+=
Layout
.
constraint
(
"H:|[titleLabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabelContainer"
:
titleLabelContainer
!
])
verticalFormat
+=
"[titleLabelContainer
]"
views
[
"titleLabelContainer"
]
=
titleLabelContainer
!
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
}
// detail
s
if
nil
!=
detail
TextContainer
&&
nil
!=
detailText
Label
{
// detail
if
nil
!=
detail
LabelContainer
&&
nil
!=
detail
Label
{
// container
layoutConstraints
+=
Layout
.
constraint
(
"H:|[detail
TextContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextContainer"
:
detailText
Container
!
])
verticalFormat
+=
"
-(0)-[detailText
Container]"
views
[
"detail
TextContainer"
]
=
detailText
Container
!
layoutConstraints
+=
Layout
.
constraint
(
"H:|[detail
LabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailLabelContainer"
:
detailLabel
Container
!
])
verticalFormat
+=
"
[detailLabel
Container]"
views
[
"detail
LabelContainer"
]
=
detailLabel
Container
!
// text
layoutConstraints
+=
Layout
.
constraint
(
"H:|-(16)-[detailTextLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailTextLabel
!
])
layoutConstraints
+=
Layout
.
constraint
(
"V:|-(16)-[detailTextLabel(<=128)]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailTextLabel
!
])
views
[
"detailTextLabel"
]
=
detailTextLabel
!
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailHeight"
:
maximumDetailHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
}
if
nil
!=
buttons
&&
nil
!=
buttonsContainer
{
if
nil
!=
buttons
Container
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|[divider]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"divider"
:
divider
!
])
views
[
"divider"
]
=
divider
!
verticalFormat
+=
"
-(0)-
[divider(1)]"
verticalFormat
+=
"[divider(1)]"
}
//container
layoutConstraints
+=
Layout
.
constraint
(
"H:|[buttonsContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"buttonsContainer"
:
buttonsContainer
!
])
verticalFormat
+=
"
-(0)-[buttonsContainer]|
"
verticalFormat
+=
"
[buttonsContainer]
"
views
[
"buttonsContainer"
]
=
buttonsContainer
!
// buttons
var
horizontalFormat
:
String
=
"H:|"
var
buttonViews
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
for
var
i
:
Int
=
0
,
l
:
Int
=
buttons
!.
count
;
i
<
l
;
++
i
{
let
button
:
MaterialButton
=
buttons
!
[
i
]
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
views
[
"button
\(
i
)
"
]
=
button
as
AnyObject
horizontalFormat
+=
"-(8)-[button
\(
i
)
]"
layoutConstraints
+=
Layout
.
constraint
(
"V:|-(8)-[button
\(
i
)
]-(8)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
)
// leftButtons
if
nil
!=
leftButtons
{
var
horizontalFormat
:
String
=
"H:|"
var
buttonViews
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
for
var
i
:
Int
=
0
,
l
:
Int
=
leftButtons
!.
count
;
i
<
l
;
++
i
{
let
button
:
MaterialButton
=
leftButtons
!
[
i
]
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"-(verticalSpace)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
buttonViews
))
}
layoutConstraints
+=
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
nil
,
views
:
buttonViews
)
}
else
{
verticalFormat
+=
"|"
// rightButtons
if
nil
!=
rightButtons
{
var
horizontalFormat
:
String
=
"H:"
var
buttonViews
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
for
var
i
:
Int
=
0
,
l
:
Int
=
rightButtons
!.
count
;
i
<
l
;
++
i
{
let
button
:
MaterialButton
=
rightButtons
!
[
i
]
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"[button
\(
i
)
]-(verticalSpace)-"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
+
"|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
buttonViews
))
}
}
verticalFormat
+=
"|"
// combine constraints
if
0
<
layoutConstraints
.
count
{
layoutConstraints
+=
Layout
.
constraint
(
verticalFormat
,
options
:
nil
,
metrics
:
nil
,
views
:
views
)
...
...
@@ -214,3 +270,23 @@ public class ImageCard : MaterialCard {
}
}
}
public
func
==
(
lhs
:
ImageCard
,
rhs
:
ImageCard
)
->
Bool
{
return
lhs
.
tag
==
rhs
.
tag
}
public
func
<=
(
lhs
:
ImageCard
,
rhs
:
ImageCard
)
->
Bool
{
return
lhs
.
tag
<=
rhs
.
tag
}
public
func
>=
(
lhs
:
ImageCard
,
rhs
:
ImageCard
)
->
Bool
{
return
lhs
.
tag
>=
rhs
.
tag
}
public
func
>
(
lhs
:
ImageCard
,
rhs
:
ImageCard
)
->
Bool
{
return
lhs
.
tag
>
rhs
.
tag
}
public
func
<
(
lhs
:
ImageCard
,
rhs
:
ImageCard
)
->
Bool
{
return
lhs
.
tag
<
rhs
.
tag
}
Source/Layout.swift
View file @
12fd3d0c
...
...
@@ -85,7 +85,7 @@ public struct Layout {
/**
:name: expandToParentWithPad
*/
public
static
func
expandToParentWithPad
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
,
top
:
CGFloat
=
0
)
{
public
static
func
expandToParentWithPad
(
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
:
nil
,
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
nil
,
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
views
))
...
...
Source/Roboto.swift
View file @
12fd3d0c
...
...
@@ -20,22 +20,22 @@ import UIKit
public
struct
Roboto
{
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
light
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
light
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
light
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
}
return
UIFont
.
systemFontOfSize
(
size
)
}
...
...
Source/TextView.swift
View file @
12fd3d0c
...
...
@@ -66,7 +66,7 @@ public class TextView: UITextView {
:name: placeholderColor
:description: The placeholder color.
*/
public
var
placeholderColor
:
UIColor
=
MaterialTheme
.
blueGrey
.
lighten
3
{
public
var
placeholderColor
:
UIColor
=
MaterialTheme
.
blueGrey
.
lighten
1
{
didSet
{
label
.
textColor
=
placeholderColor
}
...
...
@@ -143,7 +143,7 @@ public class TextView: UITextView {
backgroundColor
=
MaterialTheme
.
clear
.
color
textColor
=
MaterialTheme
.
black
.
color
label
.
font
=
font
label
.
textColor
=
MaterialTheme
.
blueGrey
.
lighten3
label
.
textColor
=
placeholderColor
label
.
textAlignment
=
textAlignment
label
.
text
=
placeholder
label
.
numberOfLines
=
0
...
...
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