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
33260ec0
Commit
33260ec0
authored
Aug 30, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated buttons layout for BasicCard
parent
03ada092
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
14 deletions
+45
-14
Source/BasicCard.swift
+44
-13
Source/MaterialCard.swift
+1
-1
No files found.
Source/BasicCard.swift
View file @
33260ec0
...
...
@@ -115,9 +115,24 @@ public class BasicCard : MaterialCard {
public
private(set)
var
buttonsContainer
:
UIView
?
/**
:name:
b
uttons
:name:
leftB
uttons
*/
public
var
buttons
:
Array
<
MaterialButton
>
?
{
public
var
leftButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
buttonsContainer
!.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
clear
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
}
}
/**
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
MaterialButton
>
?
{
didSet
{
if
nil
==
buttonsContainer
{
buttonsContainer
=
UIView
()
...
...
@@ -175,7 +190,7 @@ public class BasicCard : MaterialCard {
detailLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|"
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
,
"maximumDetailHeight"
:
maximumDetailHeight
],
views
:
[
"detailLabel"
:
detailLabel
!
]))
}
if
nil
!=
buttonsContainer
&&
nil
!=
buttons
{
if
nil
!=
buttonsContainer
&&
(
nil
!=
leftButtons
||
nil
!=
rightButtons
)
{
// divider
if
nil
!=
divider
{
layoutConstraints
+=
Layout
.
constraint
(
"H:|[divider]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
[
"divider"
:
divider
!
])
...
...
@@ -188,17 +203,33 @@ public class BasicCard : MaterialCard {
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
horizontalFormat
+=
"-(verticalSpace)-[button
\(
i
)
]"
Layout
.
expandToParentVerticallyWithPad
(
buttonsContainer
!
,
child
:
button
,
top
:
verticalSpace
,
bottom
:
verticalSpace
)
// 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
))
}
// 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
))
}
buttonsContainer
!.
addConstraints
(
Layout
.
constraint
(
horizontalFormat
,
options
:
nil
,
metrics
:
[
"verticalSpace"
:
verticalSpace
],
views
:
buttonViews
))
}
verticalFormat
+=
"|"
...
...
Source/MaterialCard.swift
View file @
33260ec0
...
...
@@ -117,7 +117,6 @@ public class MaterialCard : UIView {
layer
.
shadowOffset
=
CGSizeMake
(
0.05
,
0.05
)
layer
.
shadowOpacity
=
0.1
layer
.
shadowRadius
=
3
layer
.
shadowPath
=
UIBezierPath
(
rect
:
bounds
)
.
CGPath
}
//
...
...
@@ -125,6 +124,7 @@ public class MaterialCard : UIView {
//
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
layer
.
shadowPath
=
UIBezierPath
(
rect
:
bounds
)
.
CGPath
}
//
...
...
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