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
9410474e
Commit
9410474e
authored
Sep 11, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
card alignment fix prior to color additions
parent
a2559db4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
243 additions
and
79 deletions
+243
-79
Source/BasicCardView.swift
+113
-39
Source/ImageCardView.swift
+119
-28
Source/MaterialTheme.swift
+11
-12
No files found.
Source/BasicCardView.swift
View file @
9410474e
This diff is collapsed.
Click to expand it.
Source/ImageCardView.swift
View file @
9410474e
...
...
@@ -42,12 +42,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: imageViewTopInset
*/
public
var
imageViewTopInset
:
CGFloat
=
0
public
var
imageViewTopInset
:
CGFloat
=
0
{
didSet
{
prepareCard
()
}
}
/**
:name: imageViewBottomInset
*/
public
var
imageViewBottomInset
:
CGFloat
=
0
public
var
imageViewBottomInset
:
CGFloat
=
0
{
didSet
{
prepareCard
()
}
}
/**
:name: imageViewHorizontalInset
...
...
@@ -62,26 +70,48 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: imageViewLeftInset
*/
public
var
imageViewLeftInset
:
CGFloat
=
0
public
var
imageViewLeftInset
:
CGFloat
=
0
{
didSet
{
prepareCard
()
}
}
/**
:name: imageViewRightInset
*/
public
var
imageViewRightInset
:
CGFloat
=
0
public
var
imageViewRightInset
:
CGFloat
=
0
{
didSet
{
prepareCard
()
}
}
/**
:name: titleLabelVerticalInset
*/
public
var
titleLabelVerticalInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
titleLabelTopInset
=
titleLabelVerticalInset
titleLabelBottomInset
=
titleLabelVerticalInset
}
}
/**
:name: titleLabelTopInset
*/
public
var
titleLabelTopInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: titleLabelBottomInset
*/
public
var
titleLabelBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
public
var
titleLabelBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: titleLabelHorizontalInset
...
...
@@ -96,12 +126,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: titleLabelLeftInset
*/
public
var
titleLabelLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
titleLabelLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: titleLabelRightInset
*/
public
var
titleLabelRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
titleLabelRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: detailLabelVerticalInset
...
...
@@ -116,12 +154,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: detailLabelTopInset
*/
public
var
detailLabelTopInset
:
CGFloat
=
MaterialTheme
.
verticalInset
public
var
detailLabelTopInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: detailLabelBottomInset
*/
public
var
detailLabelBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
public
var
detailLabelBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: detailLabelHorizontalInset
...
...
@@ -136,12 +182,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: detailLabelLeftInset
*/
public
var
detailLabelLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
detailLabelLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: detailLabelRightInset
*/
public
var
detailLabelRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
detailLabelRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: buttonVerticalInset
...
...
@@ -156,12 +210,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: buttonTopInset
*/
public
var
buttonTopInset
:
CGFloat
=
MaterialTheme
.
verticalInset
public
var
buttonTopInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: buttonBottomInset
*/
public
var
buttonBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
public
var
buttonBottomInset
:
CGFloat
=
MaterialTheme
.
verticalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: buttonHorizontalInset
...
...
@@ -176,12 +238,20 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/**
:name: buttonLeftInset
*/
public
var
buttonLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
buttonLeftInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: buttonRightInset
*/
public
var
buttonRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
public
var
buttonRightInset
:
CGFloat
=
MaterialTheme
.
horizontalInset
{
didSet
{
prepareCard
()
}
}
/**
:name: shadow
...
...
@@ -189,13 +259,18 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
public
var
shadow
:
Bool
=
true
{
didSet
{
false
==
shadow
?
removeShadow
()
:
prepareShadow
()
prepareCard
()
}
}
/**
:name: maximumImageViewHeight
*/
public
var
maximumImageViewHeight
:
CGFloat
=
200
public
var
maximumImageViewHeight
:
CGFloat
=
200
{
didSet
{
prepareCard
()
}
}
/**
:name: imageViewContainer
...
...
@@ -228,10 +303,19 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
titleLabelContainer
!.
removeFromSuperview
()
imageViewContainer
!.
addSubview
(
titleLabelContainer
!
)
}
prepareCard
()
}
else
{
imageViewContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
/**
:name: maximumTitleLabelHeight
*/
public
var
maximumTitleLabelHeight
:
CGFloat
=
0
{
didSet
{
prepareCard
()
}
}
...
...
@@ -258,7 +342,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
t
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
t
.
backgroundColor
=
MaterialTheme
.
clear
.
color
t
.
font
=
Roboto
.
medium
t
.
numberOfLines
=
1
t
.
numberOfLines
=
0
t
.
lineBreakMode
=
.
ByTruncatingTail
if
nil
==
imageView
{
titleLabelContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
...
...
@@ -269,17 +353,21 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
titleLabelContainer
!.
removeFromSuperview
()
imageViewContainer
!.
addSubview
(
titleLabelContainer
!
)
}
prepareCard
()
}
else
{
titleLabelContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
/**
:name: maximumDetailLabelHeight
*/
public
var
maximumDetailLabelHeight
:
CGFloat
=
144
public
var
maximumDetailLabelHeight
:
CGFloat
=
144
{
didSet
{
prepareCard
()
}
}
/**
:name: detailLabelContainer
...
...
@@ -308,10 +396,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
l
.
font
=
Roboto
.
light
l
.
numberOfLines
=
0
l
.
lineBreakMode
=
.
ByTruncatingTail
prepareCard
()
}
else
{
detailLabelContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
...
...
@@ -324,10 +412,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
d
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
d
.
backgroundColor
=
MaterialTheme
.
blueGrey
.
lighten5
addSubview
(
d
)
prepareCard
()
}
else
{
divider
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
...
...
@@ -348,10 +436,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
...
...
@@ -367,10 +455,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer
!.
backgroundColor
=
MaterialTheme
.
white
.
color
addSubview
(
buttonsContainer
!
)
}
prepareCard
()
}
else
{
buttonsContainer
?
.
removeFromSuperview
()
}
prepareCard
()
}
}
...
...
@@ -422,8 +510,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
//
internal
override
func
prepareCard
()
{
super
.
prepareCard
()
// deactivate and clear all constraints
// clear all constraints
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
layoutConstraints
.
removeAll
(
keepCapacity
:
false
)
...
...
@@ -462,8 +549,12 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
}
// common text
Layout
.
height
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
height
:
1.5
*
titleLabel
!.
font
.
pointSize
)
Layout
.
expandToParentWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
left
:
titleLabelLeftInset
,
bottom
:
titleLabelBottomInset
,
right
:
titleLabelRightInset
)
if
0
==
maximumTitleLabelHeight
{
Layout
.
expandToParentWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
top
:
titleLabelTopInset
,
left
:
titleLabelLeftInset
,
bottom
:
titleLabelBottomInset
,
right
:
titleLabelRightInset
)
}
else
{
Layout
.
expandToParentHorizontallyWithPad
(
titleLabelContainer
!
,
child
:
titleLabel
!
,
left
:
titleLabelLeftInset
,
right
:
titleLabelRightInset
)
titleLabelContainer
!.
addConstraints
(
Layout
.
constraint
(
"V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|"
,
options
:
nil
,
metrics
:
[
"titleLabelTopInset"
:
titleLabelTopInset
,
"titleLabelBottomInset"
:
titleLabelBottomInset
,
"maximumTitleLabelHeight"
:
maximumTitleLabelHeight
],
views
:
[
"titleLabel"
:
titleLabel
!
]))
}
}
// detail
...
...
Source/MaterialTheme.swift
View file @
9410474e
...
...
@@ -20,6 +20,17 @@ import UIKit
public
struct
MaterialTheme
{}
// spacing
extension
MaterialTheme
{
public
static
var
verticalInset
:
CGFloat
=
16
public
static
var
horizontalInset
:
CGFloat
=
16
}
// fonts
extension
MaterialTheme
{
public
static
var
textFontSize
:
CGFloat
=
16
}
// colors
extension
MaterialTheme
{
// clear
...
...
@@ -369,14 +380,3 @@ extension MaterialTheme {
public
static
let
darken4
:
UIColor
=
UIColor
(
red
:
38
/
255
,
green
:
50
/
255
,
blue
:
56
/
255
,
alpha
:
1
)
}
}
// spacing
extension
MaterialTheme
{
public
static
var
verticalInset
:
CGFloat
=
8
public
static
var
horizontalInset
:
CGFloat
=
2
*
verticalInset
}
// fonts
extension
MaterialTheme
{
public
static
var
textFontSize
:
CGFloat
=
16
}
\ No newline at end of file
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