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
ffcb12a1
Commit
ffcb12a1
authored
Sep 29, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BasicCardView added
parent
62c42c52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
29 deletions
+114
-29
Source/BasicCardView.swift
+100
-18
Source/MaterialTheme.swift
+5
-2
Source/NavigationBarView.swift
+9
-9
No files found.
Source/BasicCardView.swift
View file @
ffcb12a1
...
@@ -20,20 +20,39 @@ import UIKit
...
@@ -20,20 +20,39 @@ import UIKit
public
class
BasicCardView
:
MaterialPulseView
{
public
class
BasicCardView
:
MaterialPulseView
{
/**
/**
:name:
title
Insets
:name:
content
Insets
*/
*/
public
var
title
Insets
:
MaterialInsets
?
{
public
var
content
Insets
:
MaterialInsets
?
{
didSet
{
didSet
{
titleInsetsRef
=
nil
==
titleInsets
?
nil
:
MaterialInsetsToValue
(
title
Insets
!
)
contentInsetsRef
=
nil
==
contentInsets
?
nil
:
MaterialInsetsToValue
(
content
Insets
!
)
}
}
}
}
/**
/**
:name:
title
InsetsRef
:name:
content
InsetsRef
*/
*/
public
var
title
InsetsRef
:
MaterialInsetsType
!
{
public
var
content
InsetsRef
:
MaterialInsetsType
!
{
didSet
{
didSet
{
titleInsetsRef
=
nil
==
titleInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
titleInsetsRef
!
contentInsetsRef
=
nil
==
contentInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
contentInsetsRef
!
reloadView
()
}
}
/**
:name: titleLabelInsets
*/
public
var
titleLabelInsets
:
MaterialInsets
?
{
didSet
{
titleLabelInsetsRef
=
nil
==
titleLabelInsets
?
nil
:
MaterialInsetsToValue
(
titleLabelInsets
!
)
}
}
/**
:name: titleLabelInsetsRef
*/
public
var
titleLabelInsetsRef
:
MaterialInsetsType
!
{
didSet
{
titleLabelInsetsRef
=
nil
==
titleLabelInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
titleLabelInsetsRef
!
reloadView
()
reloadView
()
}
}
}
}
...
@@ -51,6 +70,37 @@ public class BasicCardView: MaterialPulseView {
...
@@ -51,6 +70,37 @@ public class BasicCardView: MaterialPulseView {
}
}
/**
/**
:name: detailLabelInsets
*/
public
var
detailLabelInsets
:
MaterialInsets
?
{
didSet
{
detailLabelInsetsRef
=
nil
==
detailLabelInsets
?
nil
:
MaterialInsetsToValue
(
detailLabelInsets
!
)
}
}
/**
:name: detailLabelInsetsRef
*/
public
var
detailLabelInsetsRef
:
MaterialInsetsType
!
{
didSet
{
detailLabelInsetsRef
=
nil
==
detailLabelInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
detailLabelInsetsRef
!
reloadView
()
}
}
/**
:name: detailLabel
*/
public
var
detailLabel
:
UILabel
?
{
didSet
{
if
let
v
=
detailLabel
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
}
reloadView
()
}
}
/**
:name: leftButtonsInsets
:name: leftButtonsInsets
*/
*/
public
var
leftButtonsInsets
:
MaterialInsets
?
{
public
var
leftButtonsInsets
:
MaterialInsets
?
{
...
@@ -140,9 +190,9 @@ public class BasicCardView: MaterialPulseView {
...
@@ -140,9 +190,9 @@ public class BasicCardView: MaterialPulseView {
/**
/**
:name: init
:name: init
*/
*/
public
convenience
init
?(
titleLabel
:
UILabel
?
=
nil
,
leftButtons
:
Array
<
MaterialButton
>
?
=
nil
,
rightButtons
:
Array
<
MaterialButton
>
?
=
nil
)
{
public
convenience
init
?(
titleLabel
:
UILabel
?
=
nil
,
detailLabel
:
UILabel
?
=
nil
,
leftButtons
:
Array
<
MaterialButton
>
?
=
nil
,
rightButtons
:
Array
<
MaterialButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
self
.
init
(
frame
:
CGRectZero
)
self
.
prepareProperties
(
titleLabel
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
self
.
prepareProperties
(
titleLabel
,
detailLabel
:
detailLabel
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
}
/**
/**
...
@@ -155,20 +205,37 @@ public class BasicCardView: MaterialPulseView {
...
@@ -155,20 +205,37 @@ public class BasicCardView: MaterialPulseView {
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
var
verticalFormat
:
String
=
"V:|"
var
verticalFormat
:
String
=
"V:|
-(insetTop)
"
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
views
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
metrics
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
metrics
:
Dictionary
<
String
,
AnyObject
>
=
[
"insetTop"
:
contentInsetsRef
!.
top
,
"insetBottom"
:
contentInsetsRef
!.
bottom
]
// title
// title
if
let
v
=
titleLabel
{
if
let
v
=
titleLabel
{
verticalFormat
+=
"-
(titleLabelTopInset)-[titleLabel]-(titleLabelBottomInset)-
"
verticalFormat
+=
"-
[titleLabel]
"
views
[
"titleLabel"
]
=
titleLabel
views
[
"titleLabel"
]
=
v
metrics
[
"titleLabelTopInset"
]
=
titleInsetsRef
!.
top
metrics
[
"
titleLabelBottomInset"
]
=
titleInsetsRef
!.
bottom
metrics
[
"
insetTop"
]
=
titleLabelInsetsRef
!.
top
addSubview
(
v
)
addSubview
(
v
)
v
.
layer
.
zPosition
=
2000
v
.
layer
.
zPosition
=
2000
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
titleInsetsRef
!.
left
,
right
:
titleInsetsRef
!.
right
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
!.
left
+
titleLabelInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
+
titleLabelInsetsRef
!.
right
)
}
// detail
if
let
v
=
detailLabel
{
if
nil
==
titleLabel
{
metrics
[
"insetTop"
]
=
detailLabelInsetsRef
!.
top
}
else
{
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInsetsRef
!.
bottom
+
detailLabelInsetsRef
!.
top
}
verticalFormat
+=
"-[detailLabel]"
views
[
"detailLabel"
]
=
v
addSubview
(
v
)
v
.
layer
.
zPosition
=
2000
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
!.
left
+
detailLabelInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
+
detailLabelInsetsRef
!.
right
)
}
}
// leftButtons
// leftButtons
...
@@ -207,8 +274,20 @@ public class BasicCardView: MaterialPulseView {
...
@@ -207,8 +274,20 @@ public class BasicCardView: MaterialPulseView {
addConstraints
(
MaterialLayout
.
constraint
(
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
rightButtonsInsetsRef
!.
right
],
views
:
d
))
addConstraints
(
MaterialLayout
.
constraint
(
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
rightButtonsInsetsRef
!.
right
],
views
:
d
))
}
}
if
nil
!=
titleLabel
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
titleLabelInsetsRef
!.
top
}
else
if
nil
!=
detailLabel
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
detailLabelInsetsRef
!.
top
}
if
nil
!=
detailLabel
{
metrics
[
"insetBottom"
]
=
(
metrics
[
"insetBottom"
]
as!
CGFloat
)
+
detailLabelInsetsRef
!.
bottom
}
else
if
nil
!=
titleLabel
{
metrics
[
"insetBottom"
]
=
(
metrics
[
"insetBottom"
]
as!
CGFloat
)
+
titleLabelInsetsRef
!.
bottom
}
if
0
<
views
.
count
{
if
0
<
views
.
count
{
verticalFormat
+=
"|"
verticalFormat
+=
"
-(insetBottom)-
|"
addConstraints
(
MaterialLayout
.
constraint
(
verticalFormat
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
addConstraints
(
MaterialLayout
.
constraint
(
verticalFormat
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
...
@@ -217,8 +296,9 @@ public class BasicCardView: MaterialPulseView {
...
@@ -217,8 +296,9 @@ public class BasicCardView: MaterialPulseView {
//
//
// :name: prepareProperties
// :name: prepareProperties
//
//
internal
func
prepareProperties
(
titleLabel
:
UILabel
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
internal
func
prepareProperties
(
titleLabel
:
UILabel
?,
detailLabel
:
UILabel
?,
leftButtons
:
Array
<
MaterialButton
>
?,
rightButtons
:
Array
<
MaterialButton
>
?)
{
self
.
titleLabel
=
titleLabel
self
.
titleLabel
=
titleLabel
self
.
detailLabel
=
detailLabel
self
.
leftButtons
=
leftButtons
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
self
.
rightButtons
=
rightButtons
}
}
...
@@ -230,7 +310,9 @@ public class BasicCardView: MaterialPulseView {
...
@@ -230,7 +310,9 @@ public class BasicCardView: MaterialPulseView {
super
.
prepareView
()
super
.
prepareView
()
userInteractionEnabled
=
MaterialTheme
.
basicCardView
.
userInteractionEnabled
userInteractionEnabled
=
MaterialTheme
.
basicCardView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
basicCardView
.
backgroudColor
backgroundColor
=
MaterialTheme
.
basicCardView
.
backgroudColor
titleInsetsRef
=
MaterialTheme
.
basicCardView
.
titleInsetsRef
contentInsetsRef
=
MaterialTheme
.
basicCardView
.
contentInsetsRef
titleLabelInsetsRef
=
MaterialTheme
.
basicCardView
.
titleLabelInsetsRef
detailLabelInsetsRef
=
MaterialTheme
.
basicCardView
.
detailLabelInsetsRef
leftButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
leftButtonsInsetsRef
leftButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
leftButtonsInsetsRef
rightButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
rightButtonsInsetsRef
rightButtonsInsetsRef
=
MaterialTheme
.
basicCardView
.
rightButtonsInsetsRef
...
...
Source/MaterialTheme.swift
View file @
ffcb12a1
...
@@ -118,7 +118,9 @@ public extension MaterialTheme.basicCardView {
...
@@ -118,7 +118,9 @@ public extension MaterialTheme.basicCardView {
// shape
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
10
,
right
:
8
)
public
static
var
contentInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
titleLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
detailLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
...
@@ -159,7 +161,8 @@ public extension MaterialTheme.navigationBarView {
...
@@ -159,7 +161,8 @@ public extension MaterialTheme.navigationBarView {
// shape
// shape
public
static
var
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
var
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
contentInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
titleLabelInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
MaterialInsetsToValue
(
.
Square2
)
...
...
Source/NavigationBarView.swift
View file @
ffcb12a1
...
@@ -29,20 +29,20 @@ public class NavigationBarView: MaterialView {
...
@@ -29,20 +29,20 @@ public class NavigationBarView: MaterialView {
}
}
/**
/**
:name: titleInsets
:name: title
Label
Insets
*/
*/
public
var
titleInsets
:
MaterialInsets
?
{
public
var
title
Label
Insets
:
MaterialInsets
?
{
didSet
{
didSet
{
title
InsetsRef
=
nil
==
titleInsets
?
nil
:
MaterialInsetsToValue
(
title
Insets
!
)
title
LabelInsetsRef
=
nil
==
titleLabelInsets
?
nil
:
MaterialInsetsToValue
(
titleLabel
Insets
!
)
}
}
}
}
/**
/**
:name: titleInsetsRef
:name: title
Label
InsetsRef
*/
*/
public
var
titleInsetsRef
:
MaterialInsetsType
!
{
public
var
title
Label
InsetsRef
:
MaterialInsetsType
!
{
didSet
{
didSet
{
title
InsetsRef
=
nil
==
titleInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
title
InsetsRef
!
title
LabelInsetsRef
=
nil
==
titleLabelInsetsRef
?
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
:
titleLabel
InsetsRef
!
reloadView
()
reloadView
()
}
}
}
}
...
@@ -184,8 +184,8 @@ public class NavigationBarView: MaterialView {
...
@@ -184,8 +184,8 @@ public class NavigationBarView: MaterialView {
// title
// title
if
let
v
=
titleLabel
{
if
let
v
=
titleLabel
{
insertSubview
(
v
,
atIndex
:
0
)
insertSubview
(
v
,
atIndex
:
0
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
title
InsetsRef
!.
left
,
right
:
title
InsetsRef
!.
right
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
v
,
left
:
title
LabelInsetsRef
!.
left
,
right
:
titleLabel
InsetsRef
!.
right
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
v
,
bottom
:
titleInsetsRef
!.
bottom
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
v
,
bottom
:
title
Label
InsetsRef
!.
bottom
)
}
}
// rightButtons
// rightButtons
...
@@ -224,7 +224,7 @@ public class NavigationBarView: MaterialView {
...
@@ -224,7 +224,7 @@ public class NavigationBarView: MaterialView {
userInteractionEnabled
=
MaterialTheme
.
navigationBarView
.
userInteractionEnabled
userInteractionEnabled
=
MaterialTheme
.
navigationBarView
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
navigationBarView
.
backgroudColor
backgroundColor
=
MaterialTheme
.
navigationBarView
.
backgroudColor
statusBarStyle
=
MaterialTheme
.
navigationBarView
.
statusBarStyle
statusBarStyle
=
MaterialTheme
.
navigationBarView
.
statusBarStyle
title
InsetsRef
=
MaterialTheme
.
navigationBarView
.
title
InsetsRef
title
LabelInsetsRef
=
MaterialTheme
.
navigationBarView
.
titleLabel
InsetsRef
leftButtonsInsetsRef
=
MaterialTheme
.
navigationBarView
.
leftButtonsInsetsRef
leftButtonsInsetsRef
=
MaterialTheme
.
navigationBarView
.
leftButtonsInsetsRef
rightButtonsInsetsRef
=
MaterialTheme
.
navigationBarView
.
rightButtonsInsetsRef
rightButtonsInsetsRef
=
MaterialTheme
.
navigationBarView
.
rightButtonsInsetsRef
...
...
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