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
52657f40
Unverified
Commit
52657f40
authored
Nov 08, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: issue-588: initial fix for GridAxis leak
parent
9c3c58e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
57 deletions
+41
-57
Sources/iOS/Grid.swift
+34
-52
Sources/iOS/Material+Obj-C.swift
+2
-2
Sources/iOS/NavigationItem.swift
+5
-3
No files found.
Sources/iOS/Grid.swift
View file @
52657f40
...
...
@@ -37,70 +37,40 @@ public enum GridAxisDirection: Int {
case
vertical
}
public
class
GridAxis
{
/// Grid reference.
unowned
var
grid
:
Grid
public
struct
GridAxis
{
/// The direction the grid lays its views out.
open
var
direction
:
GridAxisDirection
=
.
horizontal
{
didSet
{
grid
.
reload
()
}
}
var
direction
=
GridAxisDirection
.
horizontal
/// The rows size.
public
var
rows
:
Int
{
didSet
{
grid
.
reload
()
}
}
public
var
rows
:
Int
/// The columns size.
public
var
columns
:
Int
{
didSet
{
grid
.
reload
()
}
}
public
var
columns
:
Int
/**
Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, vertical axis the grid will use.
- Parameter columns: The number of columns, horizontal axis the grid will use.
*/
public
init
(
grid
:
Grid
,
rows
:
Int
=
12
,
columns
:
Int
=
12
)
{
self
.
grid
=
grid
public
init
(
rows
:
Int
=
12
,
columns
:
Int
=
12
)
{
self
.
rows
=
rows
self
.
columns
=
columns
}
}
public
class
GridOffset
{
/// Grid reference.
unowned
var
grid
:
Grid
public
struct
GridOffset
{
/// The rows size.
public
var
rows
:
Int
{
didSet
{
grid
.
reload
()
}
}
public
var
rows
:
Int
/// The columns size.
public
var
columns
:
Int
{
didSet
{
grid
.
reload
()
}
}
public
var
columns
:
Int
/**
Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, vertical axis the grid will use.
- Parameter columns: The number of columns, horizontal axis the grid will use.
*/
public
init
(
grid
:
Grid
,
rows
:
Int
=
0
,
columns
:
Int
=
0
)
{
self
.
grid
=
grid
public
init
(
rows
:
Int
=
0
,
columns
:
Int
=
0
)
{
self
.
rows
=
rows
self
.
columns
=
columns
}
...
...
@@ -128,10 +98,18 @@ public class Grid {
}
/// Offsets for rows and columns.
public
private(set)
var
offset
:
GridOffset
!
public
var
offset
:
GridOffset
{
didSet
{
reload
()
}
}
/// The axis in which the Grid is laying out its views.
public
private(set)
var
axis
:
GridAxis
!
public
var
axis
:
GridAxis
{
didSet
{
reload
()
}
}
/// Preset inset value for grid.
public
var
layoutEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
...
...
@@ -176,8 +154,11 @@ public class Grid {
}
/// An Array of UIButtons.
public
var
views
=
[
UIView
]()
{
public
var
views
:
[
UIView
]
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
}
reload
()
}
}
...
...
@@ -193,8 +174,9 @@ public class Grid {
self
.
rows
=
rows
self
.
columns
=
columns
self
.
interimSpace
=
interimSpace
offset
=
GridOffset
(
grid
:
self
)
axis
=
GridAxis
(
grid
:
self
)
offset
=
GridOffset
()
axis
=
GridAxis
()
views
=
[]
}
/// Begins a deferred block.
...
...
@@ -214,6 +196,14 @@ public class Grid {
return
}
guard
let
canvas
=
context
else
{
return
}
guard
0
<
canvas
.
width
&&
0
<
canvas
.
height
else
{
return
}
let
count
=
views
.
count
guard
0
<
count
else
{
...
...
@@ -224,14 +214,6 @@ public class Grid {
var
i
=
0
for
v
in
views
{
guard
let
canvas
=
context
else
{
return
}
guard
0
<
canvas
.
width
&&
0
<
canvas
.
height
else
{
return
}
if
canvas
!=
v
.
superview
{
v
.
removeFromSuperview
()
canvas
.
addSubview
(
v
)
...
...
Sources/iOS/Material+Obj-C.swift
View file @
52657f40
...
...
@@ -36,11 +36,11 @@
- Returns: The associated reference for the initializer object.
*/
internal
func
AssociatedObject
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
if
let
v
:
T
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
if
let
v
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
return
v
}
let
v
:
T
=
initializer
()
let
v
=
initializer
()
objc_setAssociatedObject
(
base
,
key
,
v
,
.
OBJC_ASSOCIATION_RETAIN
)
return
v
}
...
...
Sources/iOS/NavigationItem.swift
View file @
52657f40
...
...
@@ -55,7 +55,7 @@ public class NavigationItem: NSObject {
public
private(set)
lazy
var
detailLabel
=
UILabel
()
/// Left items.
public
var
leftViews
=
[
UIView
]()
{
public
var
leftViews
:
[
UIView
]
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
...
...
@@ -65,7 +65,7 @@ public class NavigationItem: NSObject {
}
/// Right items.
public
var
rightViews
=
[
UIView
]()
{
public
var
rightViews
:
[
UIView
]
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
...
...
@@ -105,7 +105,9 @@ public class NavigationItem: NSObject {
/// Initializer.
public
override
init
()
{
super
.
init
()
leftViews
=
[]
rightViews
=
[]
super
.
init
()
prepareTitleLabel
()
prepareDetailLabel
()
}
...
...
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