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
19fad6e1
Commit
19fad6e1
authored
Aug 05, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated to Grid and Layout
parent
ccc51561
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
19 deletions
+41
-19
Sources/iOS/Grid.swift
+23
-3
Sources/iOS/Layout.swift
+10
-13
Sources/iOS/Material+UIView.swift
+8
-3
No files found.
Sources/iOS/Grid.swift
View file @
19fad6e1
...
...
@@ -199,14 +199,18 @@ public class Grid {
let
gc
=
axis
.
inherited
?
columns
:
axis
.
columns
let
gr
=
axis
.
inherited
?
rows
:
axis
.
rows
var
n
:
Int
=
0
for
i
in
0
..<
v
.
count
{
let
child
:
UIView
=
v
[
i
]
if
let
parent
:
UIView
=
context
{
if
parent
!=
child
.
superview
{
child
.
removeFromSuperview
()
parent
.
addSubview
(
child
)
}
parent
.
layoutIfNeeded
()
switch
axis
.
direction
{
case
.
horizontal
:
let
w
=
(
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
...
...
@@ -215,8 +219,14 @@ public class Grid {
let
vh
=
parent
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
let
vl
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentInset
.
left
+
layoutInset
.
left
let
vw
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
vl
,
y
:
contentInset
.
top
+
layoutInset
.
top
,
width
:
vw
,
height
:
vh
)
child
.
x
=
vl
child
.
y
=
contentInset
.
top
+
layoutInset
.
top
child
.
width
=
vw
child
.
height
=
vh
n
+=
c
+
co
-
1
case
.
vertical
:
let
h
=
(
parent
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
r
=
child
.
grid
.
rows
...
...
@@ -224,8 +234,14 @@ public class Grid {
let
vw
=
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
let
vt
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInset
.
top
+
layoutInset
.
top
let
vh
=
h
*
CGFloat
(
r
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
contentInset
.
left
+
layoutInset
.
left
,
y
:
vt
,
width
:
vw
,
height
:
vh
)
child
.
x
=
contentInset
.
left
+
layoutInset
.
left
child
.
y
=
vt
child
.
width
=
vw
child
.
height
=
vh
n
+=
r
+
ro
-
1
case
.
none
:
let
w
=
(
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
c
=
child
.
grid
.
columns
...
...
@@ -237,7 +253,11 @@ public class Grid {
let
vl
=
CGFloat
(
co
)
*
w
+
contentInset
.
left
+
layoutInset
.
left
let
vh
=
h
*
CGFloat
(
r
)
-
interimSpace
let
vw
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
vl
,
y
:
vt
,
width
:
vw
,
height
:
vh
)
child
.
x
=
vl
child
.
y
=
vt
child
.
width
=
vw
child
.
height
=
vh
}
}
}
...
...
Sources/iOS/Layout.swift
View file @
19fad6e1
...
...
@@ -134,30 +134,28 @@ public class Layout {
/**
Sets the width and height of a view.
- Parameter child: A child UIView to layout.
- Parameter width: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter size: A CGSize value.
- Returns: The current Layout instance.
*/
public
func
size
(
_
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
)
->
Layout
{
public
func
size
(
_
child
:
UIView
,
size
:
CGSize
)
->
Layout
{
guard
let
v
=
parent
else
{
return
debugParentNotAvailableMessage
()
}
self
.
child
=
child
Layout
.
size
(
parent
:
v
,
child
:
child
,
width
:
width
,
height
:
height
)
Layout
.
size
(
parent
:
v
,
child
:
child
,
size
:
size
)
return
self
}
/**
Sets the width and height of a view assuming a child context view.
- Parameter width: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter size: A CGSize value.
- Returns: The current Layout instance.
*/
public
func
size
(
width
:
CGFloat
,
height
:
CGFloat
)
->
Layout
{
public
func
size
(
_
size
:
CGSize
=
CGSize
.
zero
)
->
Layout
{
guard
let
v
=
child
else
{
return
debugChildNotAvailableMessage
()
}
return
s
ize
(
v
,
width
:
width
,
height
:
height
)
return
s
elf
.
size
(
v
,
size
:
size
)
}
/**
...
...
@@ -622,12 +620,11 @@ public extension Layout {
Sets the width and height of a view.
- Parameter parent: A parent UIView context.
- Parameter child: A child UIView to layout.
- Parameter width: A CGFloat value.
- Parameter height: A CGFloat value.
- Parameter size: A CGSize value.
*/
public
class
func
size
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
=
0
,
height
:
CGFloat
=
0
)
{
Layout
.
width
(
parent
:
parent
,
child
:
child
,
width
:
width
)
Layout
.
height
(
parent
:
parent
,
child
:
child
,
height
:
height
)
public
class
func
size
(
parent
:
UIView
,
child
:
UIView
,
size
:
CGSize
=
CGSize
.
zero
)
{
Layout
.
width
(
parent
:
parent
,
child
:
child
,
width
:
size
.
width
)
Layout
.
height
(
parent
:
parent
,
child
:
child
,
height
:
size
.
height
)
}
/**
...
...
Sources/iOS/Material+UIView.swift
View file @
19fad6e1
...
...
@@ -401,9 +401,14 @@ public extension UIView {
/// Manages the layout for the shape of the view instance.
public
func
layoutShape
()
{
if
.
circle
==
shapePreset
{
let
w
:
CGFloat
=
(
width
/
2
)
if
w
!=
cornerRadius
{
cornerRadius
=
w
if
width
<
height
{
width
=
height
}
else
{
height
=
width
}
let
r
=
width
/
2
if
r
!=
cornerRadius
{
cornerRadius
=
r
}
}
}
...
...
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