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
ea72a610
Unverified
Commit
ea72a610
authored
Oct 02, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added centerViews to Bar and updated Card samples
parent
54a2e6d0
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
131 additions
and
102 deletions
+131
-102
Examples/Programmatic/Card/Card/ViewController.swift
+9
-18
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
+3
-11
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/dreamer.imageset/dreamer.jpg
+0
-0
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/pattern.imageset/Contents.json
+1
-1
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/pattern.imageset/pattern.png
+0
-0
Examples/Programmatic/PresenterCard/PresenterCard/ViewController.swift
+7
-19
Material.xcodeproj/project.pbxproj
+1
-1
Sources/iOS/Bar.swift
+13
-1
Sources/iOS/Card.swift
+61
-28
Sources/iOS/Grid.swift
+6
-5
Sources/iOS/ImageCard.swift
+12
-6
Sources/iOS/PresenterCard.swift
+12
-8
Sources/iOS/SearchBar.swift
+3
-2
Sources/iOS/Toolbar.swift
+3
-2
No files found.
Examples/Programmatic/Card/Card/ViewController.swift
View file @
ea72a610
...
...
@@ -46,7 +46,7 @@ class ViewController: UIViewController {
/// Toolbar views.
private
var
toolbar
:
Toolbar
!
private
var
moreButton
:
IconButton
!
private
var
authorView
:
View
!
private
var
authorView
:
UIImage
View
!
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -77,7 +77,6 @@ class ViewController: UIViewController {
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
red
.
base
)
favoriteButton
.
grid
.
columns
=
4
}
private
func
prepareMoreButton
()
{
...
...
@@ -85,16 +84,13 @@ class ViewController: UIViewController {
}
private
func
prepareAuthorView
()
{
authorView
=
View
()
authorView
.
width
=
24
authorView
.
image
=
UIImage
(
named
:
"CosmicMind"
)
authorView
.
backgroundColor
=
nil
authorView
.
contentsGravityPreset
=
.
ResizeAspect
authorView
=
UIImageView
()
authorView
.
image
=
UIImage
(
named
:
"CosmicMind"
)?
.
resize
(
toWidth
:
24
)
authorView
.
contentMode
=
.
scaleAspectFit
}
private
func
prepareToolbar
()
{
toolbar
=
Toolbar
()
toolbar
.
backgroundColor
=
nil
toolbar
=
Toolbar
(
leftViews
:
[
authorView
],
rightViews
:
[
moreButton
])
toolbar
.
title
=
"CosmicMind"
toolbar
.
titleLabel
.
textAlignment
=
.
left
...
...
@@ -102,21 +98,17 @@ class ViewController: UIViewController {
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textColor
=
Color
.
blueGrey
.
base
toolbar
.
leftViews
=
[
authorView
]
toolbar
.
rightViews
=
[
moreButton
]
}
private
func
prepareContentView
()
{
contentView
=
UILabel
()
contentView
.
numberOfLines
=
0
contentView
.
text
=
"Material is an animation and graphics framework that is
the foundation
for creating beautiful applications."
contentView
.
text
=
"Material is an animation and graphics framework that is
used
for creating beautiful applications."
contentView
.
font
=
RobotoFont
.
regular
(
with
:
14
)
}
private
func
prepareBottomBar
()
{
bottomBar
=
Bar
()
bottomBar
.
cornerRadiusPreset
=
.
cornerRadius1
bottomBar
.
leftViews
=
[
dateLabel
]
bottomBar
.
rightViews
=
[
favoriteButton
]
...
...
@@ -124,16 +116,15 @@ class ViewController: UIViewController {
private
func
prepareImageCard
()
{
card
=
Card
()
card
.
cornerRadiusPreset
=
.
cornerRadius1
card
.
toolbar
=
toolbar
card
.
toolbarEdgeInsetsPreset
=
.
square1
card
.
toolbarEdgeInsetsPreset
=
.
wideRectangle2
card
.
contentView
=
contentView
card
.
contentViewEdgeInsetsPreset
=
.
squar
e3
card
.
contentViewEdgeInsetsPreset
=
.
wideRectangl
e3
card
.
bottomBar
=
bottomBar
card
.
bottomBarEdgeInsetsPreset
=
.
squar
e2
card
.
bottomBarEdgeInsetsPreset
=
.
wideRectangl
e2
view
.
layout
(
card
)
.
horizontally
(
left
:
20
,
right
:
20
)
.
center
()
}
...
...
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
View file @
ea72a610
...
...
@@ -66,24 +66,19 @@ class ViewController: UIViewController {
private
func
prepareImageView
()
{
imageView
=
UIImageView
()
imageView
.
image
=
UIImage
(
named
:
"frontier.jpg"
)?
.
resize
(
toWidth
:
view
.
width
)
imageView
.
clipsToBounds
=
true
imageView
.
cornerRadiusPreset
=
.
cornerRadius1
imageView
.
contentMode
=
.
scaleAspectFill
}
private
func
prepareFavoriteButton
()
{
favoriteButton
=
FlatButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
blueGrey
.
base
)
favoriteButton
.
grid
.
columns
=
4
}
private
func
prepareShareButton
()
{
shareButton
=
FlatButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
shareButton
.
grid
.
columns
=
4
}
private
func
prepareStarButton
()
{
starButton
=
FlatButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
Color
.
blueGrey
.
base
)
starButton
.
grid
.
columns
=
4
}
private
func
prepareMoreButton
()
{
...
...
@@ -104,19 +99,17 @@ class ViewController: UIViewController {
private
func
prepareContentView
()
{
contentView
=
UILabel
()
contentView
.
numberOfLines
=
0
contentView
.
text
=
"Material is an animation and graphics framework that is
the foundation
for creating beautiful applications."
contentView
.
text
=
"Material is an animation and graphics framework that is
used
for creating beautiful applications."
contentView
.
font
=
RobotoFont
.
regular
(
with
:
14
)
}
private
func
prepareBottomBar
()
{
bottomBar
=
Bar
()
bottomBar
.
backgroundColor
=
nil
bottomBar
.
contentView
.
grid
.
views
=
[
favoriteButton
,
shareButton
,
starButton
]
bottomBar
=
Bar
(
centerViews
:
[
favoriteButton
,
shareButton
,
starButton
])
}
private
func
prepareImageCard
()
{
card
=
ImageCard
()
card
.
imageView
=
imageView
card
.
toolbar
=
toolbar
...
...
@@ -126,7 +119,6 @@ class ViewController: UIViewController {
card
.
contentViewEdgeInsetsPreset
=
.
square3
card
.
bottomBar
=
bottomBar
card
.
cornerRadiusPreset
=
.
cornerRadius1
view
.
layout
(
card
)
.
horizontally
(
left
:
20
,
right
:
20
)
.
center
()
}
...
...
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/dreamer.imageset/dreamer.jpg
deleted
100644 → 0
View file @
54a2e6d0
227 KB
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/
dreamer
.imageset/Contents.json
→
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/
pattern
.imageset/Contents.json
View file @
ea72a610
...
...
@@ -2,7 +2,7 @@
"images"
:
[
{
"idiom"
:
"universal"
,
"filename"
:
"
dreamer.jp
g"
,
"filename"
:
"
pattern.pn
g"
,
"scale"
:
"1x"
},
{
...
...
Examples/Programmatic/PresenterCard/PresenterCard/Assets.xcassets/pattern.imageset/pattern.png
0 → 100644
View file @
ea72a610
601 KB
Examples/Programmatic/PresenterCard/PresenterCard/ViewController.swift
View file @
ea72a610
...
...
@@ -67,8 +67,7 @@ class ViewController: UIViewController {
private
func
preparePresenterView
()
{
presenterView
=
UIImageView
()
presenterView
.
image
=
UIImage
(
named
:
"dreamer.jpg"
)?
.
resize
(
toWidth
:
view
.
width
)
presenterView
.
clipsToBounds
=
true
presenterView
.
image
=
UIImage
(
named
:
"pattern"
)?
.
resize
(
toWidth
:
view
.
width
)
presenterView
.
contentMode
=
.
scaleAspectFill
}
...
...
@@ -87,12 +86,10 @@ class ViewController: UIViewController {
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
red
.
base
)
favoriteButton
.
grid
.
columns
=
4
}
private
func
prepareShareButton
()
{
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
shareButton
.
grid
.
columns
=
4
}
private
func
prepareMoreButton
()
{
...
...
@@ -100,41 +97,32 @@ class ViewController: UIViewController {
}
private
func
prepareToolbar
()
{
toolbar
=
Toolbar
()
toolbar
.
backgroundColor
=
nil
toolbar
=
Toolbar
(
rightViews
:
[
moreButton
])
toolbar
.
title
=
"
Material
"
toolbar
.
title
=
"
CosmicMind
"
toolbar
.
titleLabel
.
textAlignment
=
.
left
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textColor
=
Color
.
blueGrey
.
base
toolbar
.
rightViews
=
[
moreButton
]
}
private
func
prepareContentView
()
{
contentView
=
UILabel
()
contentView
.
numberOfLines
=
0
contentView
.
text
=
"Material is an animation and graphics framework that is
the foundation
for creating beautiful applications."
contentView
.
text
=
"Material is an animation and graphics framework that is
used
for creating beautiful applications."
contentView
.
font
=
RobotoFont
.
regular
(
with
:
14
)
}
private
func
prepareBottomBar
()
{
bottomBar
=
Bar
()
bottomBar
.
backgroundColor
=
nil
bottomBar
.
leftViews
=
[
favoriteButton
]
bottomBar
.
rightViews
=
[
shareButton
]
bottomBar
.
contentView
.
grid
.
views
=
[
dateLabel
]
bottomBar
=
Bar
(
leftViews
:
[
favoriteButton
],
rightViews
:
[
shareButton
],
centerViews
:
[
dateLabel
])
}
private
func
prepareImageCard
()
{
card
=
PresenterCard
()
card
.
cornerRadiusPreset
=
.
cornerRadius1
card
.
toolbar
=
toolbar
card
.
toolbarEdgeInsetsPreset
=
.
squar
e2
card
.
toolbarEdgeInsetsPreset
=
.
wideRectangl
e2
card
.
presenterView
=
presenterView
...
...
@@ -142,7 +130,7 @@ class ViewController: UIViewController {
card
.
contentViewEdgeInsetsPreset
=
.
square3
card
.
bottomBar
=
bottomBar
card
.
bottomBarEdgeInsetsPreset
=
.
square1
card
.
bottomBarEdgeInsetsPreset
=
.
wideRectangle2
view
.
layout
(
card
)
.
horizontally
(
left
:
20
,
right
:
20
)
.
center
()
}
...
...
Material.xcodeproj/project.pbxproj
View file @
ea72a610
...
...
@@ -597,8 +597,8 @@
isa
=
PBXGroup
;
children
=
(
96BCB75D1CB40DC500C806FE
/* Card.swift */
,
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
,
96BCB7621CB40DC500C806FE
/* ImageCard.swift */
,
9631A7C01D95E3AC00CFB109
/* PresenterCard.swift */
,
);
name
=
Card
;
sourceTree
=
"<group>"
;
...
...
Sources/iOS/Bar.swift
View file @
ea72a610
...
...
@@ -124,6 +124,16 @@ open class Bar: View {
}
}
/// Center UIViews.
open
var
centerViews
:
[
UIView
]
{
get
{
return
contentView
.
grid
.
views
}
set
(
value
)
{
contentView
.
grid
.
views
=
value
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
...
...
@@ -152,11 +162,13 @@ open class Bar: View {
A convenience initializer with parameter settings.
- Parameter leftViews: An Array of UIViews that go on the left side.
- Parameter rightViews: An Array of UIViews that go on the right side.
- Parameter centerViews: An Array of UIViews that go in the center.
*/
public
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
)
{
public
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
,
centerViews
:
[
UIView
]?
=
nil
)
{
self
.
leftViews
=
leftViews
??
[]
self
.
rightViews
=
rightViews
??
[]
super
.
init
(
frame
:
.
zero
)
self
.
centerViews
=
centerViews
??
[]
frame
.
size
=
intrinsicContentSize
}
...
...
Sources/iOS/Card.swift
View file @
ea72a610
...
...
@@ -36,6 +36,44 @@ open class Card: PulseView {
return
0
<
width
&&
nil
!=
superview
}
/// A container view for subviews.
open
private(set)
lazy
var
container
=
UIView
()
@IBInspectable
open
override
var
cornerRadiusPreset
:
CornerRadiusPreset
{
didSet
{
container
.
cornerRadiusPreset
=
cornerRadiusPreset
}
}
@IBInspectable
open
override
var
cornerRadius
:
CGFloat
{
didSet
{
container
.
cornerRadius
=
cornerRadius
}
}
open
override
var
shapePreset
:
ShapePreset
{
didSet
{
container
.
shapePreset
=
shapePreset
}
}
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
container
.
backgroundColor
=
backgroundColor
}
}
/// A reference to the toolbar.
@IBInspectable
open
var
toolbar
:
Toolbar
?
{
didSet
{
layoutSubviews
()
}
}
/// A preset wrapper around toolbarEdgeInsets.
open
var
toolbarEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
didSet
{
...
...
@@ -51,9 +89,9 @@ open class Card: PulseView {
}
}
/// A reference to the
toolbar
.
/// A reference to the
contentView
.
@IBInspectable
open
var
toolbar
:
Toolbar
?
{
open
var
contentView
:
UIView
?
{
didSet
{
layoutSubviews
()
}
...
...
@@ -74,9 +112,9 @@ open class Card: PulseView {
}
}
/// A reference to the
contentView
.
/// A reference to the
bottomBar
.
@IBInspectable
open
var
contentView
:
UIView
?
{
open
var
bottomBar
:
Bar
?
{
didSet
{
layoutSubviews
()
}
...
...
@@ -97,14 +135,6 @@ open class Card: PulseView {
}
}
/// A reference to the bottomBar.
@IBInspectable
open
var
bottomBar
:
Bar
?
{
didSet
{
layoutSubviews
()
}
}
/**
An initializer that accepts a NSCoder.
- Parameter coder aDecoder: A NSCoder.
...
...
@@ -139,26 +169,21 @@ open class Card: PulseView {
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
guard
willLayout
else
{
return
}
reload
()
}
/// Reloads the layout.
open
func
reload
()
{
guard
willLayout
else
{
return
}
// clear constraints so new ones do not conflict
removeConstraints
(
constraints
)
for
v
in
subviews
{
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
}
layout
()
}
/// Lays out view.
open
func
layout
()
{
var
format
=
"V:|"
var
views
=
[
String
:
Any
]()
var
metrics
=
[
String
:
Any
]()
...
...
@@ -169,7 +194,7 @@ open class Card: PulseView {
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -186,7 +211,7 @@ open class Card: PulseView {
}
views
[
"contentView"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -206,7 +231,7 @@ open class Card: PulseView {
}
views
[
"bottomBar"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -215,7 +240,7 @@ open class Card: PulseView {
return
}
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
...
...
@@ -229,6 +254,8 @@ open class Card: PulseView {
super
.
prepare
()
depthPreset
=
.
depth1
pulseAnimation
=
.
none
cornerRadiusPreset
=
.
cornerRadius1
prepareContainer
()
}
/**
...
...
@@ -242,4 +269,10 @@ open class Card: PulseView {
self
.
contentView
=
contentView
self
.
bottomBar
=
bottomBar
}
/// Prepares the container.
private
func
prepareContainer
()
{
container
.
clipsToBounds
=
true
layout
(
container
)
.
edges
()
}
}
Sources/iOS/Grid.swift
View file @
ea72a610
...
...
@@ -188,7 +188,7 @@ public class Grid {
- Parameter columns: The number of columns, horizontal axis the grid will use.
- Parameter interimSpace: The interim space between rows or columns.
*/
public
init
(
context
:
UIView
?,
rows
:
Int
=
12
,
columns
:
Int
=
12
,
interimSpace
:
InterimSpace
=
0
)
{
public
init
(
context
:
UIView
?,
rows
:
Int
=
0
,
columns
:
Int
=
0
,
interimSpace
:
InterimSpace
=
0
)
{
self
.
context
=
context
self
.
rows
=
rows
self
.
columns
=
columns
...
...
@@ -216,6 +216,7 @@ public class Grid {
var
n
:
Int
=
0
var
i
:
Int
=
0
var
count
=
views
.
count
for
child
in
views
{
guard
let
canvas
=
context
else
{
...
...
@@ -229,7 +230,7 @@ public class Grid {
switch
axis
.
direction
{
case
.
horizontal
:
let
c
=
child
.
grid
.
columns
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
views
.
count
:
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
...
...
@@ -241,7 +242,7 @@ public class Grid {
n
+=
c
+
co
-
1
case
.
vertical
:
let
r
=
child
.
grid
.
rows
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
views
.
count
:
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
...
...
@@ -253,9 +254,9 @@ public class Grid {
n
+=
r
+
ro
-
1
case
.
any
:
let
r
=
child
.
grid
.
rows
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
views
.
count
:
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
c
=
child
.
grid
.
columns
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
views
.
count
:
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
...
...
Sources/iOS/ImageCard.swift
View file @
ea72a610
...
...
@@ -67,12 +67,18 @@ open class ImageCard: Card {
}
}
open
override
func
layout
()
{
open
override
func
reload
()
{
guard
let
iv
=
imageView
else
{
super
.
layout
()
super
.
reload
()
return
}
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
}
var
format
=
"V:|"
var
views
=
[
String
:
Any
]()
var
metrics
=
[
String
:
Any
]()
...
...
@@ -82,7 +88,7 @@ open class ImageCard: Card {
format
+=
"-(imageViewTop)-[imageView]-(imageViewBottom)"
views
[
"imageView"
]
=
iv
layout
(
iv
)
.
horizontally
(
left
:
imageViewEdgeInsets
.
left
,
right
:
imageViewEdgeInsets
.
right
)
container
.
layout
(
iv
)
.
horizontally
(
left
:
imageViewEdgeInsets
.
left
,
right
:
imageViewEdgeInsets
.
right
)
iv
.
divider
.
reload
()
if
let
v
=
toolbar
{
...
...
@@ -103,7 +109,7 @@ open class ImageCard: Card {
format
+=
"-[contentView]-(contentViewBottom)"
views
[
"contentView"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -120,7 +126,7 @@ open class ImageCard: Card {
}
views
[
"bottomBar"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -129,6 +135,6 @@ open class ImageCard: Card {
return
}
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
Sources/iOS/PresenterCard.swift
View file @
ea72a610
...
...
@@ -54,7 +54,13 @@ open class PresenterCard: Card {
}
}
open
override
func
layout
()
{
open
override
func
reload
()
{
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
}
var
format
=
"V:|"
var
views
=
[
String
:
Any
]()
var
metrics
=
[
String
:
Any
]()
...
...
@@ -65,7 +71,7 @@ open class PresenterCard: Card {
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -82,7 +88,7 @@ open class PresenterCard: Card {
}
views
[
"presenterView"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
presenterViewEdgeInsets
.
left
,
right
:
presenterViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
presenterViewEdgeInsets
.
left
,
right
:
presenterViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -102,7 +108,7 @@ open class PresenterCard: Card {
}
views
[
"contentView"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -125,7 +131,7 @@ open class PresenterCard: Card {
}
views
[
"bottomBar"
]
=
v
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
...
...
@@ -134,8 +140,6 @@ open class PresenterCard: Card {
return
}
print
(
format
)
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
}
Sources/iOS/SearchBar.swift
View file @
ea72a610
...
...
@@ -122,9 +122,10 @@ open class SearchBar: Bar {
A convenience initializer with parameter settings.
- Parameter leftViews: An Array of UIViews that go on the left side.
- Parameter rightViews: An Array of UIViews that go on the right side.
- Parameter centerViews: An Array of UIViews that go in the center.
*/
public
override
init
(
leftViews
:
[
UIView
]?
=
nil
,
right
Views
:
[
UIView
]?
=
nil
)
{
super
.
init
(
leftViews
:
leftViews
,
rightViews
:
right
Views
)
public
override
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
,
center
Views
:
[
UIView
]?
=
nil
)
{
super
.
init
(
leftViews
:
leftViews
,
rightViews
:
rightViews
,
centerViews
:
center
Views
)
}
/**
...
...
Sources/iOS/Toolbar.swift
View file @
ea72a610
...
...
@@ -87,9 +87,10 @@ open class Toolbar: Bar {
A convenience initializer with parameter settings.
- Parameter leftViews: An Array of UIViews that go on the left side.
- Parameter rightViews: An Array of UIViews that go on the right side.
- Parameter centerViews: An Array of UIViews that go in the center.
*/
public
override
init
(
leftViews
:
[
UIView
]?
=
nil
,
right
Views
:
[
UIView
]?
=
nil
)
{
super
.
init
(
leftViews
:
leftViews
,
rightViews
:
right
Views
)
public
override
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
,
center
Views
:
[
UIView
]?
=
nil
)
{
super
.
init
(
leftViews
:
leftViews
,
rightViews
:
rightViews
,
centerViews
:
center
Views
)
}
open
override
func
observeValue
(
forKeyPath
keyPath
:
String
?,
of
object
:
Any
?,
change
:
[
NSKeyValueChangeKey
:
Any
]?,
context
:
UnsafeMutableRawPointer
?)
{
...
...
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