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