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
d2aa614b
Commit
d2aa614b
authored
Aug 15, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: Updated grid layout and content EdgeInsets
parent
d200c0b3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
36 deletions
+35
-36
Sources/iOS/CollectionReusableView.swift
+2
-2
Sources/iOS/CollectionViewCell.swift
+2
-2
Sources/iOS/ControlView.swift
+3
-3
Sources/iOS/Grid.swift
+21
-22
Sources/iOS/NavigationBar.swift
+1
-1
Sources/iOS/SearchBarController.swift
+3
-3
Sources/iOS/ToolbarController.swift
+3
-3
No files found.
Sources/iOS/CollectionReusableView.swift
View file @
d2aa614b
...
...
@@ -141,10 +141,10 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
UIEdgeInsets
{
get
{
return
grid
.
content
Inset
return
grid
.
content
EdgeInsets
}
set
(
value
)
{
grid
.
content
Inset
=
value
grid
.
content
EdgeInsets
=
value
}
}
...
...
Sources/iOS/CollectionViewCell.swift
View file @
d2aa614b
...
...
@@ -141,10 +141,10 @@ public class CollectionViewCell: UICollectionViewCell {
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
UIEdgeInsets
{
get
{
return
contentView
.
grid
.
content
Inset
return
contentView
.
grid
.
content
EdgeInsets
}
set
(
value
)
{
contentView
.
grid
.
content
Inset
=
value
contentView
.
grid
.
content
EdgeInsets
=
value
}
}
...
...
Sources/iOS/ControlView.swift
View file @
d2aa614b
...
...
@@ -49,10 +49,10 @@ public class ControlView: View {
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
EdgeInsets
{
get
{
return
grid
.
content
Inset
return
grid
.
content
EdgeInsets
}
set
(
value
)
{
grid
.
content
Inset
=
value
grid
.
content
EdgeInsets
=
value
}
}
...
...
@@ -209,7 +209,7 @@ public class ControlView: View {
}
}
grid
.
content
Inset
=
contentInset
grid
.
content
EdgeInsets
=
contentInset
grid
.
interimSpace
=
interimSpace
grid
.
reload
()
contentView
.
grid
.
reload
()
...
...
Sources/iOS/Grid.swift
View file @
d2aa614b
...
...
@@ -41,11 +41,12 @@ public class GridAxis {
/// Grid reference.
unowned
var
grid
:
Grid
/// Inherit grid rows and columns.
public
var
isInherited
:
Bool
=
false
/// The direction the grid lays its views out.
public
var
direction
:
GridAxisDirection
=
.
horizontal
public
var
direction
:
GridAxisDirection
=
.
horizontal
{
didSet
{
grid
.
reload
()
}
}
/// The rows size.
public
var
rows
:
Int
{
...
...
@@ -132,12 +133,12 @@ public class Grid {
/// Preset inset value for grid.
public
var
layoutEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
didSet
{
layout
Inset
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
layout
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
}
}
/// Insets value for grid.
public
var
layout
Inset
=
EdgeInsets
.
zero
{
public
var
layout
EdgeInsets
=
EdgeInsets
.
zero
{
didSet
{
reload
()
}
...
...
@@ -146,12 +147,12 @@ public class Grid {
/// Preset inset value for grid.
public
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
didSet
{
content
Inset
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
content
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
}
}
/// Insets value for grid.
public
var
content
Inset
:
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
.
none
)
{
public
var
content
EdgeInsets
=
EdgeInsets
.
zero
{
didSet
{
reload
()
}
...
...
@@ -196,8 +197,6 @@ public class Grid {
/// Reload the button layout.
public
func
reload
()
{
let
gc
=
axis
.
isInherited
?
columns
:
axis
.
columns
let
gr
=
axis
.
isInherited
?
rows
:
axis
.
rows
var
n
:
Int
=
0
for
i
in
0
..<
views
.
count
{
...
...
@@ -215,23 +214,23 @@ public class Grid {
case
.
horizontal
:
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
parent
.
bounds
.
width
-
content
Inset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
w
=
(
parent
.
bounds
.
width
-
content
EdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
child
.
x
=
CGFloat
(
i
+
n
+
co
)
*
w
+
content
Inset
.
left
+
layoutInset
.
left
child
.
y
=
content
Inset
.
top
+
layoutInset
.
top
child
.
x
=
CGFloat
(
i
+
n
+
co
)
*
w
+
content
EdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
content
EdgeInsets
.
top
+
layoutEdgeInsets
.
top
child
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
height
=
parent
.
bounds
.
height
-
content
Inset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
child
.
height
=
parent
.
bounds
.
height
-
content
EdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
n
+=
c
+
co
-
1
case
.
vertical
:
let
r
=
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
h
=
(
parent
.
bounds
.
height
-
content
Inset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
h
=
(
parent
.
bounds
.
height
-
content
EdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
child
.
x
=
content
Inset
.
left
+
layoutInset
.
left
child
.
y
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
content
Inset
.
top
+
layoutInset
.
top
child
.
width
=
parent
.
bounds
.
width
-
content
Inset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
child
.
x
=
content
EdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
content
EdgeInsets
.
top
+
layoutEdgeInsets
.
top
child
.
width
=
parent
.
bounds
.
width
-
content
EdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
child
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
n
+=
r
+
ro
-
1
...
...
@@ -241,11 +240,11 @@ public class Grid {
let
ro
=
child
.
grid
.
offset
.
rows
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
parent
.
bounds
.
width
-
content
Inset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
h
=
(
parent
.
bounds
.
height
-
content
Inset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
w
=
(
parent
.
bounds
.
width
-
content
EdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
parent
.
bounds
.
height
-
content
EdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
child
.
x
=
CGFloat
(
co
)
*
w
+
content
Inset
.
left
+
layoutInset
.
left
child
.
y
=
CGFloat
(
ro
)
*
h
+
content
Inset
.
top
+
layoutInset
.
top
child
.
x
=
CGFloat
(
co
)
*
w
+
content
EdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
CGFloat
(
ro
)
*
h
+
content
EdgeInsets
.
top
+
layoutEdgeInsets
.
top
child
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
}
...
...
Sources/iOS/NavigationBar.swift
View file @
d2aa614b
...
...
@@ -243,7 +243,7 @@ public class NavigationBar: UINavigationBar {
}
}
titleView
.
grid
.
content
Inset
=
contentInset
titleView
.
grid
.
content
EdgeInsets
=
contentInset
titleView
.
grid
.
interimSpace
=
interimSpace
titleView
.
grid
.
reload
()
...
...
Sources/iOS/SearchBarController.swift
View file @
d2aa614b
...
...
@@ -60,13 +60,13 @@ public class SearchBarController: RootController {
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
let
v
:
SearchBar
=
searchBar
{
v
.
grid
.
layout
Inset
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
v
.
grid
.
layout
EdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
h
:
CGFloat
=
Device
.
height
let
w
:
CGFloat
=
Device
.
width
let
p
:
CGFloat
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layout
Inset
.
top
+
v
.
grid
.
layoutInset
.
bottom
let
p
:
CGFloat
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layout
EdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layout
Inset
.
left
+
v
.
grid
.
layoutInset
.
right
v
.
width
=
w
+
v
.
grid
.
layout
EdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
v
.
height
=
p
rootViewController
.
view
.
frame
.
origin
.
y
=
p
...
...
Sources/iOS/ToolbarController.swift
View file @
d2aa614b
...
...
@@ -163,13 +163,13 @@ public class ToolbarController: RootController {
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
let
v
:
Toolbar
=
toolbar
{
v
.
grid
.
layout
Inset
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
v
.
grid
.
layout
EdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
h
:
CGFloat
=
Device
.
height
let
w
:
CGFloat
=
Device
.
width
let
p
:
CGFloat
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layout
Inset
.
top
+
v
.
grid
.
layoutInset
.
bottom
let
p
:
CGFloat
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layout
EdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layout
Inset
.
left
+
v
.
grid
.
layoutInset
.
right
v
.
width
=
w
+
v
.
grid
.
layout
EdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
v
.
height
=
p
rootViewController
.
view
.
frame
.
origin
.
y
=
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