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
6ab2352e
Unverified
Commit
6ab2352e
authored
Jun 13, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated AssociatedObject API to a struct from global functions
parent
fe8a6c41
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
35 deletions
+41
-35
Sources/iOS/Divider.swift
+2
-2
Sources/iOS/Grid.swift
+2
-2
Sources/iOS/Layout.swift
+2
-2
Sources/iOS/Material+CALayer.swift
+2
-2
Sources/iOS/Material+Obj-C.swift
+25
-23
Sources/iOS/NavigationItem.swift
+2
-2
Sources/iOS/TabsController.swift
+6
-2
No files found.
Sources/iOS/Divider.swift
View file @
6ab2352e
...
@@ -141,12 +141,12 @@ extension UIView {
...
@@ -141,12 +141,12 @@ extension UIView {
/// TabBarItem reference.
/// TabBarItem reference.
public
private(set)
var
divider
:
Divider
{
public
private(set)
var
divider
:
Divider
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
DividerKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
DividerKey
)
{
return
Divider
(
view
:
self
)
return
Divider
(
view
:
self
)
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
DividerKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
DividerKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/Grid.swift
View file @
6ab2352e
...
@@ -272,12 +272,12 @@ extension UIView {
...
@@ -272,12 +272,12 @@ extension UIView {
/// Grid reference.
/// Grid reference.
public
var
grid
:
Grid
{
public
var
grid
:
Grid
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
GridKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
GridKey
)
{
return
Grid
(
context
:
self
)
return
Grid
(
context
:
self
)
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
GridKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
GridKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/Layout.swift
View file @
6ab2352e
...
@@ -968,12 +968,12 @@ extension UIView {
...
@@ -968,12 +968,12 @@ extension UIView {
/// Layout reference.
/// Layout reference.
public
private(set)
var
layout
:
Layout
{
public
private(set)
var
layout
:
Layout
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
LayoutKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
LayoutKey
)
{
return
Layout
(
parent
:
self
)
return
Layout
(
parent
:
self
)
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
LayoutKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
LayoutKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/Material+CALayer.swift
View file @
6ab2352e
...
@@ -100,12 +100,12 @@ extension CALayer {
...
@@ -100,12 +100,12 @@ extension CALayer {
/// MaterialLayer Reference.
/// MaterialLayer Reference.
fileprivate
var
materialLayer
:
MaterialLayer
{
fileprivate
var
materialLayer
:
MaterialLayer
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
MaterialLayer
(
layer
:
self
)
return
MaterialLayer
(
layer
:
self
)
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
MaterialLayerKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
MaterialLayerKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/Material+Obj-C.swift
View file @
6ab2352e
...
@@ -28,30 +28,32 @@
...
@@ -28,30 +28,32 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
/**
internal
struct
AssociatedObject
{
Gets the Obj-C reference for the instance object within the UIView extension.
/**
- Parameter base: Base object.
Gets the Obj-C reference for the instance object within the UIView extension.
- Parameter key: Memory key pointer.
- Parameter base: Base object.
- Parameter initializer: Object initializer.
- Parameter key: Memory key pointer.
- Returns: The associated reference for the initializer object.
- Parameter initializer: Object initializer.
*/
- Returns: The associated reference for the initializer object.
internal
func
AssociatedObject
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
*/
if
let
v
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
public
static
func
get
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
if
let
v
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
return
v
}
let
v
=
initializer
()
objc_setAssociatedObject
(
base
,
key
,
v
,
.
OBJC_ASSOCIATION_RETAIN
)
return
v
return
v
}
}
let
v
=
initializer
()
/**
objc_setAssociatedObject
(
base
,
key
,
v
,
.
OBJC_ASSOCIATION_RETAIN
)
Sets the Obj-C reference for the instance object within the UIView extension.
return
v
- Parameter base: Base object.
}
- Parameter key: Memory key pointer.
- Parameter value: The object instance to set for the associated object.
/**
- Returns: The associated reference for the initializer object.
Sets the Obj-C reference for the instance object within the UIView extension.
*/
- Parameter base: Base object.
public
static
func
set
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
- Parameter key: Memory key pointer.
objc_setAssociatedObject
(
base
,
key
,
value
,
.
OBJC_ASSOCIATION_RETAIN
)
- Parameter value: The object instance to set for the associated object.
}
- Returns: The associated reference for the initializer object.
*/
internal
func
AssociateObject
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
objc_setAssociatedObject
(
base
,
key
,
value
,
.
OBJC_ASSOCIATION_RETAIN
)
}
}
Sources/iOS/NavigationItem.swift
View file @
6ab2352e
...
@@ -134,12 +134,12 @@ extension UINavigationItem {
...
@@ -134,12 +134,12 @@ extension UINavigationItem {
/// NavigationItem reference.
/// NavigationItem reference.
public
internal(set)
var
navigationItem
:
NavigationItem
{
public
internal(set)
var
navigationItem
:
NavigationItem
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
NavigationItem
()
return
NavigationItem
()
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
NavigationItemKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
NavigationItemKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/TabsController.swift
View file @
6ab2352e
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
*/
*/
import
UIKit
import
UIKit
import
Motion
/// A memory reference to the TabsBarItem instance for UIViewController extensions.
/// A memory reference to the TabsBarItem instance for UIViewController extensions.
fileprivate
var
TabsBarItemKey
:
UInt8
=
0
fileprivate
var
TabsBarItemKey
:
UInt8
=
0
...
@@ -51,12 +52,12 @@ extension UIViewController {
...
@@ -51,12 +52,12 @@ extension UIViewController {
/// pageMenuBarItem reference.
/// pageMenuBarItem reference.
public
private(set)
var
pageMenuBarItem
:
TabsBarItem
{
public
private(set)
var
pageMenuBarItem
:
TabsBarItem
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
TabsBarItemKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
TabsBarItemKey
)
{
return
TabsBarItem
()
return
TabsBarItem
()
}
}
}
}
set
(
value
)
{
set
(
value
)
{
Associate
Objec
t
(
base
:
self
,
key
:
&
TabsBarItemKey
,
value
:
value
)
Associate
dObject
.
se
t
(
base
:
self
,
key
:
&
TabsBarItemKey
,
value
:
value
)
}
}
}
}
}
}
...
@@ -248,6 +249,7 @@ extension TabsController {
...
@@ -248,6 +249,7 @@ extension TabsController {
for
v
in
viewControllers
{
for
v
in
viewControllers
{
let
button
=
v
.
pageMenuBarItem
as
UIButton
let
button
=
v
.
pageMenuBarItem
as
UIButton
v
.
isMotionEnabled
=
true
buttons
.
append
(
button
)
buttons
.
append
(
button
)
}
}
...
@@ -472,6 +474,8 @@ extension TabsController {
...
@@ -472,6 +474,8 @@ extension TabsController {
// prepareViewControllersForTransition(from: selectedIndex, to: i)
// prepareViewControllersForTransition(from: selectedIndex, to: i)
selectedIndex
=
i
selectedIndex
=
i
v
.
select
(
at
:
i
)
v
.
select
(
at
:
i
)
...
...
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