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
52a42ed4
Unverified
Commit
52a42ed4
authored
Jun 11, 2016
by
M. Porooshani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated example projects to new Layout API
parent
b639eaf4
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
38 additions
and
67 deletions
+38
-67
Examples/Programmatic/App/App/AppLeftViewController.swift
+3
-12
Examples/Programmatic/App/App/AppMenuController.swift
+2
-2
Examples/Programmatic/App/App/ItemViewController.swift
+1
-1
Examples/Programmatic/App/App/RecipesViewController.swift
+2
-2
Examples/Programmatic/App/App/RecommendationViewController.swift
+2
-2
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
+1
-1
Examples/Programmatic/CardView/CardView/ViewController.swift
+4
-8
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
+2
-4
Examples/Programmatic/Layout/Layout/ViewController.swift
+4
-12
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
+1
-1
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
+1
-1
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
+2
-2
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
+2
-3
Examples/Programmatic/MenuView/MenuView/ViewController.swift
+1
-2
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
+1
-1
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
+2
-2
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
+1
-1
Examples/Programmatic/TextField/TextField/ViewController.swift
+3
-6
Examples/Programmatic/TextView/TextView/ViewController.swift
+1
-1
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
+1
-1
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
+1
-2
No files found.
Examples/Programmatic/App/App/AppLeftViewController.swift
View file @
52a42ed4
...
...
@@ -96,17 +96,8 @@ class AppLeftViewController: UIViewController {
nameLabel
.
textColor
=
MaterialColor
.
white
nameLabel
.
font
=
RobotoFont
.
mediumWithSize
(
18
)
view
.
layout
.
size
(
profileView
,
width
:
72
,
height
:
72
)
// view.layout.align.topLeft(profileView, top: 30, left: (view.bounds.width - 72) / 2)
view
.
layout
(
profileView
)
.
top
(
30
)
.
left
((
view
.
bounds
.
width
-
72
)
/
2
)
view
.
addSubview
(
nameLabel
)
Layout
.
alignFromTop
(
view
,
child
:
nameLabel
,
top
:
130
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
nameLabel
,
left
:
20
,
right
:
20
)
// view.layout.alignFromTop(nameLabel, top: 130)
// view.layout.horizontally(nameLabel, left: 20, right: 20)
view
.
layout
(
profileView
)
.
width
(
72
)
.
height
(
72
)
.
top
(
30
)
.
centerHorizontally
()
view
.
layout
(
nameLabel
)
.
top
(
130
)
.
left
(
20
)
.
right
(
20
)
}
/// Prepares the tableView.
...
...
@@ -118,7 +109,7 @@ class AppLeftViewController: UIViewController {
tableView
.
separatorStyle
=
.
None
// Use Layout to easily align the tableView.
view
.
layout
.
edges
(
tableView
,
top
:
170
)
view
.
layout
(
tableView
)
.
edges
(
top
:
170
)
}
}
...
...
Examples/Programmatic/App/App/AppMenuController.swift
View file @
52a42ed4
...
...
@@ -156,8 +156,8 @@ class AppMenuController: MenuController {
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
delegate
=
self
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
heigh
t
)
view
.
layout
.
bottomRight
(
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
view
.
layout
(
menuView
)
.
width
(
baseSize
.
width
)
.
height
(
baseSize
.
height
)
.
bottom
(
menuViewInset
)
.
right
(
menuViewInse
t
)
}
/// Prepare tabBarItem.
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
52a42ed4
...
...
@@ -82,7 +82,7 @@ class ItemViewController: UIViewController {
scrollView
.
frame
=
view
.
bounds
scrollView
.
removeConstraints
(
scrollView
.
constraints
)
scrollView
.
layout
.
width
(
imageCardView
,
width
:
scrollView
.
bounds
.
width
)
scrollView
.
layout
(
imageCardView
)
.
width
(
scrollView
.
bounds
.
width
)
imageCardView
.
layoutIfNeeded
()
scrollView
.
contentSize
=
CGSizeMake
(
view
.
bounds
.
width
,
imageCardView
.
height
)
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
52a42ed4
...
...
@@ -169,7 +169,7 @@ class RecipesViewController: UIViewController {
tableView
.
delegate
=
self
// Use Layout to easily align the tableView.
view
.
layout
.
edges
(
tableView
)
view
.
layout
(
tableView
)
.
edges
(
)
}
}
...
...
@@ -214,7 +214,7 @@ extension RecipesViewController: UITableViewDataSource {
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
text
=
"Favorites"
header
.
layout
.
edges
(
label
,
left
:
24
)
header
.
layout
(
label
)
.
edges
(
left
:
24
)
return
header
}
...
...
Examples/Programmatic/App/App/RecommendationViewController.swift
View file @
52a42ed4
...
...
@@ -70,7 +70,7 @@ class RecommendationViewController: UIViewController {
tableView
.
delegate
=
self
// Use Layout to easily align the tableView.
view
.
layout
.
edges
(
tableView
)
view
.
layout
(
tableView
)
.
edges
(
)
}
}
...
...
@@ -115,7 +115,7 @@ extension RecommendationViewController: UITableViewDataSource {
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
text
=
"Recommendations"
header
.
layout
.
edges
(
label
,
left
:
24
)
header
.
layout
(
label
)
.
edges
(
left
:
24
)
return
header
}
...
...
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
View file @
52a42ed4
...
...
@@ -226,7 +226,7 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
captureView
.
tapToExposeEnabled
=
true
captureView
.
delegate
=
self
captureView
.
captureSession
.
delegate
=
self
view
.
layout
.
align
(
captureView
)
view
.
layout
(
captureView
)
.
edges
(
)
}
/**
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
52a42ed4
...
...
@@ -79,8 +79,7 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
,
btn2
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
cardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
private
func
prepareCardViewWithoutPulseBackgroundImageExample
()
{
...
...
@@ -117,8 +116,7 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
cardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
private
func
prepareCardViewWithPulseBackgroundImageExample
()
{
...
...
@@ -156,8 +154,7 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
cardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
private
func
prepareCardViewButtonBarExample
()
{
...
...
@@ -194,8 +191,7 @@ class ViewController: UIViewController {
cardView
.
rightButtons
=
[
btn2
,
btn3
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
cardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
}
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
View file @
52a42ed4
...
...
@@ -83,8 +83,7 @@ class ViewController: UIViewController {
imageCardView
.
leftButtons
=
[
btn1
,
btn2
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
imageCardView
,
top
:
100
)
view
.
layout
.
horizontally
(
imageCardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
imageCardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
private
func
prepareImageCardViewWithoutDetailLabelAndDividerExample
()
{
...
...
@@ -132,8 +131,7 @@ class ViewController: UIViewController {
imageCardView
.
rightButtons
=
[
btn1
,
btn2
,
btn3
]
// To support orientation changes, use Layout.
view
.
layout
.
alignFromTop
(
imageCardView
,
top
:
100
)
view
.
layout
.
horizontally
(
imageCardView
,
left
:
20
,
right
:
20
)
view
.
layout
(
imageCardView
)
.
top
(
100
)
.
left
(
20
)
.
right
(
20
)
}
}
Examples/Programmatic/Layout/Layout/ViewController.swift
View file @
52a42ed4
...
...
@@ -74,12 +74,7 @@ class ViewController: UIViewController {
let
children
:
Array
<
UIView
>
=
[
label1
,
label2
,
label3
,
label4
]
// Align the labels vertically with an equal height.
// view.layout.vertically(children, top: 100, bottom: 100)
// Align the labels horizontally with an equal width.
// view.layout.horizontally(children, left: 30, right: 30, spacing: 30)
// Align the labels horizontally with an equal width and vertically with an equal height.
view
.
layout
.
horizontally
(
children
,
left
:
30
,
right
:
30
,
spacing
:
30
)
.
vertically
(
children
,
top
:
100
,
bottom
:
100
)
...
...
@@ -101,8 +96,7 @@ class ViewController: UIViewController {
labelCX
.
layer
.
cornerRadius
=
length
/
2.0
labelCX
.
clipsToBounds
=
true
view
.
layout
.
size
(
labelCX
,
width
:
length
,
height
:
length
)
view
.
layout
.
centerHorizontally
(
labelCX
)
view
.
layout
(
labelCX
)
.
width
(
length
)
.
height
(
length
)
.
centerHorizontally
()
let
labelCY
=
UILabel
()
labelCY
.
backgroundColor
=
MaterialColor
.
grey
.
base
...
...
@@ -111,8 +105,7 @@ class ViewController: UIViewController {
labelCY
.
layer
.
cornerRadius
=
length
/
2.0
labelCY
.
clipsToBounds
=
true
view
.
layout
.
size
(
labelCY
,
width
:
length
,
height
:
length
)
view
.
layout
.
centerVertically
(
labelCY
)
view
.
layout
(
labelCY
)
.
width
(
length
)
.
height
(
length
)
.
centerVertically
()
let
labelCXY
=
UILabel
()
labelCXY
.
backgroundColor
=
MaterialColor
.
grey
.
base
...
...
@@ -121,8 +114,7 @@ class ViewController: UIViewController {
labelCXY
.
layer
.
cornerRadius
=
length
/
2.0
labelCXY
.
clipsToBounds
=
true
view
.
layout
.
size
(
labelCXY
,
width
:
length
,
height
:
length
)
view
.
layout
.
center
(
labelCXY
)
view
.
layout
(
labelCXY
)
.
width
(
length
)
.
height
(
length
)
.
center
()
}
}
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
View file @
52a42ed4
...
...
@@ -85,7 +85,7 @@ class ViewController: UIViewController {
collectionView
.
contentInset
.
top
=
100
collectionView
.
spacing
=
16
view
.
layout
.
align
(
collectionView
)
view
.
layout
(
collectionView
)
.
edges
(
)
}
}
...
...
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
View file @
52a42ed4
...
...
@@ -70,7 +70,7 @@ class ViewController: UIViewController {
If this is left out, the intrinsic value is used for the view.
*/
for
v
in
children
{
view
.
layout
.
horizontally
(
v
,
left
:
20
,
right
:
20
)
view
.
layout
(
v
)
.
horizontally
(
left
:
20
,
right
:
20
)
}
}
}
...
...
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
View file @
52a42ed4
...
...
@@ -109,11 +109,11 @@ class ViewController: UIViewController {
/// Prepares the tableView.
private
func
prepareTableView
()
{
tableView
.
registerClass
(
MaterialTableViewCell
.
self
,
forCellReuseIdentifier
:
"Cell"
)
view
.
layout
(
tableView
)
.
edges
(
top
:
20
)
tableView
.
registerClass
(
MaterialTableViewCell
.
self
,
forCellReuseIdentifier
:
"Cell"
)
tableView
.
dataSource
=
self
tableView
.
delegate
=
self
view
.
layout
.
align
(
tableView
,
top
:
20
)
}
private
func
image
(
iconName
:
String
!
)
->
UIImage
?
{
...
...
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
View file @
52a42ed4
...
...
@@ -105,7 +105,7 @@ class AppMenuController: MenuController {
view
.
backgroundColor
=
MaterialColor
.
black
prepareMenuView
()
}
/// Prepares the add button.
private
func
prepareMenuView
()
{
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
add
...
...
@@ -148,8 +148,7 @@ class AppMenuController: MenuController {
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
delegate
=
self
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
view
.
layout
.
alignFromBottomRight
(
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
view
.
layout
(
menuView
)
.
width
(
baseSize
.
width
)
.
height
(
baseSize
.
height
)
.
bottom
(
menuViewInset
)
.
right
(
menuViewInset
)
}
}
...
...
Examples/Programmatic/MenuView/MenuView/ViewController.swift
View file @
52a42ed4
...
...
@@ -137,8 +137,7 @@ class ViewController: UIViewController {
menuView
.
menu
.
baseSize
=
CGSizeMake
(
diameter
,
diameter
)
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
view
.
layout
.
size
(
menuView
,
width
:
diameter
,
height
:
diameter
)
view
.
layout
.
alignFromBottomLeft
(
menuView
,
bottom
:
16
,
left
:
(
view
.
bounds
.
width
-
diameter
)
/
2
)
view
.
layout
(
menuView
)
.
width
(
diameter
)
.
height
(
diameter
)
.
bottom
(
16
)
.
centerHorizontally
()
}
}
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
View file @
52a42ed4
...
...
@@ -59,7 +59,7 @@ class ViewController: UIViewController {
/// Prepares the containerView.
private
func
prepareContainerView
()
{
containerView
=
UIView
()
view
.
layout
.
align
(
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
view
.
layout
(
containerView
)
.
edges
(
top
:
100
,
left
:
20
,
right
:
20
)
}
/// Prepares the toolbar
...
...
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
View file @
52a42ed4
...
...
@@ -74,8 +74,8 @@ class AppLeftViewController: UIViewController {
tableView
.
delegate
=
self
tableView
.
separatorStyle
=
.
None
// Use Layout to easily align the tableView.
view
.
layout
.
align
.
edges
(
tableView
)
// Use Layout to easily align the tableView.
view
.
layout
(
tableView
)
.
edges
(
top
:
170
)
}
}
...
...
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
View file @
52a42ed4
...
...
@@ -117,7 +117,7 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
rightButtons
=
[
settingButton
]
view
.
layout
.
align
(
cardView
,
left
:
10
,
right
:
10
,
top
:
100
,
bottom
:
100
)
view
.
layout
(
cardView
)
.
edges
(
left
:
10
,
right
:
10
,
top
:
100
,
bottom
:
100
)
}
}
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
52a42ed4
...
...
@@ -70,8 +70,7 @@ class ViewController: UIViewController, TextFieldDelegate {
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Normal
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Highlighted
)
view
.
layout
.
size
(
btn
,
width
:
100
,
height
:
50
)
view
.
layout
.
alignFromBottomRight
(
btn
,
bottom
:
24
,
right
:
24
)
view
.
layout
(
btn
)
.
width
(
100
)
.
height
(
50
)
.
bottom
(
24
)
.
right
(
24
)
}
/// Handle the resign responder button.
...
...
@@ -93,8 +92,7 @@ class ViewController: UIViewController, TextFieldDelegate {
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 40 pixels.
view
.
layout
.
alignFromTop
(
nameField
,
top
:
40
)
view
.
layout
.
horizontally
(
nameField
,
left
:
40
,
right
:
40
)
view
.
layout
(
nameField
)
.
top
(
40
)
.
horizontally
(
left
:
40
,
right
:
40
)
}
/// Prepares the email TextField.
...
...
@@ -125,8 +123,7 @@ class ViewController: UIViewController, TextFieldDelegate {
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 200 pixels.
view
.
layout
.
alignFromTop
(
passwordField
,
top
:
200
)
view
.
layout
.
horizontally
(
passwordField
,
left
:
40
,
right
:
40
)
view
.
layout
(
passwordField
)
.
top
(
200
)
.
horizontally
(
left
:
40
,
right
:
40
)
}
/// Executed when the 'return' key is pressed when using the emailField.
...
...
Examples/Programmatic/TextView/TextView/ViewController.swift
View file @
52a42ed4
...
...
@@ -75,7 +75,7 @@ class ViewController: UIViewController, TextDelegate {
textView
.
titleLabelColor
=
MaterialColor
.
grey
.
base
textView
.
titleLabelActiveColor
=
MaterialColor
.
blue
.
accent3
view
.
layout
.
align
(
textView
!
,
top
:
124
,
left
:
24
,
bottom
:
24
,
right
:
24
)
view
.
layout
(
textView
!
)
.
edges
(
top
:
124
,
left
:
24
,
bottom
:
24
,
right
:
24
)
}
/**
...
...
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
View file @
52a42ed4
...
...
@@ -59,7 +59,7 @@ class ViewController: UIViewController {
/// Prepares the containerView.
private
func
prepareContainerView
()
{
containerView
=
UIView
()
view
.
layout
.
align
.
edges
(
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
view
.
layout
(
containerView
)
.
edges
(
top
:
100
,
left
:
20
,
right
:
20
)
}
/// Prepares the toolbar
...
...
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
View file @
52a42ed4
...
...
@@ -43,8 +43,7 @@ class RootViewController: UIViewController {
fabButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
fabButton
.
addTarget
(
self
,
action
:
#selector(
handleFabButton
)
,
forControlEvents
:
.
TouchUpInside
)
view
.
layout
.
size
(
fabButton
,
width
:
64
,
height
:
64
)
view
.
layout
.
alignFromBottomRight
(
fabButton
,
bottom
:
16
,
right
:
16
)
view
.
layout
(
fabButton
)
.
width
(
64
)
.
height
(
64
)
.
bottom
(
16
)
.
right
(
16
)
}
// FabButton handler.
...
...
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