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
03ada092
Commit
03ada092
authored
Aug 30, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated BasicCard
parent
48b9d4e9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
46 deletions
+78
-46
Source/BasicCard.swift
+74
-43
Source/FabButton.swift
+1
-0
Source/FlatButton.swift
+1
-1
Source/MaterialCard.swift
+1
-1
Source/RaisedButton.swift
+1
-1
No files found.
Source/BasicCard.swift
View file @
03ada092
...
...
@@ -29,49 +29,70 @@ public class BasicCard : 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: titleLabel
*/
public
var
titleLabel
:
UILabel
?
{
didSet
{
// container
if
nil
==
titleLabelContainer
{
titleLabelContainer
=
UIView
()
titleLabelContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
titleLabelContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
titleLabelContainer
!
)
}
// text
titleLabelContainer
!.
addSubview
(
titleLabel
!
)
titleLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
titleLabel
!.
textColor
=
MaterialTheme
.
white
.
color
titleLabel
!.
font
=
Roboto
.
regularWithSize
(
24
)
addSubview
(
titleLabel
!
)
prepareCard
()
titleLabel
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
titleLabel
!.
font
=
Roboto
.
regularWithSize
(
18
)
titleLabel
!.
numberOfLines
=
1
}
}
/**
:name: detailTextLabel
:name: detailLabelContainer
*/
public
var
detailTextLabel
:
UILabel
?
{
public
private(set)
var
detailLabelContainer
:
UIView
?
/**
:name: detailLabel
*/
public
var
detailLabel
:
UILabel
?
{
didSet
{
// container
if
nil
==
detail
Text
Container
{
detail
Text
Container
=
UIView
()
detail
Text
Container
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detail
TextContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
addSubview
(
detail
Text
Container
!
)
if
nil
==
detail
Label
Container
{
detail
Label
Container
=
UIView
()
detail
Label
Container
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detail
LabelContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
detail
Label
Container
!
)
}
// text
detailTextContainer
!.
addSubview
(
detailTextLabel
!
)
detailTextLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailTextLabel
!.
textColor
=
MaterialTheme
.
black
.
color
detailTextLabel
!.
font
=
Roboto
.
lightWithSize
(
14
)
detailTextLabel
!.
numberOfLines
=
0
detailTextLabel
!.
lineBreakMode
=
.
ByWordWrapping
detailLabelContainer
!.
addSubview
(
detailLabel
!
)
detailLabel
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
detailLabel
!.
textColor
=
MaterialTheme
.
white
.
color
detailLabel
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
detailLabel
!.
font
=
Roboto
.
lightWithSize
(
14
)
detailLabel
!.
numberOfLines
=
0
detailLabel
!.
lineBreakMode
=
.
ByWordWrapping
prepareCard
()
}
}
...
...
@@ -82,13 +103,18 @@ public class BasicCard : MaterialCard {
public
var
divider
:
UIView
?
{
didSet
{
divider
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
divider
!.
backgroundColor
=
MaterialTheme
.
blueGrey
.
lighten4
divider
!.
backgroundColor
=
MaterialTheme
.
blueGrey
.
color
addSubview
(
divider
!
)
prepareCard
()
}
}
/**
:name: buttonsContainer
*/
public
private(set)
var
buttonsContainer
:
UIView
?
/**
:name: buttons
*/
public
var
buttons
:
Array
<
MaterialButton
>
?
{
...
...
@@ -96,7 +122,7 @@ public class BasicCard : MaterialCard {
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
...
...
@@ -109,7 +135,7 @@ public class BasicCard : MaterialCard {
internal
override
func
prepareView
()
{
super
.
prepareView
()
prepareShadow
()
backgroundColor
=
MaterialTheme
.
clear
.
color
backgroundColor
=
MaterialTheme
.
blueGrey
.
darken1
}
//
...
...
@@ -117,6 +143,7 @@ public class BasicCard : MaterialCard {
//
internal
override
func
prepareCard
()
{
super
.
prepareCard
()
// deactivate and clear all constraints
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
layoutConstraints
.
removeAll
(
keepCapacity
:
false
)
...
...
@@ -125,25 +152,30 @@ public class BasicCard : MaterialCard {
var
verticalFormat
:
String
=
"V:|"
// title
if
nil
!=
titleLabel
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|-(16)-[titleLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"titleLabel"
:
titleLabel
!
])
verticalFormat
+=
"-(16)-[titleLabel(24)]"
views
[
"titleLabel"
]
=
titleLabel
!
if
nil
!=
titleLabelContainer
&&
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]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
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
+=
"[detail
Text
Container]"
views
[
"detail
TextContainer"
]
=
detailText
Container
!
layoutConstraints
+=
Layout
.
constraint
(
"H:|[detail
LabelContainer]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailLabelContainer"
:
detailLabel
Container
!
])
verticalFormat
+=
"[detail
Label
Container]"
views
[
"detail
LabelContainer"
]
=
detailLabel
Container
!
// text
detail
TextContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(16)-[detailTextLabel]-(16)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailText
Label
!
]))
detail
TextContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(16)-[detailTextLabel(<=128)]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"detailTextLabel"
:
detailText
Label
!
]))
detail
LabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
[
"detailLabel"
:
detail
Label
!
]))
detail
LabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailHeight"
:
maximumDetailHeight
],
views
:
[
"detailLabel"
:
detail
Label
!
]))
}
if
nil
!=
buttons
&&
nil
!=
buttonsContainer
{
if
nil
!=
buttons
Container
&&
nil
!=
buttons
{
// divider
if
nil
!=
divider
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|[divider]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"divider"
:
divider
!
])
...
...
@@ -163,11 +195,10 @@ public class BasicCard : MaterialCard {
let
button
:
MaterialButton
=
buttons
!
[
i
]
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"-(8)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
8
,
bottom
:
8
)
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
nil
,
views
:
buttonViews
))
horizontalFormat
+=
"-(verticalSpace)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
}
layoutConstraints
+=
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
nil
,
views
:
buttonViews
)
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
buttonViews
)
)
}
verticalFormat
+=
"|"
...
...
Source/FabButton.swift
View file @
03ada092
...
...
@@ -26,6 +26,7 @@ public class FabButton : MaterialButton {
super
.
prepareView
()
setTitleColor
(
MaterialTheme
.
white
.
color
,
forState
:
.
Normal
)
backgroundColor
=
MaterialTheme
.
red
.
darken1
contentEdgeInsets
=
UIEdgeInsetsMake
(
0
,
0
,
0
,
0
)
}
//
...
...
Source/FlatButton.swift
View file @
03ada092
...
...
@@ -27,7 +27,7 @@ public class FlatButton : MaterialButton {
setTitleColor
(
MaterialTheme
.
indigo
.
darken1
,
forState
:
.
Normal
)
pulseColor
=
MaterialTheme
.
indigo
.
darken1
backgroundColor
=
MaterialTheme
.
clear
.
color
contentEdgeInsets
=
UIEdgeInsetsMake
(
10
,
20
,
10
,
20
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
4
,
4
,
4
,
4
)
}
//
...
...
Source/MaterialCard.swift
View file @
03ada092
...
...
@@ -117,6 +117,7 @@ public class MaterialCard : UIView {
layer
.
shadowOffset
=
CGSizeMake
(
0.05
,
0.05
)
layer
.
shadowOpacity
=
0.1
layer
.
shadowRadius
=
3
layer
.
shadowPath
=
UIBezierPath
(
rect
:
bounds
)
.
CGPath
}
//
...
...
@@ -124,7 +125,6 @@ public class MaterialCard : UIView {
//
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
layer
.
shadowPath
=
UIBezierPath
(
rect
:
bounds
)
.
CGPath
}
//
...
...
Source/RaisedButton.swift
View file @
03ada092
...
...
@@ -26,7 +26,7 @@ public class RaisedButton : MaterialButton {
super
.
prepareView
()
setTitleColor
(
MaterialTheme
.
white
.
color
,
forState
:
.
Normal
)
backgroundColor
=
MaterialTheme
.
indigo
.
darken1
contentEdgeInsets
=
UIEdgeInsetsMake
(
10
,
20
,
10
,
20
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
4
,
4
,
4
,
4
)
}
//
...
...
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