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
838fadf0
Unverified
Commit
838fadf0
authored
Sep 03, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: reducing code complexity with BarViews round 2
parent
3ff98d5a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
19 deletions
+13
-19
Sources/iOS/ControlView.swift
+0
-1
Sources/iOS/Grid.swift
+8
-6
Sources/iOS/RootController.swift
+4
-3
Sources/iOS/Snackbar.swift
+1
-9
No files found.
Sources/iOS/ControlView.swift
View file @
838fadf0
...
...
@@ -224,7 +224,6 @@ open class ControlView: View {
super
.
prepareView
()
interimSpacePreset
=
.
interimSpace3
contentEdgeInsetsPreset
=
.
square1
autoresizingMask
=
.
flexibleWidth
prepareContentView
()
}
...
...
Sources/iOS/Grid.swift
View file @
838fadf0
...
...
@@ -227,27 +227,29 @@ public class Grid {
canvas
.
addSubview
(
child
)
}
canvas
.
layoutIfNeeded
()
switch
axis
.
direction
{
case
.
horizontal
:
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
child
.
x
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
child
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
height
=
canvas
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
child
.
height
=
canvas
.
bounds
.
height
-
contentEdgeInsets
.
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
=
(
canvas
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
child
.
x
=
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
child
.
width
=
canvas
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
child
.
width
=
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
child
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
n
+=
r
+
ro
-
1
...
...
@@ -257,8 +259,8 @@ public class Grid {
let
ro
=
child
.
grid
.
offset
.
rows
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
canvas
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
child
.
x
=
CGFloat
(
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
child
.
y
=
CGFloat
(
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
...
...
Sources/iOS/RootController.swift
View file @
838fadf0
...
...
@@ -117,7 +117,7 @@ open class RootController: UIViewController {
open
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
rootViewController
.
willMove
(
toParentViewController
:
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
toViewController
.
view
.
frame
=
rootViewController
.
view
.
bounds
transition
(
from
:
rootViewController
,
to
:
toViewController
,
duration
:
duration
,
...
...
@@ -138,7 +138,7 @@ open class RootController: UIViewController {
/**
To execute in the order of the layout chain, override this
method.
LayoutSubviews
should be called immediately, unless you
method.
`layoutSubviews`
should be called immediately, unless you
have a certain need.
*/
open
func
layoutSubviews
()
{}
...
...
@@ -176,7 +176,8 @@ open class RootController: UIViewController {
addChildViewController
(
v
)
container
.
addSubview
(
v
.
view
)
v
.
didMove
(
toParentViewController
:
self
)
v
.
view
.
clipsToBounds
=
true
v
.
view
.
frame
=
container
.
bounds
v
.
view
.
clipsToBounds
=
true
v
.
view
.
autoresizingMask
=
[
.
flexibleWidth
,
.
flexibleHeight
]
v
.
view
.
contentScaleFactor
=
Device
.
scale
}
...
...
Sources/iOS/Snackbar.swift
View file @
838fadf0
...
...
@@ -77,14 +77,6 @@ open class Snackbar: BarView {
return
super
.
hitTest
(
point
,
with
:
event
)
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
print
(
"RENDING"
,
contentView
)
textLabel
.
frame
=
contentView
.
bounds
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
...
...
@@ -112,6 +104,6 @@ open class Snackbar: BarView {
textLabel
.
numberOfLines
=
0
contentView
.
backgroundColor
=
Color
.
green
.
base
contentView
.
addSubview
(
textLabel
)
contentView
.
grid
.
views
.
append
(
textLabel
)
}
}
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