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
a6308b53
Commit
a6308b53
authored
Aug 18, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated NavigationItem internals
parent
33b548eb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
72 deletions
+49
-72
Sources/iOS/ControlView.swift
+1
-1
Sources/iOS/Grid.swift
+1
-0
Sources/iOS/Material+CALayer.swift
+11
-11
Sources/iOS/Material+UIView.swift
+2
-24
Sources/iOS/NavigationBar.swift
+7
-9
Sources/iOS/NavigationItem.swift
+26
-26
Sources/iOS/RootController.swift
+1
-1
No files found.
Sources/iOS/ControlView.swift
View file @
a6308b53
...
@@ -167,7 +167,7 @@ open class ControlView: View {
...
@@ -167,7 +167,7 @@ open class ControlView: View {
let
g
=
Int
(
width
/
gridFactor
)
let
g
=
Int
(
width
/
gridFactor
)
let
columns
=
g
+
1
let
columns
=
g
+
1
grid
.
views
=
[]
grid
.
views
.
removeAll
()
grid
.
axis
.
columns
=
columns
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
...
...
Sources/iOS/Grid.swift
View file @
a6308b53
...
@@ -200,6 +200,7 @@ public class Grid {
...
@@ -200,6 +200,7 @@ public class Grid {
var
n
:
Int
=
0
var
n
:
Int
=
0
for
i
in
0
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
print
(
i
,
views
.
count
,
views
)
let
child
=
views
[
i
]
let
child
=
views
[
i
]
if
let
parent
=
context
{
if
let
parent
=
context
{
...
...
Sources/iOS/Material+CALayer.swift
View file @
a6308b53
...
@@ -105,7 +105,7 @@ private var MaterialLayerKey: UInt8 = 0
...
@@ -105,7 +105,7 @@ private var MaterialLayerKey: UInt8 = 0
/// Grid extension for UIView.
/// Grid extension for UIView.
extension
CALayer
{
extension
CALayer
{
/// MaterialLayer Reference.
/// MaterialLayer Reference.
internal
var
material
:
MaterialLayer
{
internal
var
material
Layer
:
MaterialLayer
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
MaterialLayer
(
layer
:
self
)
return
MaterialLayer
(
layer
:
self
)
...
@@ -185,10 +185,10 @@ extension CALayer {
...
@@ -185,10 +185,10 @@ extension CALayer {
*/
*/
open
var
shapePreset
:
ShapePreset
{
open
var
shapePreset
:
ShapePreset
{
get
{
get
{
return
material
.
shapePreset
return
material
Layer
.
shapePreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
shapePreset
=
value
material
Layer
.
shapePreset
=
value
}
}
}
}
...
@@ -205,10 +205,10 @@ extension CALayer {
...
@@ -205,10 +205,10 @@ extension CALayer {
/// Grid reference.
/// Grid reference.
open
var
depth
:
Depth
{
open
var
depth
:
Depth
{
get
{
get
{
return
material
.
depth
return
material
Layer
.
depth
}
}
set
(
value
)
{
set
(
value
)
{
material
.
depth
=
value
material
Layer
.
depth
=
value
}
}
}
}
...
@@ -216,30 +216,30 @@ extension CALayer {
...
@@ -216,30 +216,30 @@ extension CALayer {
@IBInspectable
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
get
{
return
material
.
isShadowPathAutoSizing
return
material
Layer
.
isShadowPathAutoSizing
}
}
set
(
value
)
{
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
material
Layer
.
isShadowPathAutoSizing
=
value
}
}
}
}
/// A property that sets the cornerRadius of the backing layer.
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
get
{
return
material
.
cornerRadiusPreset
return
material
Layer
.
cornerRadiusPreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
material
Layer
.
cornerRadiusPreset
=
value
}
}
}
}
/// A preset property to set the borderWidth.
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
get
{
return
material
.
borderWidthPreset
return
material
Layer
.
borderWidthPreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
borderWidthPreset
=
value
material
Layer
.
borderWidthPreset
=
value
}
}
}
}
...
...
Sources/iOS/Material+UIView.swift
View file @
a6308b53
...
@@ -264,16 +264,7 @@ extension UIView {
...
@@ -264,16 +264,7 @@ extension UIView {
- Parameter animation: A CAAnimation instance.
- Parameter animation: A CAAnimation instance.
*/
*/
open
func
animate
(
animation
:
CAAnimation
)
{
open
func
animate
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
layer
.
animate
(
animation
:
animation
)
a
.
fromValue
=
(
nil
==
layer
.
presentation
()
?
layer
:
layer
.
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
layer
.
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
layer
.
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
layer
.
add
(
a
,
forKey
:
kCATransition
)
}
}
}
/**
/**
...
@@ -285,20 +276,7 @@ extension UIView {
...
@@ -285,20 +276,7 @@ extension UIView {
if interrupted.
if interrupted.
*/
*/
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
layer
.
animationDidStop
(
animation
,
finished
:
flag
)
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
}
}
/// Manages the layout for the shape of the view instance.
/// Manages the layout for the shape of the view instance.
...
...
Sources/iOS/NavigationBar.swift
View file @
a6308b53
...
@@ -207,14 +207,13 @@ public class NavigationBar: UINavigationBar {
...
@@ -207,14 +207,13 @@ public class NavigationBar: UINavigationBar {
contentView
.
grid
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
let
v
=
item
.
leftControls
{
for
c
in
v
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
let
w
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
Int
(
w
/
gridFactor
)
+
1
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
...
@@ -227,14 +226,13 @@ public class NavigationBar: UINavigationBar {
...
@@ -227,14 +226,13 @@ public class NavigationBar: UINavigationBar {
titleView
.
grid
.
views
.
append
(
contentView
)
titleView
.
grid
.
views
.
append
(
contentView
)
// rightControls
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
if
let
v
=
item
.
rightControls
{
for
c
in
v
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
let
w
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
Int
(
w
/
gridFactor
)
+
1
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
...
@@ -268,7 +266,7 @@ public class NavigationBar: UINavigationBar {
...
@@ -268,7 +266,7 @@ public class NavigationBar: UINavigationBar {
item
.
titleLabel
.
sizeToFit
()
item
.
titleLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
let
diff
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
item
.
titleLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
...
...
Sources/iOS/NavigationItem.swift
View file @
a6308b53
...
@@ -31,14 +31,14 @@
...
@@ -31,14 +31,14 @@
import
UIKit
import
UIKit
/// A memory reference to the NavigationItem instance.
/// A memory reference to the NavigationItem instance.
private
var
MaterialAssociatedObject
NavigationItemKey
:
UInt8
=
0
private
var
NavigationItemKey
:
UInt8
=
0
public
class
MaterialAssociatedObject
NavigationItem
{
public
class
NavigationItem
{
/**
/**
A boolean indicating whether keys are being observed
A boolean indicating whether keys are being observed
on the UINavigationItem.
on the UINavigationItem.
*/
*/
internal
var
observed
:
Bool
=
false
internal
var
observed
=
false
/// Back Button.
/// Back Button.
public
var
backButton
:
IconButton
?
public
var
backButton
:
IconButton
?
...
@@ -53,10 +53,10 @@ public class MaterialAssociatedObjectNavigationItem {
...
@@ -53,10 +53,10 @@ public class MaterialAssociatedObjectNavigationItem {
public
private(set)
var
detailLabel
:
UILabel
!
public
private(set)
var
detailLabel
:
UILabel
!
/// Left controls.
/// Left controls.
public
var
leftControls
:
Array
<
UIControl
>
?
public
var
leftControls
:
[
UIView
]
?
/// Right controls.
/// Right controls.
public
var
rightControls
:
Array
<
UIControl
>
?
public
var
rightControls
:
[
UIView
]
?
/// Initializer.
/// Initializer.
public
init
()
{
public
init
()
{
...
@@ -65,7 +65,7 @@ public class MaterialAssociatedObjectNavigationItem {
...
@@ -65,7 +65,7 @@ public class MaterialAssociatedObjectNavigationItem {
}
}
/// Reloads the subviews for the NavigationBar.
/// Reloads the subviews for the NavigationBar.
internal
func
reload
NavigationBar
()
{
internal
func
reload
()
{
guard
let
navigationBar
=
contentView
?
.
superview
?
.
superview
as?
NavigationBar
else
{
guard
let
navigationBar
=
contentView
?
.
superview
?
.
superview
as?
NavigationBar
else
{
return
return
}
}
...
@@ -89,34 +89,34 @@ public class MaterialAssociatedObjectNavigationItem {
...
@@ -89,34 +89,34 @@ public class MaterialAssociatedObjectNavigationItem {
extension
UINavigationItem
{
extension
UINavigationItem
{
/// NavigationItem reference.
/// NavigationItem reference.
public
internal(set)
var
item
:
MaterialAssociatedObject
NavigationItem
{
public
internal(set)
var
navigationItem
:
NavigationItem
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialAssociatedObject
NavigationItemKey
)
{
return
AssociatedObject
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
MaterialAssociatedObject
NavigationItem
()
return
NavigationItem
()
}
}
}
}
set
(
value
)
{
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialAssociatedObject
NavigationItemKey
,
value
:
value
)
AssociateObject
(
base
:
self
,
key
:
&
NavigationItemKey
,
value
:
value
)
}
}
}
}
/// Back Button.
/// Back Button.
public
internal(set)
var
backButton
:
IconButton
?
{
public
internal(set)
var
backButton
:
IconButton
?
{
get
{
get
{
return
i
tem
.
backButton
return
navigationI
tem
.
backButton
}
}
set
(
value
)
{
set
(
value
)
{
i
tem
.
backButton
=
value
navigationI
tem
.
backButton
=
value
}
}
}
}
/// Content View.
/// Content View.
public
internal(set)
var
contentView
:
UIView
?
{
public
internal(set)
var
contentView
:
UIView
?
{
get
{
get
{
return
i
tem
.
contentView
return
navigationI
tem
.
contentView
}
}
set
(
value
)
{
set
(
value
)
{
i
tem
.
contentView
=
value
navigationI
tem
.
contentView
=
value
}
}
}
}
...
@@ -127,13 +127,13 @@ extension UINavigationItem {
...
@@ -127,13 +127,13 @@ extension UINavigationItem {
}
}
set
(
value
)
{
set
(
value
)
{
titleLabel
.
text
=
value
titleLabel
.
text
=
value
item
.
reloadNavigationBar
()
navigationItem
.
reload
()
}
}
}
}
/// Title Label.
/// Title Label.
public
var
titleLabel
:
UILabel
{
public
var
titleLabel
:
UILabel
{
return
i
tem
.
titleLabel
return
navigationI
tem
.
titleLabel
}
}
/// Detail text.
/// Detail text.
...
@@ -143,32 +143,32 @@ extension UINavigationItem {
...
@@ -143,32 +143,32 @@ extension UINavigationItem {
}
}
set
(
value
)
{
set
(
value
)
{
detailLabel
.
text
=
value
detailLabel
.
text
=
value
item
.
reloadNavigationBar
()
navigationItem
.
reload
()
}
}
}
}
/// Detail Label.
/// Detail Label.
public
var
detailLabel
:
UILabel
{
public
var
detailLabel
:
UILabel
{
return
i
tem
.
detailLabel
return
navigationI
tem
.
detailLabel
}
}
/// Left side UI
Control
s.
/// Left side UI
View
s.
public
var
leftControls
:
Array
<
UIControl
>
?
{
public
var
leftControls
:
[
UIView
]
?
{
get
{
get
{
return
i
tem
.
leftControls
return
navigationI
tem
.
leftControls
}
}
set
(
value
)
{
set
(
value
)
{
i
tem
.
leftControls
=
value
navigationI
tem
.
leftControls
=
value
}
}
}
}
/// Right side UI
Control
s.
/// Right side UI
View
s.
public
var
rightControls
:
Array
<
UIControl
>
?
{
public
var
rightControls
:
[
UIView
]
?
{
get
{
get
{
return
i
tem
.
rightControls
return
navigationI
tem
.
rightControls
}
}
set
(
value
)
{
set
(
value
)
{
i
tem
.
rightControls
=
value
navigationI
tem
.
rightControls
=
value
}
}
}
}
}
}
Sources/iOS/RootController.swift
View file @
a6308b53
...
@@ -62,7 +62,7 @@ open class RootController: UIViewController {
...
@@ -62,7 +62,7 @@ open class RootController: UIViewController {
is recommended to use the transitionFromRootViewController
is recommended to use the transitionFromRootViewController
helper method.
helper method.
*/
*/
public
internal(set)
var
rootViewController
:
UIViewController
!
open
internal(set)
var
rootViewController
:
UIViewController
!
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
...
...
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