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
69c51d10
Commit
69c51d10
authored
Sep 14, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-861: Fixed issue where NavigationBar was returning a nil value. Closes #861.
parent
c3ff9361
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
73 deletions
+28
-73
Sources/Frameworks/Motion/Sources/Animator/MotionCoreAnimationViewContext.swift
+1
-1
Sources/iOS/NavigationBar.swift
+1
-1
Sources/iOS/NavigationItem.swift
+19
-40
Sources/iOS/Toolbar.swift
+7
-31
No files found.
Sources/Frameworks/Motion/Sources/Animator/MotionCoreAnimationViewContext.swift
View file @
69c51d10
...
@@ -170,7 +170,7 @@ extension MotionCoreAnimationViewContext {
...
@@ -170,7 +170,7 @@ extension MotionCoreAnimationViewContext {
}
}
if
false
!=
snapshot
.
layer
.
animationKeys
()?
.
isEmpty
{
if
false
!=
snapshot
.
layer
.
animationKeys
()?
.
isEmpty
{
return
snapshot
.
layer
.
value
(
forKeyPath
:
key
)
return
snapshot
.
layer
.
value
(
forKeyPath
:
key
)
}
}
return
(
snapshot
.
layer
.
presentation
()
??
snapshot
.
layer
)
.
value
(
forKeyPath
:
key
)
return
(
snapshot
.
layer
.
presentation
()
??
snapshot
.
layer
)
.
value
(
forKeyPath
:
key
)
...
...
Sources/iOS/NavigationBar.swift
View file @
69c51d10
...
@@ -256,7 +256,7 @@ open class NavigationBar: UINavigationBar {
...
@@ -256,7 +256,7 @@ open class NavigationBar: UINavigationBar {
item
.
titleLabel
.
removeFromSuperview
()
item
.
titleLabel
.
removeFromSuperview
()
}
}
if
nil
!=
item
.
detail
&&
""
!=
item
.
detail
{
if
0
<
item
.
detailLabel
.
text
?
.
utf16
.
count
??
0
{
if
nil
==
item
.
detailLabel
.
superview
{
if
nil
==
item
.
detailLabel
.
superview
{
item
.
contentView
.
addSubview
(
item
.
detailLabel
)
item
.
contentView
.
addSubview
(
item
.
detailLabel
)
}
}
...
...
Sources/iOS/NavigationItem.swift
View file @
69c51d10
...
@@ -34,28 +34,29 @@ import UIKit
...
@@ -34,28 +34,29 @@ import UIKit
fileprivate
var
NavigationItemKey
:
UInt8
=
0
fileprivate
var
NavigationItemKey
:
UInt8
=
0
fileprivate
var
NavigationItemContext
:
UInt8
=
0
fileprivate
var
NavigationItemContext
:
UInt8
=
0
public
class
NavigationItem
:
NSObject
{
fileprivate
class
NavigationItem
:
NSObject
{
/// Should center the contentView.
/// Should center the contentView.
open
var
contentViewAlignment
=
ContentViewAlignment
.
center
{
var
contentViewAlignment
=
ContentViewAlignment
.
center
{
didSet
{
didSet
{
navigationBar
?
.
layoutSubviews
()
navigationBar
?
.
layoutSubviews
()
}
}
}
}
/// Back Button.
/// Back Button.
public
fileprivate
(
set
)
lazy
var
backButton
:
Icon
Button
=
IconButton
()
lazy
var
back
Button
=
IconButton
()
/// Content View.
/// Content View.
public
fileprivate
(
set
)
var
contentView
=
UIView
()
var
contentView
=
UIView
()
/// Title label.
/// Title label.
public
fileprivate
(
set
)
var
titleLabel
=
UILabel
()
@objc
var
titleLabel
=
UILabel
()
/// Detail label.
/// Detail label.
public
fileprivate
(
set
)
var
detailLabel
=
UILabel
()
var
detailLabel
=
UILabel
()
/// Left items.
/// Left items.
public
var
leftViews
=
[
UIView
]()
{
var
leftViews
=
[
UIView
]()
{
didSet
{
didSet
{
for
v
in
oldValue
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
...
@@ -65,7 +66,7 @@ public class NavigationItem: NSObject {
...
@@ -65,7 +66,7 @@ public class NavigationItem: NSObject {
}
}
/// Right items.
/// Right items.
public
var
rightViews
=
[
UIView
]()
{
var
rightViews
=
[
UIView
]()
{
didSet
{
didSet
{
for
v
in
oldValue
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
...
@@ -75,7 +76,7 @@ public class NavigationItem: NSObject {
...
@@ -75,7 +76,7 @@ public class NavigationItem: NSObject {
}
}
/// Center items.
/// Center items.
public
var
centerViews
:
[
UIView
]
{
var
centerViews
:
[
UIView
]
{
get
{
get
{
return
contentView
.
grid
.
views
return
contentView
.
grid
.
views
}
}
...
@@ -85,7 +86,7 @@ public class NavigationItem: NSObject {
...
@@ -85,7 +86,7 @@ public class NavigationItem: NSObject {
}
}
/// An optional reference to the NavigationBar.
/// An optional reference to the NavigationBar.
public
var
navigationBar
:
NavigationBar
?
{
var
navigationBar
:
NavigationBar
?
{
var
v
=
contentView
.
superview
var
v
=
contentView
.
superview
while
nil
!=
v
{
while
nil
!=
v
{
if
let
navigationBar
=
v
as?
NavigationBar
{
if
let
navigationBar
=
v
as?
NavigationBar
{
...
@@ -101,36 +102,37 @@ public class NavigationItem: NSObject {
...
@@ -101,36 +102,37 @@ public class NavigationItem: NSObject {
super
.
observeValue
(
forKeyPath
:
keyPath
,
of
:
object
,
change
:
change
,
context
:
context
)
super
.
observeValue
(
forKeyPath
:
keyPath
,
of
:
object
,
change
:
change
,
context
:
context
)
return
return
}
}
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
}
}
deinit
{
deinit
{
removeObserver
(
self
,
forKeyPath
:
"titleLabel.textAlignment"
)
removeObserver
(
self
,
forKeyPath
:
#keyPath(
titleLabel.textAlignment
)
)
}
}
/// Initializer.
/// Initializer.
public
override
init
()
{
override
init
()
{
super
.
init
()
super
.
init
()
prepareTitleLabel
()
prepareTitleLabel
()
prepareDetailLabel
()
prepareDetailLabel
()
}
}
/// Reloads the subviews for the NavigationBar.
/// Reloads the subviews for the NavigationBar.
f
ileprivate
f
unc
reload
()
{
func
reload
()
{
navigationBar
?
.
layoutSubviews
()
navigationBar
?
.
layoutSubviews
()
}
}
/// Prepares the titleLabel.
/// Prepares the titleLabel.
f
ileprivate
f
unc
prepareTitleLabel
()
{
func
prepareTitleLabel
()
{
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabel
.
textColor
=
Color
.
darkText
.
primary
addObserver
(
self
,
forKeyPath
:
"titleLabel.textAlignment"
,
options
:
[],
context
:
&
NavigationItemContext
)
addObserver
(
self
,
forKeyPath
:
#keyPath(
titleLabel.textAlignment
)
,
options
:
[],
context
:
&
NavigationItemContext
)
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
f
ileprivate
f
unc
prepareDetailLabel
()
{
func
prepareDetailLabel
()
{
detailLabel
.
textAlignment
=
.
center
detailLabel
.
textAlignment
=
.
center
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
contentScaleFactor
=
Screen
.
scale
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
...
@@ -140,7 +142,7 @@ public class NavigationItem: NSObject {
...
@@ -140,7 +142,7 @@ public class NavigationItem: NSObject {
extension
UINavigationItem
{
extension
UINavigationItem
{
/// NavigationItem reference.
/// NavigationItem reference.
public
internal(set)
var
navigationItem
:
NavigationItem
{
fileprivate
var
navigationItem
:
NavigationItem
{
get
{
get
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
NavigationItem
()
return
NavigationItem
()
...
@@ -171,34 +173,11 @@ extension UINavigationItem {
...
@@ -171,34 +173,11 @@ extension UINavigationItem {
return
navigationItem
.
backButton
return
navigationItem
.
backButton
}
}
/// Title text.
@nonobjc
open
var
title
:
String
?
{
get
{
return
titleLabel
.
text
}
set
(
value
)
{
titleLabel
.
text
=
value
navigationItem
.
reload
()
}
}
/// Title Label.
/// Title Label.
open
var
titleLabel
:
UILabel
{
open
var
titleLabel
:
UILabel
{
return
navigationItem
.
titleLabel
return
navigationItem
.
titleLabel
}
}
/// Detail text.
open
var
detail
:
String
?
{
get
{
return
detailLabel
.
text
}
set
(
value
)
{
detailLabel
.
text
=
value
navigationItem
.
reload
()
}
}
/// Detail Label.
/// Detail Label.
open
var
detailLabel
:
UILabel
{
open
var
detailLabel
:
UILabel
{
return
navigationItem
.
detailLabel
return
navigationItem
.
detailLabel
...
...
Sources/iOS/Toolbar.swift
View file @
69c51d10
...
@@ -33,40 +33,16 @@ import UIKit
...
@@ -33,40 +33,16 @@ import UIKit
fileprivate
var
ToolbarContext
:
UInt8
=
0
fileprivate
var
ToolbarContext
:
UInt8
=
0
open
class
Toolbar
:
Bar
{
open
class
Toolbar
:
Bar
{
/// A convenience property to set the titleLabel.text.
@IBInspectable
open
var
title
:
String
?
{
get
{
return
titleLabel
.
text
}
set
(
value
)
{
titleLabel
.
text
=
value
layoutSubviews
()
}
}
/// Title label.
/// Title label.
@IBInspectable
@IBInspectable
open
let
titleLabel
=
UILabel
()
open
let
titleLabel
=
UILabel
()
/// A convenience property to set the detailLabel.text.
@IBInspectable
open
var
detail
:
String
?
{
get
{
return
detailLabel
.
text
}
set
(
value
)
{
detailLabel
.
text
=
value
layoutSubviews
()
}
}
/// Detail label.
/// Detail label.
@IBInspectable
@IBInspectable
open
let
detailLabel
=
UILabel
()
open
let
detailLabel
=
UILabel
()
deinit
{
deinit
{
removeObserver
(
self
,
forKeyPath
:
"titleLabel.textAlignment"
)
removeObserver
(
self
,
forKeyPath
:
#keyPath(
titleLabel.textAlignment
)
)
}
}
/**
/**
...
@@ -101,7 +77,7 @@ open class Toolbar: Bar {
...
@@ -101,7 +77,7 @@ open class Toolbar: Bar {
return
return
}
}
if
nil
!=
title
&&
""
!=
title
{
if
0
<
titleLabel
.
text
?
.
utf16
.
count
??
0
{
if
nil
==
titleLabel
.
superview
{
if
nil
==
titleLabel
.
superview
{
contentView
.
addSubview
(
titleLabel
)
contentView
.
addSubview
(
titleLabel
)
}
}
...
@@ -110,7 +86,7 @@ open class Toolbar: Bar {
...
@@ -110,7 +86,7 @@ open class Toolbar: Bar {
titleLabel
.
removeFromSuperview
()
titleLabel
.
removeFromSuperview
()
}
}
if
nil
!=
detail
&&
""
!=
detail
{
if
0
<
detailLabel
.
text
?
.
utf16
.
count
??
0
{
if
nil
==
detailLabel
.
superview
{
if
nil
==
detailLabel
.
superview
{
contentView
.
addSubview
(
detailLabel
)
contentView
.
addSubview
(
detailLabel
)
}
}
...
@@ -144,18 +120,18 @@ open class Toolbar: Bar {
...
@@ -144,18 +120,18 @@ open class Toolbar: Bar {
}
}
}
}
extension
Toolbar
{
fileprivate
extension
Toolbar
{
/// Prepares the titleLabel.
/// Prepares the titleLabel.
f
ileprivate
f
unc
prepareTitleLabel
()
{
func
prepareTitleLabel
()
{
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabel
.
textColor
=
Color
.
darkText
.
primary
addObserver
(
self
,
forKeyPath
:
"titleLabel.textAlignment"
,
options
:
[],
context
:
&
ToolbarContext
)
addObserver
(
self
,
forKeyPath
:
#keyPath(
titleLabel.textAlignment
)
,
options
:
[],
context
:
&
ToolbarContext
)
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
f
ileprivate
f
unc
prepareDetailLabel
()
{
func
prepareDetailLabel
()
{
detailLabel
.
textAlignment
=
.
center
detailLabel
.
textAlignment
=
.
center
detailLabel
.
contentScaleFactor
=
Screen
.
scale
detailLabel
.
contentScaleFactor
=
Screen
.
scale
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
...
...
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