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