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
f47aaf8d
Commit
f47aaf8d
authored
Aug 06, 2018
by
Orkhan Alikhanov
Committed by
OrkhanAlikhanov
Aug 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using swift 3.2 way to observe changes
parent
4def686b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
17 deletions
+6
-17
Sources/iOS/Toolbar.swift
+6
-17
No files found.
Sources/iOS/Toolbar.swift
View file @
f47aaf8d
...
@@ -30,8 +30,6 @@
...
@@ -30,8 +30,6 @@
import
UIKit
import
UIKit
fileprivate
var
ToolbarContext
:
UInt8
=
0
open
class
Toolbar
:
Bar
{
open
class
Toolbar
:
Bar
{
/// A convenience property to set the titleLabel.text.
/// A convenience property to set the titleLabel.text.
@IBInspectable
@IBInspectable
...
@@ -65,10 +63,6 @@ open class Toolbar: Bar {
...
@@ -65,10 +63,6 @@ open class Toolbar: Bar {
@IBInspectable
@IBInspectable
public
let
detailLabel
=
UILabel
()
public
let
detailLabel
=
UILabel
()
deinit
{
removeObserver
(
self
,
forKeyPath
:
#keyPath(
titleLabel.textAlignment
)
)
}
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
...
@@ -87,15 +81,6 @@ open class Toolbar: Bar {
...
@@ -87,15 +81,6 @@ open class Toolbar: Bar {
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
}
}
open
override
func
observeValue
(
forKeyPath
keyPath
:
String
?,
of
object
:
Any
?,
change
:
[
NSKeyValueChangeKey
:
Any
]?,
context
:
UnsafeMutableRawPointer
?)
{
guard
"titleLabel.textAlignment"
==
keyPath
else
{
super
.
observeValue
(
forKeyPath
:
keyPath
,
of
:
object
,
change
:
change
,
context
:
context
)
return
}
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
}
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
...
@@ -143,16 +128,20 @@ open class Toolbar: Bar {
...
@@ -143,16 +128,20 @@ open class Toolbar: Bar {
prepareTitleLabel
()
prepareTitleLabel
()
prepareDetailLabel
()
prepareDetailLabel
()
}
}
private
var
titleLabelTextAlignmentObserver
:
NSKeyValueObservation
!
}
}
file
private
extension
Toolbar
{
private
extension
Toolbar
{
/// Prepares the titleLabel.
/// Prepares the titleLabel.
func
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
:
#keyPath(
titleLabel.textAlignment
)
,
options
:
[],
context
:
&
ToolbarContext
)
titleLabelTextAlignmentObserver
=
titleLabel
.
observe
(
\
.
textAlignment
)
{
[
weak
self
]
titleLabel
,
_
in
self
?
.
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
}
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
...
...
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