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
602f184d
Commit
602f184d
authored
May 26, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated grid to include a layout inset
parent
d84c2cd1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
25 deletions
+33
-25
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
+1
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+0
-0
Sources/iOS/BarController.swift
+9
-0
Sources/iOS/BarView.swift
+0
-10
Sources/iOS/ControlView.swift
+1
-1
Sources/iOS/Grid.swift
+20
-6
Sources/iOS/ToolbarController.swift
+2
-6
No files found.
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
View file @
602f184d
...
@@ -77,7 +77,7 @@ class ViewController: UIViewController {
...
@@ -77,7 +77,7 @@ class ViewController: UIViewController {
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
}
}
/// Prepares the
table
View.
/// Prepares the
collection
View.
private
func
prepareCollectionView
()
{
private
func
prepareCollectionView
()
{
collectionView
=
MaterialCollectionView
(
frame
:
view
.
bounds
)
collectionView
=
MaterialCollectionView
(
frame
:
view
.
bounds
)
collectionView
.
registerClass
(
MaterialCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"MaterialCollectionViewCell"
)
collectionView
.
registerClass
(
MaterialCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"MaterialCollectionViewCell"
)
...
@@ -85,7 +85,6 @@ class ViewController: UIViewController {
...
@@ -85,7 +85,6 @@ class ViewController: UIViewController {
collectionView
.
contentInset
.
top
=
100
collectionView
.
contentInset
.
top
=
100
collectionView
.
spacing
=
16
collectionView
.
spacing
=
16
// Use MaterialLayout to easily align the tableView.
view
.
addSubview
(
collectionView
)
view
.
addSubview
(
collectionView
)
MaterialLayout
.
alignToParent
(
view
,
child
:
collectionView
)
MaterialLayout
.
alignToParent
(
view
,
child
:
collectionView
)
}
}
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
602f184d
Sources/iOS/BarController.swift
View file @
602f184d
...
@@ -32,6 +32,15 @@ import UIKit
...
@@ -32,6 +32,15 @@ import UIKit
@IBDesignable
@IBDesignable
public
class
BarController
:
UIViewController
{
public
class
BarController
:
UIViewController
{
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
return
MaterialDevice
.
statusBarStyle
}
set
(
value
)
{
MaterialDevice
.
statusBarStyle
=
value
}
}
/**
/**
A Boolean property used to enable and disable interactivity
A Boolean property used to enable and disable interactivity
...
...
Sources/iOS/BarView.swift
View file @
602f184d
...
@@ -31,16 +31,6 @@
...
@@ -31,16 +31,6 @@
import
UIKit
import
UIKit
public
class
BarView
:
ControlView
{
public
class
BarView
:
ControlView
{
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
return
MaterialDevice
.
statusBarStyle
}
set
(
value
)
{
MaterialDevice
.
statusBarStyle
=
value
}
}
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
...
...
Sources/iOS/ControlView.swift
View file @
602f184d
...
@@ -217,7 +217,7 @@ public class ControlView : MaterialView {
...
@@ -217,7 +217,7 @@ public class ControlView : MaterialView {
}
}
public
override
func
intrinsicContentSize
()
->
CGSize
{
public
override
func
intrinsicContentSize
()
->
CGSize
{
return
CGSizeMake
(
width
,
36
+
contentInset
.
top
+
contentInset
.
bottom
)
return
CGSizeMake
(
width
,
44
)
}
}
/**
/**
...
...
Sources/iOS/Grid.swift
View file @
602f184d
...
@@ -126,6 +126,20 @@ public class Grid {
...
@@ -126,6 +126,20 @@ public class Grid {
public
private(set)
var
axis
:
GridAxis
!
public
private(set)
var
axis
:
GridAxis
!
/// Preset inset value for grid.
/// Preset inset value for grid.
public
var
layoutInsetPreset
:
MaterialEdgeInset
=
.
None
{
didSet
{
layoutInset
=
MaterialEdgeInsetToValue
(
contentInsetPreset
)
}
}
/// Insets value for grid.
public
var
layoutInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
None
)
{
didSet
{
reloadLayout
()
}
}
/// Preset inset value for grid.
public
var
contentInsetPreset
:
MaterialEdgeInset
=
.
None
{
public
var
contentInsetPreset
:
MaterialEdgeInset
=
.
None
{
didSet
{
didSet
{
contentInset
=
MaterialEdgeInsetToValue
(
contentInsetPreset
)
contentInset
=
MaterialEdgeInsetToValue
(
contentInsetPreset
)
...
@@ -186,28 +200,28 @@ public class Grid {
...
@@ -186,28 +200,28 @@ public class Grid {
sv
.
layoutIfNeeded
()
sv
.
layoutIfNeeded
()
switch
axis
.
direction
{
switch
axis
.
direction
{
case
.
Horizontal
:
case
.
Horizontal
:
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
+
spacing
)
/
CGFloat
(
gc
)
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
spacing
)
/
CGFloat
(
gc
)
let
c
:
Int
=
view
.
grid
.
columns
let
c
:
Int
=
view
.
grid
.
columns
let
co
:
Int
=
view
.
grid
.
offset
.
columns
let
co
:
Int
=
view
.
grid
.
offset
.
columns
let
vh
:
CGFloat
=
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
vh
:
CGFloat
=
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
let
vl
:
CGFloat
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentInset
.
left
let
vl
:
CGFloat
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentInset
.
left
let
vw
:
CGFloat
=
w
*
CGFloat
(
c
)
-
spacing
let
vw
:
CGFloat
=
w
*
CGFloat
(
c
)
-
spacing
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
n
+=
c
+
co
-
1
n
+=
c
+
co
-
1
case
.
Vertical
:
case
.
Vertical
:
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
+
spacing
)
/
CGFloat
(
gr
)
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
spacing
)
/
CGFloat
(
gr
)
let
r
:
Int
=
view
.
grid
.
rows
let
r
:
Int
=
view
.
grid
.
rows
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
let
vw
:
CGFloat
=
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
let
vw
:
CGFloat
=
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
let
vt
:
CGFloat
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInset
.
top
let
vt
:
CGFloat
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInset
.
top
let
vh
:
CGFloat
=
h
*
CGFloat
(
r
)
-
spacing
let
vh
:
CGFloat
=
h
*
CGFloat
(
r
)
-
spacing
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
n
+=
r
+
ro
-
1
n
+=
r
+
ro
-
1
case
.
None
:
case
.
None
:
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
+
spacing
)
/
CGFloat
(
gc
)
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
spacing
)
/
CGFloat
(
gc
)
let
c
:
Int
=
view
.
grid
.
columns
let
c
:
Int
=
view
.
grid
.
columns
let
co
:
Int
=
view
.
grid
.
offset
.
columns
let
co
:
Int
=
view
.
grid
.
offset
.
columns
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
+
spacing
)
/
CGFloat
(
gr
)
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
spacing
)
/
CGFloat
(
gr
)
let
r
:
Int
=
view
.
grid
.
rows
let
r
:
Int
=
view
.
grid
.
rows
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
let
vt
:
CGFloat
=
CGFloat
(
ro
)
*
h
+
contentInset
.
top
let
vt
:
CGFloat
=
CGFloat
(
ro
)
*
h
+
contentInset
.
top
...
...
Sources/iOS/ToolbarController.swift
View file @
602f184d
...
@@ -159,15 +159,11 @@ public class ToolbarController : BarController {
...
@@ -159,15 +159,11 @@ public class ToolbarController : BarController {
/// Layout subviews.
/// Layout subviews.
public
func
layoutSubviews
()
{
public
func
layoutSubviews
()
{
if
let
v
:
Toolbar
=
toolbar
{
if
let
v
:
Toolbar
=
toolbar
{
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
isLandscape
{
v
.
grid
.
layoutInset
.
top
=
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
isLandscape
?
0
:
20
v
.
contentInset
.
top
=
4
}
else
{
v
.
contentInset
.
top
=
24
}
let
h
:
CGFloat
=
MaterialDevice
.
height
let
h
:
CGFloat
=
MaterialDevice
.
height
let
w
:
CGFloat
=
MaterialDevice
.
width
let
w
:
CGFloat
=
MaterialDevice
.
width
let
p
:
CGFloat
=
v
.
intrinsicContentSize
()
.
height
let
p
:
CGFloat
=
v
.
intrinsicContentSize
()
.
height
+
v
.
grid
.
layoutInset
.
top
v
.
width
=
w
v
.
width
=
w
v
.
height
=
p
v
.
height
=
p
...
...
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