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
414d067e
Commit
414d067e
authored
Oct 12, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating Card views
parent
c20e6381
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
32 deletions
+54
-32
Source/BasicCardView.swift
+10
-3
Source/ImageCardView.swift
+32
-10
Source/MaterialInsets.swift
+2
-2
Source/MaterialTheme.swift
+10
-10
Source/SideNavigationViewController.swift
+0
-7
No files found.
Source/BasicCardView.swift
View file @
414d067e
...
...
@@ -243,6 +243,8 @@ public class BasicCardView : MaterialPulseView {
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
basicCardView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
basicCardView
.
backgroundColor
pulseColor
=
MaterialTheme
.
basicCardView
.
pulseColor
contentInsetsRef
=
MaterialTheme
.
basicCardView
.
contentInsetsRef
titleLabelInsetsRef
=
MaterialTheme
.
basicCardView
.
titleLabelInsetsRef
detailLabelInsetsRef
=
MaterialTheme
.
basicCardView
.
detailLabelInsetsRef
...
...
@@ -287,15 +289,18 @@ public class BasicCardView : MaterialPulseView {
// title
if
let
v
=
titleLabel
{
addSubview
(
v
)
verticalFormat
+=
"-[titleLabel]"
views
[
"titleLabel"
]
=
v
addSubview
(
v
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
!.
left
+
titleLabelInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
+
titleLabelInsetsRef
!.
right
)
}
// detail
if
let
v
=
detailLabel
{
addSubview
(
v
)
if
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInsetsRef
!.
bottom
+
detailLabelInsetsRef
!.
top
...
...
@@ -303,8 +308,7 @@ public class BasicCardView : MaterialPulseView {
verticalFormat
+=
"-[detailLabel]"
views
[
"detailLabel"
]
=
v
addSubview
(
v
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
!.
left
+
detailLabelInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
+
detailLabelInsetsRef
!.
right
)
}
...
...
@@ -387,10 +391,13 @@ public class BasicCardView : MaterialPulseView {
}
else
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
titleLabelInsetsRef
!.
bottom
}
}
else
if
nil
!=
metrics
[
"insetC"
]
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentInsetsRef
!.
top
}
if
0
<
views
.
count
{
verticalFormat
+=
"-(insetBottom)-|"
print
(
verticalFormat
)
addConstraints
(
MaterialLayout
.
constraint
(
verticalFormat
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
...
...
Source/ImageCardView.swift
View file @
414d067e
...
...
@@ -34,8 +34,12 @@ public class ImageCardView : MaterialPulseView {
set
(
value
)
{
if
let
v
=
value
{
imageLayer
.
contents
=
v
.
CGImage
if
0
==
imageLayer
.
frame
.
size
.
height
{
imageLayer
.
frame
.
size
.
height
=
v
.
size
.
height
if
0
==
maxImageSize
{
if
0
==
imageLayer
.
frame
.
size
.
height
{
imageLayer
.
frame
.
size
.
height
=
v
.
size
.
height
}
}
else
{
imageLayer
.
frame
.
size
.
height
=
maxImageSize
}
imageLayer
.
hidden
=
false
}
...
...
@@ -49,6 +53,19 @@ public class ImageCardView : MaterialPulseView {
}
/**
:name: maxImageSize
*/
public
var
maxImageSize
:
CGFloat
=
0
{
didSet
{
if
0
<
maxImageSize
{
imageLayer
.
frame
.
size
.
height
=
maxImageSize
// imageLayer.contentsGravity = MaterialGravityToString(contentsGravity)
}
reloadView
()
}
}
/**
:name: contentsRect
*/
public
override
var
contentsRect
:
CGRect
{
...
...
@@ -299,11 +316,7 @@ public class ImageCardView : MaterialPulseView {
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
// image
let
h
:
CGFloat
=
imageLayer
.
frame
.
size
.
height
imageLayer
.
frame
=
bounds
if
0
<
h
&&
nil
!=
imageLayer
.
contents
{
imageLayer
.
frame
.
size
.
height
=
h
}
imageLayer
.
frame
.
size
.
width
=
bounds
.
size
.
width
// divider
if
true
==
divider
{
...
...
@@ -329,6 +342,8 @@ public class ImageCardView : MaterialPulseView {
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
imageCardView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
imageCardView
.
backgroundColor
pulseColor
=
MaterialTheme
.
imageCardView
.
pulseColor
contentInsetsRef
=
MaterialTheme
.
imageCardView
.
contentInsetsRef
titleLabelInsetsRef
=
MaterialTheme
.
imageCardView
.
titleLabelInsetsRef
detailLabelInsetsRef
=
MaterialTheme
.
imageCardView
.
detailLabelInsetsRef
...
...
@@ -367,7 +382,7 @@ public class ImageCardView : MaterialPulseView {
if
nil
!=
imageLayer
.
contents
{
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInsetsRef
!.
top
+
imageLayer
.
frame
.
size
.
height
metrics
[
"insetTop"
]
=
imageLayer
.
frame
.
size
.
height
}
else
if
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInsetsRef
!.
top
+
titleLabelInsetsRef
!.
top
...
...
@@ -379,6 +394,7 @@ public class ImageCardView : MaterialPulseView {
// title
if
let
v
=
titleLabel
{
addSubview
(
v
)
if
nil
==
imageLayer
.
contents
{
verticalFormat
+=
"-[titleLabel]"
views
[
"titleLabel"
]
=
v
...
...
@@ -390,15 +406,18 @@ public class ImageCardView : MaterialPulseView {
// detail
if
let
v
=
detailLabel
{
addSubview
(
v
)
if
nil
==
imageLayer
.
contents
&&
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInsetsRef
!.
bottom
+
detailLabelInsetsRef
!.
top
}
else
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
detailLabelInsetsRef
!.
top
}
verticalFormat
+=
"-[detailLabel]"
views
[
"detailLabel"
]
=
v
addSubview
(
v
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
!.
left
+
detailLabelInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
+
detailLabelInsetsRef
!.
right
)
}
...
...
@@ -481,10 +500,13 @@ public class ImageCardView : MaterialPulseView {
}
else
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
titleLabelInsetsRef
!.
bottom
}
}
else
if
nil
!=
metrics
[
"insetC"
]
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentInsetsRef
!.
top
}
if
0
<
views
.
count
{
verticalFormat
+=
"-(insetBottom)-|"
print
(
verticalFormat
)
addConstraints
(
MaterialLayout
.
constraint
(
verticalFormat
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
...
...
@@ -493,7 +515,7 @@ public class ImageCardView : MaterialPulseView {
// :name: prepareImageLayer
//
internal
func
prepareImageLayer
()
{
imageLayer
=
CAShapeLayer
()
imageLayer
.
masksToBounds
=
true
imageLayer
.
zPosition
=
0
visualLayer
.
addSublayer
(
imageLayer
)
}
...
...
Source/MaterialInsets.swift
View file @
414d067e
...
...
@@ -62,10 +62,10 @@ public enum MaterialInsets {
*/
public
func
MaterialInsetsToValue
(
inset
:
MaterialInsets
)
->
MaterialInsetsType
{
switch
inset
{
// square
case
.
None
:
return
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
// square
case
.
Square1
:
return
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
case
.
Square2
:
...
...
Source/MaterialTheme.swift
View file @
414d067e
...
...
@@ -102,11 +102,11 @@ public extension MaterialTheme.basicCardView {
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
None
public
static
var
contentInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square
3
)
public
static
var
contentInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square
2
)
public
static
var
titleLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
detailLabelInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
16
,
right
:
8
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
8
,
bottom
:
-
8
,
right
:
0
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
0
,
bottom
:
-
8
,
right
:
8
)
public
static
var
detailLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
None
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
None
)
// border
public
static
var
borderWidth
:
MaterialBorder
=
.
None
...
...
@@ -114,7 +114,7 @@ public extension MaterialTheme.basicCardView {
// color
public
static
var
backgroundColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
blueGrey
.
lighten4
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
// interaction
...
...
@@ -144,10 +144,10 @@ public extension MaterialTheme.imageCardView {
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
None
public
static
var
contentInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
titleLabelInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
16
,
bottom
:
0
,
right
:
16
)
public
static
var
detailLabelInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
16
,
bottom
:
16
,
right
:
16
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
0
,
bottom
:
0
,
right
:
0
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
8
,
left
:
0
,
bottom
:
0
,
right
:
0
)
public
static
var
titleLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
detailLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
None
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
None
)
// border
public
static
var
borderWidth
:
MaterialBorder
=
.
None
...
...
@@ -155,7 +155,7 @@ public extension MaterialTheme.imageCardView {
// color
public
static
var
backgroundColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
blueGrey
.
lighten4
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
// interaction
...
...
Source/SideNavigationViewController.swift
View file @
414d067e
...
...
@@ -282,13 +282,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
internal
func
prepareLeftView
()
{
prepareContainer
(
&
leftViewContainer
,
originX
:
leftOriginX
,
originY
:
0
,
width
:
options
.
leftViewContainerWidth
,
height
:
view
.
bounds
.
size
.
height
)
prepareLeftGestures
()
// leftViewContainer!.layer.speed = 0
let
w
:
CGFloat
=
leftViewContainer
!.
width
let
h
:
CGFloat
=
leftViewContainer
!.
height
// leftAnimation = MaterialAnimation.position(CGPointMake(w / 2, h / 2), duration: 1)
// leftViewContainer!.position = CGPointMake(-(w / 2), h / 2)
// leftViewContainer!.animation(leftAnimation!)
}
//
...
...
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