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
eebaf7d9
Commit
eebaf7d9
authored
Sep 05, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fully working versino of ImageCardView
parent
0e404001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
35 deletions
+30
-35
Source/BasicCardView.swift
+11
-10
Source/ImageCardView.swift
+19
-25
No files found.
Source/BasicCardView.swift
View file @
eebaf7d9
...
...
@@ -202,15 +202,6 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
//
// :name: prepareView
//
internal
override
func
prepareView
()
{
super
.
prepareView
()
prepareShadow
()
backgroundColor
=
MaterialTheme
.
blueGrey
.
darken1
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
titleLabel
:
UILabel
?,
detailLabel
:
UILabel
?,
divider
:
UIView
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
...
...
@@ -222,6 +213,15 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
//
// :name: prepareView
//
internal
override
func
prepareView
()
{
super
.
prepareView
()
prepareShadow
()
backgroundColor
=
MaterialTheme
.
blueGrey
.
darken1
}
//
// :name: prepareCard
//
internal
override
func
prepareCard
()
{
...
...
@@ -243,7 +243,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// 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)]
|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
titleLabel
!.
font
.
pointSize
+
verticalSpac
e
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[titleLabel(height)]
-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"height"
:
1.5
*
titleLabel
!.
font
.
pointSiz
e
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
}
// detail
...
...
@@ -258,6 +258,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
Layout
.
expandToParentHorizontallyWithPad
(
detailLabelContainer
!
,
child
:
detailLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
}
// buttons
if
nil
!=
buttonsContainer
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
...
...
Source/ImageCardView.swift
View file @
eebaf7d9
...
...
@@ -239,32 +239,30 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: init
*/
public
convenience
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
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
)
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: init
*/
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
if
CGRectZero
==
frame
{
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
}
}
//
// :name: prepareView
//
...
...
@@ -306,21 +304,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
...
...
@@ -331,10 +324,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
!
])
)
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailLabelHeight"
:
maximumDetailLabelHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
])
)
Layout
.
expandToParentVerticallyWithPad
(
detailLabelContainer
!
,
child
:
detailLabel
!
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentHorizontallyWithPad
(
detailLabelContainer
!
,
child
:
detailLabel
!
,
left
:
horizontalSpace
,
right
:
horizontalSpace
)
}
// buttons
if
nil
!=
buttonsContainer
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
...
...
@@ -357,7 +351,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"-(horizontalSpace)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
/
2
,
bottom
:
verticalSpace
/
2
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
buttonViews
))
}
...
...
@@ -371,7 +365,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
addSubview
(
button
)
buttonViews
[
"button
\(
i
)
"
]
=
button
horizontalFormat
+=
"[button
\(
i
)
]-(horizontalSpace)-"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
/
2
,
bottom
:
verticalSpace
/
2
)
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
+
"|"
,
options
:
nil
,
metrics
:
[
"horizontalSpace"
:
horizontalSpace
],
views
:
buttonViews
))
}
...
...
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