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
6afa56be
Commit
6afa56be
authored
Jun 05, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated all projects to use Layout
parent
eb4851dc
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
70 additions
and
152 deletions
+70
-152
Examples/Programmatic/App/App/AppLeftViewController.swift
+5
-8
Examples/Programmatic/App/App/AppMenuController.swift
+2
-3
Examples/Programmatic/App/App/AppNavigationController.swift
+1
-21
Examples/Programmatic/App/App/ItemViewController.swift
+1
-4
Examples/Programmatic/App/App/RecipesViewController.swift
+2
-4
Examples/Programmatic/App/App/RecommendationViewController.swift
+2
-4
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
+1
-1
Examples/Programmatic/CardView/CardView/ViewController.swift
+8
-12
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
+4
-6
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
+1
-2
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
+2
-7
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
+1
-3
Examples/Programmatic/MaterialSwitch/MaterialSwitch/ViewController.swift
+11
-20
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
+2
-3
Examples/Programmatic/MenuView/MenuView/ViewController.swift
+2
-3
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
+1
-3
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
+1
-2
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
+1
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+6
-11
Examples/Programmatic/TextView/TextView/ViewController.swift
+1
-2
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
+1
-3
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
+2
-3
Sources/iOS/BottomTabBar.swift
+2
-2
Sources/iOS/CardView.swift
+4
-10
Sources/iOS/ImageCardView.swift
+5
-11
Sources/iOS/TextView.swift
+1
-2
No files found.
Examples/Programmatic/App/App/AppLeftViewController.swift
View file @
6afa56be
...
@@ -90,19 +90,17 @@ class AppLeftViewController: UIViewController {
...
@@ -90,19 +90,17 @@ class AppLeftViewController: UIViewController {
profileView
.
shape
=
.
Circle
profileView
.
shape
=
.
Circle
profileView
.
borderColor
=
MaterialColor
.
white
profileView
.
borderColor
=
MaterialColor
.
white
profileView
.
borderWidth
=
3
profileView
.
borderWidth
=
3
view
.
addSubview
(
profileView
)
let
nameLabel
:
UILabel
=
UILabel
()
let
nameLabel
:
UILabel
=
UILabel
()
nameLabel
.
text
=
"Michael Smith"
nameLabel
.
text
=
"Michael Smith"
nameLabel
.
textColor
=
MaterialColor
.
white
nameLabel
.
textColor
=
MaterialColor
.
white
nameLabel
.
font
=
RobotoFont
.
mediumWithSize
(
18
)
nameLabel
.
font
=
RobotoFont
.
mediumWithSize
(
18
)
view
.
addSubview
(
nameLabel
)
Layout
.
alignFromTopLeft
(
view
,
child
:
profileView
,
top
:
30
,
left
:
(
view
.
bounds
.
width
-
72
)
/
2
)
view
.
layout
.
size
(
profileView
,
width
:
72
,
height
:
7
2
)
Layout
.
size
(
view
,
child
:
profileView
,
width
:
72
,
height
:
7
2
)
view
.
layout
.
alignFromTopLeft
(
profileView
,
top
:
30
,
left
:
(
view
.
bounds
.
width
-
72
)
/
2
)
Layout
.
alignFromTop
(
view
,
child
:
nameLabel
,
top
:
130
)
view
.
layout
.
alignFromTop
(
nameLabel
,
top
:
130
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
nameLabel
,
left
:
20
,
right
:
20
)
view
.
layout
.
horizontally
(
nameLabel
,
left
:
20
,
right
:
20
)
}
}
/// Prepares the tableView.
/// Prepares the tableView.
...
@@ -114,8 +112,7 @@ class AppLeftViewController: UIViewController {
...
@@ -114,8 +112,7 @@ class AppLeftViewController: UIViewController {
tableView
.
separatorStyle
=
.
None
tableView
.
separatorStyle
=
.
None
// Use Layout to easily align the tableView.
// Use Layout to easily align the tableView.
view
.
addSubview
(
tableView
)
view
.
layout
.
align
(
tableView
,
top
:
170
)
Layout
.
alignToParent
(
view
,
child
:
tableView
,
top
:
170
)
}
}
}
}
...
...
Examples/Programmatic/App/App/AppMenuController.swift
View file @
6afa56be
...
@@ -140,9 +140,8 @@ class AppMenuController: MenuController {
...
@@ -140,9 +140,8 @@ class AppMenuController: MenuController {
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
delegate
=
self
menuView
.
delegate
=
self
view
.
addSubview
(
menuView
)
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
Layout
.
size
(
view
,
child
:
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
view
.
layout
.
alignFromBottomRight
(
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
Layout
.
alignFromBottomRight
(
view
,
child
:
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
}
}
/// Prepare tabBarItem.
/// Prepare tabBarItem.
...
...
Examples/Programmatic/App/App/AppNavigationController.swift
View file @
6afa56be
...
@@ -32,31 +32,11 @@ import UIKit
...
@@ -32,31 +32,11 @@ import UIKit
import
Material
import
Material
class
AppNavigationController
:
NavigationController
{
class
AppNavigationController
:
NavigationController
{
/// StatusBar color reference.
// private var statusBarView: MaterialView?
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
// prepareStatusBarView()
prepareNavigationBar
()
prepareNavigationBar
()
}
}
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
// statusBarView?.hidden = MaterialDevice.statusBarHidden
}
/// Prepares the statusBarView
// private func prepareStatusBarView() {
// statusBarView = MaterialView()
// statusBarView!.backgroundColor = MaterialColor.blue.darken2
//
// view.addSubview(statusBarView!)
// Layout.alignFromTop(view, child: statusBarView!)
// Layout.alignToParentHorizontally(view, child: statusBarView!)
// Layout.height(view, child: statusBarView!, height: 20)
// }
/// Prepares the navigationBar
/// Prepares the navigationBar
private
func
prepareNavigationBar
()
{
private
func
prepareNavigationBar
()
{
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
tintColor
=
MaterialColor
.
white
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
6afa56be
...
@@ -95,7 +95,7 @@ class ItemViewController: UIViewController {
...
@@ -95,7 +95,7 @@ class ItemViewController: UIViewController {
scrollView
.
frame
=
view
.
bounds
scrollView
.
frame
=
view
.
bounds
scrollView
.
removeConstraints
(
scrollView
.
constraints
)
scrollView
.
removeConstraints
(
scrollView
.
constraints
)
Layout
.
width
(
scrollView
,
child
:
imageCardView
,
width
:
scrollView
.
bounds
.
width
)
scrollView
.
layout
.
width
(
imageCardView
,
width
:
scrollView
.
bounds
.
width
)
imageCardView
.
layoutIfNeeded
()
imageCardView
.
layoutIfNeeded
()
scrollView
.
contentSize
=
CGSizeMake
(
view
.
bounds
.
width
,
imageCardView
.
height
)
scrollView
.
contentSize
=
CGSizeMake
(
view
.
bounds
.
width
,
imageCardView
.
height
)
...
@@ -167,9 +167,6 @@ class ItemViewController: UIViewController {
...
@@ -167,9 +167,6 @@ class ItemViewController: UIViewController {
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
imageCardView
.
image
=
image
imageCardView
.
image
=
image
scrollView
.
addSubview
(
imageCardView
)
imageCardView
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
}
}
}
}
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
6afa56be
...
@@ -261,8 +261,7 @@ class RecipesViewController: UIViewController {
...
@@ -261,8 +261,7 @@ class RecipesViewController: UIViewController {
tableView
.
delegate
=
self
tableView
.
delegate
=
self
// Use Layout to easily align the tableView.
// Use Layout to easily align the tableView.
view
.
addSubview
(
tableView
)
view
.
layout
.
align
(
tableView
)
Layout
.
alignToParent
(
view
,
child
:
tableView
)
}
}
}
}
...
@@ -307,8 +306,7 @@ extension RecipesViewController: UITableViewDataSource {
...
@@ -307,8 +306,7 @@ extension RecipesViewController: UITableViewDataSource {
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
text
=
"Favorites"
label
.
text
=
"Favorites"
header
.
addSubview
(
label
)
header
.
layout
.
align
(
label
,
left
:
24
)
Layout
.
alignToParent
(
header
,
child
:
label
,
left
:
24
)
return
header
return
header
}
}
...
...
Examples/Programmatic/App/App/RecommendationViewController.swift
View file @
6afa56be
...
@@ -70,8 +70,7 @@ class RecommendationViewController: UIViewController {
...
@@ -70,8 +70,7 @@ class RecommendationViewController: UIViewController {
tableView
.
delegate
=
self
tableView
.
delegate
=
self
// Use Layout to easily align the tableView.
// Use Layout to easily align the tableView.
view
.
addSubview
(
tableView
)
view
.
layout
.
align
(
tableView
)
Layout
.
alignToParent
(
view
,
child
:
tableView
)
}
}
}
}
...
@@ -116,8 +115,7 @@ extension RecommendationViewController: UITableViewDataSource {
...
@@ -116,8 +115,7 @@ extension RecommendationViewController: UITableViewDataSource {
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
textColor
=
MaterialColor
.
grey
.
darken1
label
.
text
=
"Recommendations"
label
.
text
=
"Recommendations"
header
.
addSubview
(
label
)
header
.
layout
.
align
(
label
,
left
:
24
)
Layout
.
alignToParent
(
header
,
child
:
label
,
left
:
24
)
return
header
return
header
}
}
...
...
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
View file @
6afa56be
...
@@ -226,7 +226,7 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
...
@@ -226,7 +226,7 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
captureView
.
tapToExposeEnabled
=
true
captureView
.
tapToExposeEnabled
=
true
captureView
.
delegate
=
self
captureView
.
delegate
=
self
captureView
.
captureSession
.
delegate
=
self
captureView
.
captureSession
.
delegate
=
self
Layout
.
alignToParent
(
view
,
child
:
captureView
)
view
.
layout
.
align
(
captureView
)
}
}
/**
/**
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
6afa56be
...
@@ -79,9 +79,8 @@ class ViewController: UIViewController {
...
@@ -79,9 +79,8 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
,
btn2
]
cardView
.
leftButtons
=
[
btn1
,
btn2
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
cardView
)
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
}
private
func
prepareCardViewWithoutPulseBackgroundImageExample
()
{
private
func
prepareCardViewWithoutPulseBackgroundImageExample
()
{
...
@@ -118,9 +117,8 @@ class ViewController: UIViewController {
...
@@ -118,9 +117,8 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
]
cardView
.
leftButtons
=
[
btn1
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
cardView
)
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
}
private
func
prepareCardViewWithPulseBackgroundImageExample
()
{
private
func
prepareCardViewWithPulseBackgroundImageExample
()
{
...
@@ -158,9 +156,8 @@ class ViewController: UIViewController {
...
@@ -158,9 +156,8 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
btn1
]
cardView
.
leftButtons
=
[
btn1
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
cardView
)
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
}
private
func
prepareCardViewButtonBarExample
()
{
private
func
prepareCardViewButtonBarExample
()
{
...
@@ -197,9 +194,8 @@ class ViewController: UIViewController {
...
@@ -197,9 +194,8 @@ class ViewController: UIViewController {
cardView
.
rightButtons
=
[
btn2
,
btn3
]
cardView
.
rightButtons
=
[
btn2
,
btn3
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
cardView
)
view
.
layout
.
alignFromTop
(
cardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
view
.
layout
.
horizontally
(
cardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
}
}
}
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
View file @
6afa56be
...
@@ -83,9 +83,8 @@ class ViewController: UIViewController {
...
@@ -83,9 +83,8 @@ class ViewController: UIViewController {
imageCardView
.
leftButtons
=
[
btn1
,
btn2
]
imageCardView
.
leftButtons
=
[
btn1
,
btn2
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
imageCardView
)
view
.
layout
.
alignFromTop
(
imageCardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
imageCardView
,
top
:
100
)
view
.
layout
.
horizontally
(
imageCardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
imageCardView
,
left
:
20
,
right
:
20
)
}
}
private
func
prepareImageCardViewWithoutDetailLabelAndDividerExample
()
{
private
func
prepareImageCardViewWithoutDetailLabelAndDividerExample
()
{
...
@@ -133,9 +132,8 @@ class ViewController: UIViewController {
...
@@ -133,9 +132,8 @@ class ViewController: UIViewController {
imageCardView
.
rightButtons
=
[
btn1
,
btn2
,
btn3
]
imageCardView
.
rightButtons
=
[
btn1
,
btn2
,
btn3
]
// To support orientation changes, use Layout.
// To support orientation changes, use Layout.
view
.
addSubview
(
imageCardView
)
view
.
layout
.
alignFromTop
(
imageCardView
,
top
:
100
)
Layout
.
alignFromTop
(
view
,
child
:
imageCardView
,
top
:
100
)
view
.
layout
.
horizontally
(
imageCardView
,
left
:
20
,
right
:
20
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
imageCardView
,
left
:
20
,
right
:
20
)
}
}
}
}
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
View file @
6afa56be
...
@@ -85,8 +85,7 @@ class ViewController: UIViewController {
...
@@ -85,8 +85,7 @@ class ViewController: UIViewController {
collectionView
.
contentInset
.
top
=
100
collectionView
.
contentInset
.
top
=
100
collectionView
.
spacing
=
16
collectionView
.
spacing
=
16
view
.
addSubview
(
collectionView
)
view
.
layout
.
align
(
collectionView
)
Layout
.
alignToParent
(
view
,
child
:
collectionView
)
}
}
}
}
...
...
Examples/Programmatic/MaterialDepth/MaterialDepth/ViewController.swift
View file @
6afa56be
...
@@ -47,35 +47,30 @@ class ViewController: UIViewController {
...
@@ -47,35 +47,30 @@ class ViewController: UIViewController {
private
func
prepareMaterialDepth
()
{
private
func
prepareMaterialDepth
()
{
let
v1
:
MaterialView
=
MaterialView
()
let
v1
:
MaterialView
=
MaterialView
()
v1
.
depth
=
.
Depth1
v1
.
depth
=
.
Depth1
view
.
addSubview
(
v1
)
let
v2
:
MaterialView
=
MaterialView
()
let
v2
:
MaterialView
=
MaterialView
()
v2
.
depth
=
.
Depth2
v2
.
depth
=
.
Depth2
view
.
addSubview
(
v2
)
let
v3
:
MaterialView
=
MaterialView
()
let
v3
:
MaterialView
=
MaterialView
()
v3
.
depth
=
.
Depth3
v3
.
depth
=
.
Depth3
view
.
addSubview
(
v3
)
let
v4
:
MaterialView
=
MaterialView
()
let
v4
:
MaterialView
=
MaterialView
()
v4
.
depth
=
.
Depth4
v4
.
depth
=
.
Depth4
view
.
addSubview
(
v4
)
let
v5
:
MaterialView
=
MaterialView
()
let
v5
:
MaterialView
=
MaterialView
()
v5
.
depth
=
.
Depth5
v5
.
depth
=
.
Depth5
view
.
addSubview
(
v5
)
let
children
:
Array
<
UIView
>
=
[
v1
,
v2
,
v3
,
v4
,
v5
]
let
children
:
Array
<
UIView
>
=
[
v1
,
v2
,
v3
,
v4
,
v5
]
// Align the vs vertically with an equal height.
// Align the vs vertically with an equal height.
Layout
.
alignToParentVertically
(
view
,
children
:
children
,
top
:
100
,
bottom
:
100
,
spacing
:
20
)
view
.
layout
.
vertically
(
children
,
top
:
100
,
bottom
:
100
,
spacing
:
20
)
/*
/*
Individually set the vs' horizontal alignment.
Individually set the vs' horizontal alignment.
If this is left out, the intrinsic value is used for the view.
If this is left out, the intrinsic value is used for the view.
*/
*/
for
v
in
children
{
for
v
in
children
{
Layout
.
alignToParentHorizontally
(
view
,
child
:
v
,
left
:
20
,
right
:
20
)
view
.
layout
.
horizontally
(
v
,
left
:
20
,
right
:
20
)
}
}
}
}
}
}
...
...
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
View file @
6afa56be
...
@@ -113,9 +113,7 @@ class ViewController: UIViewController {
...
@@ -113,9 +113,7 @@ class ViewController: UIViewController {
tableView
.
dataSource
=
self
tableView
.
dataSource
=
self
tableView
.
delegate
=
self
tableView
.
delegate
=
self
view
.
addSubview
(
tableView
)
view
.
layout
.
align
(
tableView
,
top
:
20
)
Layout
.
alignToParent
(
view
,
child
:
tableView
,
top
:
20
,
left
:
0
,
bottom
:
0
,
right
:
0
)
}
}
private
func
image
(
iconName
:
String
!
)
->
UIImage
?
{
private
func
image
(
iconName
:
String
!
)
->
UIImage
?
{
...
...
Examples/Programmatic/MaterialSwitch/MaterialSwitch/ViewController.swift
View file @
6afa56be
...
@@ -50,56 +50,47 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
...
@@ -50,56 +50,47 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
private
func
prepareView
()
{
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
view
.
backgroundColor
=
MaterialColor
.
white
view
.
addSubview
(
topView
)
view
.
addSubview
(
bottomView
)
bottomView
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
bottomView
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
Layout
.
alignToParentHorizontally
(
view
,
child
:
topView
)
view
.
layout
.
horizontally
(
topView
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
bottomView
)
view
.
layout
.
horizontally
(
bottomView
)
Layout
.
alignToParentVertically
(
view
,
children
:
[
topView
,
bottomView
])
view
.
layout
.
vertically
(
[
topView
,
bottomView
])
}
}
/// Prepares the LightContent MaterialSwitch.
/// Prepares the LightContent MaterialSwitch.
private
func
prepareLightContentMaterialSwitch
()
{
private
func
prepareLightContentMaterialSwitch
()
{
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
c1
.
delegate
=
self
c1
.
delegate
=
self
topView
.
addSubview
(
c1
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
,
style
:
.
LightContent
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
,
style
:
.
LightContent
)
c2
.
delegate
=
self
c2
.
delegate
=
self
topView
.
addSubview
(
c2
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Large
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Large
)
c3
.
delegate
=
self
c3
.
delegate
=
self
c3
.
enabled
=
false
c3
.
enabled
=
false
topView
.
addSubview
(
c3
)
Layout
.
alignToParentHorizontally
(
topView
,
child
:
c1
)
topView
.
layout
.
horizontally
(
c1
)
Layout
.
alignToParentHorizontally
(
topView
,
child
:
c2
)
topView
.
layout
.
horizontally
(
c2
)
Layout
.
alignToParentHorizontally
(
topView
,
child
:
c3
)
topView
.
layout
.
horizontally
(
c3
)
Layout
.
alignToParentVertically
(
topView
,
children
:
[
c1
,
c2
,
c3
])
topView
.
layout
.
vertically
(
[
c1
,
c2
,
c3
])
}
}
/// Prepares the LightContent MaterialSwitch.
/// Prepares the LightContent MaterialSwitch.
private
func
prepareDefaultMaterialSwitch
()
{
private
func
prepareDefaultMaterialSwitch
()
{
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Small
)
let
c1
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Small
)
c1
.
delegate
=
self
c1
.
delegate
=
self
bottomView
.
addSubview
(
c1
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
)
let
c2
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
On
)
c2
.
delegate
=
self
c2
.
delegate
=
self
bottomView
.
addSubview
(
c2
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Large
)
let
c3
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
Default
,
size
:
.
Large
)
c3
.
delegate
=
self
c3
.
delegate
=
self
c3
.
enabled
=
false
c3
.
enabled
=
false
bottomView
.
addSubview
(
c3
)
Layout
.
alignToParentHorizontally
(
bottomView
,
child
:
c1
)
bottomView
.
layout
.
horizontally
(
c1
)
Layout
.
alignToParentHorizontally
(
bottomView
,
child
:
c2
)
bottomView
.
layout
.
horizontally
(
c2
)
Layout
.
alignToParentHorizontally
(
bottomView
,
child
:
c3
)
bottomView
.
layout
.
horizontally
(
c3
)
Layout
.
alignToParentVertically
(
bottomView
,
children
:
[
c1
,
c2
,
c3
])
bottomView
.
layout
.
vertically
(
[
c1
,
c2
,
c3
])
}
}
internal
func
materialSwitchStateChanged
(
control
:
MaterialSwitch
)
{
internal
func
materialSwitchStateChanged
(
control
:
MaterialSwitch
)
{
...
...
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
View file @
6afa56be
...
@@ -148,9 +148,8 @@ class AppMenuController: MenuController {
...
@@ -148,9 +148,8 @@ class AppMenuController: MenuController {
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
delegate
=
self
menuView
.
delegate
=
self
view
.
addSubview
(
menuView
)
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
Layout
.
size
(
view
,
child
:
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
view
.
layout
.
alignFromBottomRight
(
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
Layout
.
alignFromBottomRight
(
view
,
child
:
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
}
}
}
}
...
...
Examples/Programmatic/MenuView/MenuView/ViewController.swift
View file @
6afa56be
...
@@ -137,9 +137,8 @@ class ViewController: UIViewController {
...
@@ -137,9 +137,8 @@ class ViewController: UIViewController {
menuView
.
menu
.
baseSize
=
CGSizeMake
(
diameter
,
diameter
)
menuView
.
menu
.
baseSize
=
CGSizeMake
(
diameter
,
diameter
)
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
view
.
addSubview
(
menuView
)
view
.
layout
.
size
(
menuView
,
width
:
diameter
,
height
:
diameter
)
Layout
.
size
(
view
,
child
:
menuView
,
width
:
diameter
,
height
:
diameter
)
view
.
layout
.
alignFromBottomLeft
(
menuView
,
bottom
:
16
,
left
:
(
view
.
bounds
.
width
-
diameter
)
/
2
)
Layout
.
alignFromBottomLeft
(
view
,
child
:
menuView
,
bottom
:
16
,
left
:
(
view
.
bounds
.
width
-
diameter
)
/
2
)
}
}
}
}
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
View file @
6afa56be
...
@@ -59,9 +59,7 @@ class ViewController: UIViewController {
...
@@ -59,9 +59,7 @@ class ViewController: UIViewController {
/// Prepares the containerView.
/// Prepares the containerView.
private
func
prepareContainerView
()
{
private
func
prepareContainerView
()
{
containerView
=
UIView
()
containerView
=
UIView
()
view
.
addSubview
(
containerView
)
view
.
layout
.
align
(
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
Layout
.
alignToParent
(
view
,
child
:
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
}
}
/// Prepares the toolbar
/// Prepares the toolbar
...
...
Examples/Programmatic/SideNavigationController/SideNavigationController/AppLeftViewController.swift
View file @
6afa56be
...
@@ -75,8 +75,7 @@ class AppLeftViewController: UIViewController {
...
@@ -75,8 +75,7 @@ class AppLeftViewController: UIViewController {
tableView
.
separatorStyle
=
.
None
tableView
.
separatorStyle
=
.
None
// Use Layout to easily align the tableView.
// Use Layout to easily align the tableView.
view
.
addSubview
(
tableView
)
view
.
layout
.
align
(
tableView
)
Layout
.
alignToParent
(
view
,
child
:
tableView
)
}
}
}
}
...
...
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
View file @
6afa56be
...
@@ -117,8 +117,7 @@ class ViewController: UIViewController {
...
@@ -117,8 +117,7 @@ class ViewController: UIViewController {
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
rightButtons
=
[
settingButton
]
cardView
.
rightButtons
=
[
settingButton
]
view
.
addSubview
(
cardView
)
view
.
layout
.
align
(
cardView
,
left
:
10
,
right
:
10
,
top
:
100
,
bottom
:
100
)
Layout
.
alignToParent
(
view
,
child
:
cardView
,
left
:
10
,
right
:
10
,
top
:
100
,
bottom
:
100
)
}
}
}
}
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
6afa56be
...
@@ -69,10 +69,9 @@ class ViewController: UIViewController, TextFieldDelegate {
...
@@ -69,10 +69,9 @@ class ViewController: UIViewController, TextFieldDelegate {
btn
.
setTitle
(
"Resign"
,
forState
:
.
Normal
)
btn
.
setTitle
(
"Resign"
,
forState
:
.
Normal
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Normal
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Normal
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Highlighted
)
btn
.
setTitleColor
(
MaterialColor
.
blue
.
base
,
forState
:
.
Highlighted
)
view
.
addSubview
(
btn
)
Layout
.
alignFromBottomRight
(
view
,
child
:
btn
,
bottom
:
24
,
right
:
24
)
view
.
layout
.
size
(
btn
,
width
:
100
,
height
:
50
)
Layout
.
size
(
view
,
child
:
btn
,
width
:
100
,
height
:
50
)
view
.
layout
.
alignFromBottomRight
(
btn
,
bottom
:
24
,
right
:
24
)
}
}
/// Handle the resign responder button.
/// Handle the resign responder button.
...
@@ -92,12 +91,10 @@ class ViewController: UIViewController, TextFieldDelegate {
...
@@ -92,12 +91,10 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField
.
textAlignment
=
.
Center
nameField
.
textAlignment
=
.
Center
nameField
.
clearButtonMode
=
.
WhileEditing
nameField
.
clearButtonMode
=
.
WhileEditing
view
.
addSubview
(
nameField
)
// Size the TextField to the maximum width, less 40 pixels on either side
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 40 pixels.
// with a top margin of 40 pixels.
Layout
.
alignFromTop
(
view
,
child
:
nameField
,
top
:
40
)
view
.
layout
.
alignFromTop
(
nameField
,
top
:
40
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
nameField
,
left
:
40
,
right
:
40
)
view
.
layout
.
horizontally
(
nameField
,
left
:
40
,
right
:
40
)
}
}
/// Prepares the email TextField.
/// Prepares the email TextField.
...
@@ -126,12 +123,10 @@ class ViewController: UIViewController, TextFieldDelegate {
...
@@ -126,12 +123,10 @@ class ViewController: UIViewController, TextFieldDelegate {
// Setting the visibilityFlatButton color.
// Setting the visibilityFlatButton color.
passwordField
.
visibilityIconButton
?
.
tintColor
=
MaterialColor
.
green
.
base
.
colorWithAlphaComponent
(
passwordField
.
secureTextEntry
?
0.38
:
0.54
)
passwordField
.
visibilityIconButton
?
.
tintColor
=
MaterialColor
.
green
.
base
.
colorWithAlphaComponent
(
passwordField
.
secureTextEntry
?
0.38
:
0.54
)
view
.
addSubview
(
passwordField
)
// Size the TextField to the maximum width, less 40 pixels on either side
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 200 pixels.
// with a top margin of 200 pixels.
Layout
.
alignFromTop
(
view
,
child
:
passwordField
,
top
:
200
)
view
.
layout
.
alignFromTop
(
passwordField
,
top
:
200
)
Layout
.
alignToParentHorizontally
(
view
,
child
:
passwordField
,
left
:
40
,
right
:
40
)
view
.
layout
.
horizontally
(
passwordField
,
left
:
40
,
right
:
40
)
}
}
/// Executed when the 'return' key is pressed when using the emailField.
/// Executed when the 'return' key is pressed when using the emailField.
...
...
Examples/Programmatic/TextView/TextView/ViewController.swift
View file @
6afa56be
...
@@ -75,8 +75,7 @@ class ViewController: UIViewController, TextDelegate {
...
@@ -75,8 +75,7 @@ class ViewController: UIViewController, TextDelegate {
textView
.
titleLabelColor
=
MaterialColor
.
grey
.
base
textView
.
titleLabelColor
=
MaterialColor
.
grey
.
base
textView
.
titleLabelActiveColor
=
MaterialColor
.
blue
.
accent3
textView
.
titleLabelActiveColor
=
MaterialColor
.
blue
.
accent3
view
.
addSubview
(
textView
)
view
.
layout
.
align
(
textView
!
,
top
:
124
,
left
:
24
,
bottom
:
24
,
right
:
24
)
Layout
.
alignToParent
(
view
,
child
:
textView
!
,
top
:
124
,
left
:
24
,
bottom
:
24
,
right
:
24
)
}
}
/**
/**
...
...
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
View file @
6afa56be
...
@@ -59,9 +59,7 @@ class ViewController: UIViewController {
...
@@ -59,9 +59,7 @@ class ViewController: UIViewController {
/// Prepares the containerView.
/// Prepares the containerView.
private
func
prepareContainerView
()
{
private
func
prepareContainerView
()
{
containerView
=
UIView
()
containerView
=
UIView
()
view
.
addSubview
(
containerView
)
view
.
layout
.
align
(
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
Layout
.
alignToParent
(
view
,
child
:
containerView
,
top
:
100
,
left
:
20
,
right
:
20
)
}
}
/// Prepares the toolbar
/// Prepares the toolbar
...
...
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
View file @
6afa56be
...
@@ -43,9 +43,8 @@ class RootViewController: UIViewController {
...
@@ -43,9 +43,8 @@ class RootViewController: UIViewController {
fabButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
fabButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
fabButton
.
addTarget
(
self
,
action
:
#selector(
handleFabButton
)
,
forControlEvents
:
.
TouchUpInside
)
fabButton
.
addTarget
(
self
,
action
:
#selector(
handleFabButton
)
,
forControlEvents
:
.
TouchUpInside
)
view
.
addSubview
(
fabButton
)
view
.
layout
.
size
(
fabButton
,
width
:
64
,
height
:
64
)
Layout
.
alignFromBottomRight
(
view
,
child
:
fabButton
,
bottom
:
16
,
right
:
16
)
view
.
layout
.
alignFromBottomRight
(
fabButton
,
bottom
:
16
,
right
:
16
)
Layout
.
size
(
view
,
child
:
fabButton
,
width
:
64
,
height
:
64
)
}
}
// FabButton handler.
// FabButton handler.
...
...
Sources/iOS/BottomTabBar.swift
View file @
6afa56be
...
@@ -233,8 +233,8 @@ public class BottomTabBar : UITabBar {
...
@@ -233,8 +233,8 @@ public class BottomTabBar : UITabBar {
super
.
didMoveToSuperview
()
super
.
didMoveToSuperview
()
if
autoLayoutToSuperview
{
if
autoLayoutToSuperview
{
if
let
v
:
UIView
=
superview
{
if
let
v
:
UIView
=
superview
{
Layout
.
alignFromBottom
(
v
,
child
:
self
)
v
.
layout
.
alignFromBottom
(
self
)
Layout
.
alignToParentHorizontally
(
v
,
child
:
self
)
v
.
layout
.
horizontally
(
self
)
}
}
}
}
}
}
...
...
Sources/iOS/CardView.swift
View file @
6afa56be
...
@@ -274,18 +274,14 @@ public class CardView : MaterialPulseView {
...
@@ -274,18 +274,14 @@ public class CardView : MaterialPulseView {
// title
// title
if
let
v
:
UILabel
=
titleLabel
{
if
let
v
:
UILabel
=
titleLabel
{
addSubview
(
v
)
verticalFormat
+=
"-[titleLabel]"
verticalFormat
+=
"-[titleLabel]"
views
[
"titleLabel"
]
=
v
views
[
"titleLabel"
]
=
v
Layout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
titleLabelInset
.
left
,
right
:
contentInset
.
right
+
titleLabelInset
.
right
)
layout
.
horizontally
(
v
,
left
:
contentInset
.
left
+
titleLabelInset
.
left
,
right
:
contentInset
.
right
+
titleLabelInset
.
right
)
}
}
// detail
// detail
if
let
v
:
UIView
=
contentView
{
if
let
v
:
UIView
=
contentView
{
addSubview
(
v
)
if
nil
==
titleLabel
{
if
nil
==
titleLabel
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
contentViewInset
.
top
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
contentViewInset
.
top
}
else
{
}
else
{
...
@@ -296,7 +292,7 @@ public class CardView : MaterialPulseView {
...
@@ -296,7 +292,7 @@ public class CardView : MaterialPulseView {
verticalFormat
+=
"-[contentView]"
verticalFormat
+=
"-[contentView]"
views
[
"contentView"
]
=
v
views
[
"contentView"
]
=
v
Layout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
contentViewInset
.
right
)
layout
.
horizontally
(
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
contentViewInset
.
right
)
}
}
// leftButtons
// leftButtons
...
@@ -318,8 +314,7 @@ public class CardView : MaterialPulseView {
...
@@ -318,8 +314,7 @@ public class CardView : MaterialPulseView {
h
+=
"[
\(
k
)
]"
h
+=
"[
\(
k
)
]"
addSubview
(
b
)
layout
.
alignFromBottom
(
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
Layout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
i
+=
1
}
}
...
@@ -348,8 +343,7 @@ public class CardView : MaterialPulseView {
...
@@ -348,8 +343,7 @@ public class CardView : MaterialPulseView {
h
+=
"-(right_left)-"
h
+=
"-(right_left)-"
}
}
addSubview
(
b
)
layout
.
alignFromBottom
(
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
Layout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
i
-=
1
}
}
...
...
Sources/iOS/ImageCardView.swift
View file @
6afa56be
...
@@ -374,21 +374,17 @@ public class ImageCardView : MaterialPulseView {
...
@@ -374,21 +374,17 @@ public class ImageCardView : MaterialPulseView {
// title
// title
if
let
v
:
UILabel
=
titleLabel
{
if
let
v
:
UILabel
=
titleLabel
{
addSubview
(
v
)
if
nil
==
imageLayer
?
.
contents
{
if
nil
==
imageLayer
?
.
contents
{
verticalFormat
+=
"-[titleLabel]"
verticalFormat
+=
"-[titleLabel]"
views
[
"titleLabel"
]
=
v
views
[
"titleLabel"
]
=
v
}
else
{
}
else
{
Layout
.
alignFromTop
(
self
,
child
:
v
,
top
:
contentInset
.
top
+
titleLabelInset
.
top
)
layout
.
alignFromTop
(
v
,
top
:
contentInset
.
top
+
titleLabelInset
.
top
)
}
}
Layout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
titleLabelInset
.
left
,
right
:
contentInset
.
right
+
titleLabelInset
.
right
)
layout
.
horizontally
(
v
,
left
:
contentInset
.
left
+
titleLabelInset
.
left
,
right
:
contentInset
.
right
+
titleLabelInset
.
right
)
}
}
// detail
// detail
if
let
v
:
UIView
=
contentView
{
if
let
v
:
UIView
=
contentView
{
addSubview
(
v
)
if
nil
==
imageLayer
?
.
contents
&&
nil
!=
titleLabel
{
if
nil
==
imageLayer
?
.
contents
&&
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetB)"
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
contentViewInset
.
top
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
contentViewInset
.
top
...
@@ -399,7 +395,7 @@ public class ImageCardView : MaterialPulseView {
...
@@ -399,7 +395,7 @@ public class ImageCardView : MaterialPulseView {
verticalFormat
+=
"-[contentView]"
verticalFormat
+=
"-[contentView]"
views
[
"contentView"
]
=
v
views
[
"contentView"
]
=
v
Layout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
contentViewInset
.
right
)
layout
.
horizontally
(
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
contentViewInset
.
right
)
}
}
// leftButtons
// leftButtons
...
@@ -421,8 +417,7 @@ public class ImageCardView : MaterialPulseView {
...
@@ -421,8 +417,7 @@ public class ImageCardView : MaterialPulseView {
h
+=
"[
\(
k
)
]"
h
+=
"[
\(
k
)
]"
addSubview
(
b
)
layout
.
alignFromBottom
(
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
Layout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
i
+=
1
}
}
...
@@ -451,8 +446,7 @@ public class ImageCardView : MaterialPulseView {
...
@@ -451,8 +446,7 @@ public class ImageCardView : MaterialPulseView {
h
+=
"-(right_left)-"
h
+=
"-(right_left)-"
}
}
addSubview
(
b
)
layout
.
alignFromBottom
(
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
Layout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
i
-=
1
}
}
...
...
Sources/iOS/TextView.swift
View file @
6afa56be
...
@@ -409,8 +409,7 @@ public class TextView: UITextView {
...
@@ -409,8 +409,7 @@ public class TextView: UITextView {
internal
func
reloadView
()
{
internal
func
reloadView
()
{
if
let
p
=
placeholderLabel
{
if
let
p
=
placeholderLabel
{
removeConstraints
(
constraints
)
removeConstraints
(
constraints
)
Layout
.
alignToParent
(
self
,
layout
.
align
(
p
,
child
:
p
,
top
:
textContainerInset
.
top
,
top
:
textContainerInset
.
top
,
left
:
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
,
left
:
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
,
bottom
:
textContainerInset
.
bottom
,
bottom
:
textContainerInset
.
bottom
,
...
...
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