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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
97 deletions
+195
-97
MaterialKit.xcodeproj/project.pbxproj
+4
-2
Source/BasicCard.swift
+23
-3
Source/ImageCard.swift
+159
-83
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 @@
...
@@ -10,7 +10,6 @@
657CD02A1B8EE0D3008C0029
/* MaterialCard.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A94D1081B8A3F5100F586A5
/* MaterialCard.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
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
,
);
};
};
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
,
);
};
};
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
,
);
};
};
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 */
;
};
65B9657E1B8A7C330055B139
/* MaterialButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B9657D1B8A7C330055B139
/* MaterialButton.swift */
;
};
65B965871B8BEEC60055B139
/* SideNavController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavController.swift */
;
};
65B965871B8BEEC60055B139
/* SideNavController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65B965861B8BEEC60055B139
/* SideNavController.swift */
;
};
...
@@ -35,6 +34,8 @@
...
@@ -35,6 +34,8 @@
963832881B8908180015F710
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
};
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
,
);
};
};
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 */
;
};
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 */
;
};
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
,
);
};
};
9A94D0F91B895C8C00F586A5
/* Roboto.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38531B89559900FE6B2D
/* Roboto.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
...
@@ -271,7 +272,8 @@
...
@@ -271,7 +272,8 @@
657CD02A1B8EE0D3008C0029
/* MaterialCard.swift in Headers */
,
657CD02A1B8EE0D3008C0029
/* MaterialCard.swift in Headers */
,
657CD02C1B8EE0D3008C0029
/* SideNavController.swift in Headers */
,
657CD02C1B8EE0D3008C0029
/* SideNavController.swift in Headers */
,
657CD02D1B8EE0D3008C0029
/* MaterialButton.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 */
,
657CD02F1B8EE0D3008C0029
/* ImageCard.swift in Headers */
,
);
);
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
Source/BasicCard.swift
View file @
12fd3d0c
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
import
UIKit
import
UIKit
public
class
BasicCard
:
MaterialCard
{
public
class
BasicCard
:
MaterialCard
,
Comparable
,
Equatable
{
//
//
// :name: layoutConstraints
// :name: layoutConstraints
//
//
...
@@ -104,7 +104,7 @@ public class BasicCard : MaterialCard {
...
@@ -104,7 +104,7 @@ public class BasicCard : MaterialCard {
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
textColor
=
MaterialTheme
.
white
.
color
l
.
textColor
=
MaterialTheme
.
white
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
l
.
font
=
Roboto
.
lightWithSize
(
1
2
)
l
.
font
=
Roboto
.
lightWithSize
(
1
6
)
l
.
numberOfLines
=
0
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
ByWordWrapping
l
.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
prepareCard
()
...
@@ -204,7 +204,7 @@ public class BasicCard : MaterialCard {
...
@@ -204,7 +204,7 @@ public class BasicCard : MaterialCard {
// text
// text
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
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
// detail
...
@@ -270,3 +270,23 @@ public class BasicCard : MaterialCard {
...
@@ -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 @@
...
@@ -18,7 +18,7 @@
import
UIKit
import
UIKit
public
class
ImageCard
:
MaterialCard
{
public
class
ImageCard
:
MaterialCard
,
Comparable
,
Equatable
{
//
//
// :name: layoutConstraints
// :name: layoutConstraints
//
//
...
@@ -29,31 +29,27 @@ public class ImageCard : MaterialCard {
...
@@ -29,31 +29,27 @@ public class ImageCard : MaterialCard {
//
//
internal
lazy
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
internal
lazy
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
/
/
/
**
// :name: detailTextContainer
:name: verticalSpace
/
/
*
/
internal
var
detailTextContainer
:
UIView
?
public
var
verticalSpace
:
CGFloat
=
8
//
/**
// :name: buttonsContainer
:name: maximumDetailHeight
//
*/
internal
var
buttonsContainer
:
UIView
?
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
{
didSet
{
imageView
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
false
==
shadow
?
removeShadow
()
:
prepareShadow
()
imageView
!.
contentMode
=
.
ScaleAspectFill
imageView
!.
userInteractionEnabled
=
false
imageView
!.
clipsToBounds
=
true
insertSubview
(
imageView
!
,
belowSubview
:
backgroundColorView
)
if
nil
!=
titleLabel
{
titleLabel
!.
removeFromSuperview
()
imageView
!.
addSubview
(
titleLabel
!
)
}
prepareCard
()
}
}
}
}
...
@@ -62,39 +58,59 @@ public class ImageCard : MaterialCard {
...
@@ -62,39 +58,59 @@ public class ImageCard : MaterialCard {
*/
*/
public
var
titleLabel
:
UILabel
?
{
public
var
titleLabel
:
UILabel
?
{
didSet
{
didSet
{
titleLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
if
let
t
=
titleLabel
{
titleLabel
!.
textColor
=
MaterialTheme
.
white
.
color
// container
titleLabel
!.
font
=
Roboto
.
regularWithSize
(
22
)
if
nil
==
titleLabelContainer
{
if
nil
==
imageView
{
titleLabelContainer
=
UIView
()
addSubview
(
titleLabel
!
)
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
{
}
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
{
didSet
{
if
let
l
=
detailLabel
{
// container
// container
if
nil
==
detailText
Container
{
if
nil
==
detailLabel
Container
{
detailText
Container
=
UIView
()
detailLabel
Container
=
UIView
()
detailText
Container
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailLabel
Container
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailTextContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
detailLabelContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
detailText
Container
!
)
addSubview
(
detailLabel
Container
!
)
}
}
// text
// text
detailTextContainer
!.
addSubview
(
detailTextLabel
!
)
detailLabelContainer
!.
addSubview
(
l
)
detailTextLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
l
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailTextLabel
!.
textColor
=
MaterialTheme
.
black
.
color
l
.
textColor
=
MaterialTheme
.
white
.
color
detailTextLabel
!.
font
=
Roboto
.
lightWithSize
(
16
)
l
.
backgroundColor
=
MaterialTheme
.
clear
.
color
detailTextLabel
!.
numberOfLines
=
0
l
.
font
=
Roboto
.
lightWithSize
(
12
)
detailTextLabel
!.
lineBreakMode
=
.
ByWordWrapping
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
prepareCard
()
}
else
{
detailLabelContainer
?
.
removeFromSuperview
()
}
}
}
}
}
...
@@ -103,25 +119,57 @@ public class ImageCard : MaterialCard {
...
@@ -103,25 +119,57 @@ public class ImageCard : MaterialCard {
*/
*/
public
var
divider
:
UIView
?
{
public
var
divider
:
UIView
?
{
didSet
{
didSet
{
divider
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
if
let
d
=
divider
{
divider
!.
backgroundColor
=
MaterialTheme
.
blueGrey
.
lighten4
d
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
addSubview
(
divider
!
)
d
.
backgroundColor
=
MaterialTheme
.
blueGrey
.
color
addSubview
(
d
)
prepareCard
()
}
else
{
divider
?
.
removeFromSuperview
()
}
}
}
/**
:name: buttonsContainer
*/
public
private(set)
var
buttonsContainer
:
UIView
?
/**
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
let
b
=
leftButtons
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
}
}
}
}
/**
/**
:name: b
uttons
:name: rightB
uttons
*/
*/
public
var
b
uttons
:
Array
<
MaterialButton
>
?
{
public
var
rightB
uttons
:
Array
<
MaterialButton
>
?
{
didSet
{
didSet
{
if
let
b
=
rightButtons
{
if
nil
==
buttonsContainer
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
addSubview
(
buttonsContainer
!
)
}
}
prepareCard
()
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
}
}
}
}
...
@@ -131,7 +179,7 @@ public class ImageCard : MaterialCard {
...
@@ -131,7 +179,7 @@ public class ImageCard : MaterialCard {
internal
override
func
prepareView
()
{
internal
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareShadow
()
prepareShadow
()
backgroundColor
=
MaterialTheme
.
clear
.
color
backgroundColor
=
MaterialTheme
.
blueGrey
.
darken1
}
}
//
//
...
@@ -139,6 +187,7 @@ public class ImageCard : MaterialCard {
...
@@ -139,6 +187,7 @@ public class ImageCard : MaterialCard {
//
//
internal
override
func
prepareCard
()
{
internal
override
func
prepareCard
()
{
super
.
prepareCard
()
super
.
prepareCard
()
// deactivate and clear all constraints
// deactivate and clear all constraints
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
layoutConstraints
.
removeAll
(
keepCapacity
:
false
)
layoutConstraints
.
removeAll
(
keepCapacity
:
false
)
...
@@ -146,66 +195,73 @@ public class ImageCard : MaterialCard {
...
@@ -146,66 +195,73 @@ public class ImageCard : MaterialCard {
// detect all components and create constraints
// detect all components and create constraints
var
verticalFormat
:
String
=
"V:|"
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
// title
if
nil
!=
titleLabel
{
if
nil
!=
titleLabel
Container
&&
nil
!=
titleLabel
{
if
nil
==
imageView
{
// container
layoutConstraints
+=
Layout
.
constraint
(
"H:|-(16)-[titleLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabel"
:
titleLabel
!
])
layoutConstraints
+=
Layout
.
constraint
(
"H:|[titleLabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabelContainer"
:
titleLabelContainer
!
])
verticalFormat
+=
"-(16)-[titleLabel(22)
]"
verticalFormat
+=
"[titleLabelContainer
]"
}
else
{
views
[
"titleLabelContainer"
]
=
titleLabelContainer
!
layoutConstraints
+=
Layout
.
constraint
(
"H:[titleLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabel"
:
titleLabel
!
])
Layout
.
alignFromBottomLeft
(
imageView
!
,
child
:
titleLabel
!
,
bottom
:
16
,
left
:
16
)
// text
}
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
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
// detail
if
nil
!=
detail
TextContainer
&&
nil
!=
detailText
Label
{
if
nil
!=
detail
LabelContainer
&&
nil
!=
detail
Label
{
// container
// container
layoutConstraints
+=
Layout
.
constraint
(
"H:|[detail
TextContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextContainer"
:
detailText
Container
!
])
layoutConstraints
+=
Layout
.
constraint
(
"H:|[detail
LabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailLabelContainer"
:
detailLabel
Container
!
])
verticalFormat
+=
"
-(0)-[detailText
Container]"
verticalFormat
+=
"
[detailLabel
Container]"
views
[
"detail
TextContainer"
]
=
detailText
Container
!
views
[
"detail
LabelContainer"
]
=
detailLabel
Container
!
// text
// text
layoutConstraints
+=
Layout
.
constraint
(
"H:|-(16)-[detailTextLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailTextLabel
!
])
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
layoutConstraints
+=
Layout
.
constraint
(
"V:|-(16)-[detailTextLabel(<=128)]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailTextLabel
!
])
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailHeight"
:
maximumDetailHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
views
[
"detailTextLabel"
]
=
detailTextLabel
!
}
}
if
nil
!=
buttons
&&
nil
!=
buttonsContainer
{
if
nil
!=
buttons
Container
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
// divider
if
nil
!=
divider
{
if
nil
!=
divider
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|[divider]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"divider"
:
divider
!
])
layoutConstraints
+=
Layout
.
constraint
(
"H:|[divider]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"divider"
:
divider
!
])
views
[
"divider"
]
=
divider
!
views
[
"divider"
]
=
divider
!
verticalFormat
+=
"
-(0)-
[divider(1)]"
verticalFormat
+=
"[divider(1)]"
}
}
//container
//container
layoutConstraints
+=
Layout
.
constraint
(
"H:|[buttonsContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"buttonsContainer"
:
buttonsContainer
!
])
layoutConstraints
+=
Layout
.
constraint
(
"H:|[buttonsContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"buttonsContainer"
:
buttonsContainer
!
])
verticalFormat
+=
"
-(0)-[buttonsContainer]|
"
verticalFormat
+=
"
[buttonsContainer]
"
views
[
"buttonsContainer"
]
=
buttonsContainer
!
views
[
"buttonsContainer"
]
=
buttonsContainer
!
// buttons
// leftButtons
if
nil
!=
leftButtons
{
var
horizontalFormat
:
String
=
"H:|"
var
horizontalFormat
:
String
=
"H:|"
var
buttonViews
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
buttonViews
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
for
var
i
:
Int
=
0
,
l
:
Int
=
b
uttons
!.
count
;
i
<
l
;
++
i
{
for
var
i
:
Int
=
0
,
l
:
Int
=
leftB
uttons
!.
count
;
i
<
l
;
++
i
{
let
button
:
MaterialButton
=
b
uttons
!
[
i
]
let
button
:
MaterialButton
=
leftB
uttons
!
[
i
]
buttonsContainer
!.
addSubview
(
button
)
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
buttonViews
[
"button
\(
i
)
"
]
=
button
views
[
"button
\(
i
)
"
]
=
button
as
AnyObject
horizontalFormat
+=
"-(verticalSpace)-[button
\(
i
)
]"
horizontalFormat
+=
"-(8)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
layoutConstraints
+=
Layout
.
constraint
(
"V:|-(8)-[button
\(
i
)
]-(8)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
buttonViews
))
}
}
layoutConstraints
+=
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
nil
,
views
:
buttonViews
)
}
else
{
// rightButtons
verticalFormat
+=
"|"
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
// combine constraints
if
0
<
layoutConstraints
.
count
{
if
0
<
layoutConstraints
.
count
{
...
@@ -214,3 +270,23 @@ public class ImageCard : MaterialCard {
...
@@ -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 {
...
@@ -85,7 +85,7 @@ public struct Layout {
/**
/**
:name: expandToParentWithPad
: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
]
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
(
"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
))
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
...
@@ -20,22 +20,22 @@ import UIKit
public
struct
Roboto
{
public
struct
Roboto
{
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
light
return
f
}
}
return
UIFont
.
systemFontOfSize
(
size
)
return
UIFont
.
systemFontOfSize
(
size
)
}
}
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
light
return
f
}
}
return
UIFont
.
systemFontOfSize
(
size
)
return
UIFont
.
systemFontOfSize
(
size
)
}
}
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
if
let
light
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
light
return
f
}
}
return
UIFont
.
systemFontOfSize
(
size
)
return
UIFont
.
systemFontOfSize
(
size
)
}
}
...
...
Source/TextView.swift
View file @
12fd3d0c
...
@@ -66,7 +66,7 @@ public class TextView: UITextView {
...
@@ -66,7 +66,7 @@ public class TextView: UITextView {
:name: placeholderColor
:name: placeholderColor
:description: The placeholder color.
:description: The placeholder color.
*/
*/
public
var
placeholderColor
:
UIColor
=
MaterialTheme
.
blueGrey
.
lighten
3
{
public
var
placeholderColor
:
UIColor
=
MaterialTheme
.
blueGrey
.
lighten
1
{
didSet
{
didSet
{
label
.
textColor
=
placeholderColor
label
.
textColor
=
placeholderColor
}
}
...
@@ -143,7 +143,7 @@ public class TextView: UITextView {
...
@@ -143,7 +143,7 @@ public class TextView: UITextView {
backgroundColor
=
MaterialTheme
.
clear
.
color
backgroundColor
=
MaterialTheme
.
clear
.
color
textColor
=
MaterialTheme
.
black
.
color
textColor
=
MaterialTheme
.
black
.
color
label
.
font
=
font
label
.
font
=
font
label
.
textColor
=
MaterialTheme
.
blueGrey
.
lighten3
label
.
textColor
=
placeholderColor
label
.
textAlignment
=
textAlignment
label
.
textAlignment
=
textAlignment
label
.
text
=
placeholder
label
.
text
=
placeholder
label
.
numberOfLines
=
0
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