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
0d811800
Unverified
Commit
0d811800
authored
Dec 17, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: issue-624: updated TabBar internals to extension pattern
parent
59d5aaf4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
51 deletions
+57
-51
Sources/iOS/TabBar.swift
+57
-51
No files found.
Sources/iOS/TabBar.swift
View file @
0d811800
...
...
@@ -153,12 +153,64 @@ open class TabBar: Bar {
line
.
frame
=
CGRect
(
x
:
selected
!.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
selected
!.
width
,
height
:
lineHeight
)
}
/// Handles the button touch event.
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open
override
func
prepare
()
{
super
.
prepare
()
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
none
prepareLine
()
prepareDivider
()
}
}
extension
TabBar
{
// Prepares the line.
fileprivate
func
prepareLine
()
{
line
=
UIView
()
line
.
zPosition
=
6000
lineColor
=
Color
.
blueGrey
.
lighten3
lineHeight
=
3
addSubview
(
line
)
}
/// Prepares the divider.
fileprivate
func
prepareDivider
()
{
dividerAlignment
=
.
top
}
/**
Prepares the line animation handlers.
- Parameter button: A UIButton.
*/
fileprivate
func
prepareLineAnimationHandler
(
button
:
UIButton
)
{
removeLineAnimationHandler
(
button
:
button
)
button
.
addTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
}
/**
Removes the line animation handlers.
- Parameter button: A UIButton.
*/
fileprivate
func
removeLineAnimationHandler
(
button
:
UIButton
)
{
button
.
removeTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
}
}
extension
TabBar
{
/// Handles the button touch event.
@objc
internal
func
handleButton
(
button
:
UIButton
)
{
internal
func
handleButton
(
button
:
UIButton
)
{
animate
(
to
:
button
,
isTriggeredByUserInteraction
:
true
)
}
}
}
extension
TabBar
{
/**
Selects a given index from the buttons array.
- Parameter at index: An Int.
...
...
@@ -187,7 +239,7 @@ open class TabBar: Bar {
state was changed by a user interaction, true if yes, false otherwise.
- Parameter completion: An optional completion block.
*/
open
func
animate
(
to
button
:
UIButton
,
isTriggeredByUserInteraction
:
Bool
,
completion
:
((
UIButton
)
->
Void
)?
=
nil
)
{
fileprivate
func
animate
(
to
button
:
UIButton
,
isTriggeredByUserInteraction
:
Bool
,
completion
:
((
UIButton
)
->
Void
)?
=
nil
)
{
if
isTriggeredByUserInteraction
{
delegate
?
.
tabBar
?(
tabBar
:
self
,
willSelect
:
button
)
}
...
...
@@ -216,50 +268,4 @@ open class TabBar: Bar {
completion
?(
button
)
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open
override
func
prepare
()
{
super
.
prepare
()
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
none
prepareLine
()
prepareDivider
()
}
// Prepares the line.
private
func
prepareLine
()
{
line
=
UIView
()
line
.
zPosition
=
6000
lineColor
=
Color
.
blueGrey
.
lighten3
lineHeight
=
3
addSubview
(
line
)
}
/// Prepares the divider.
private
func
prepareDivider
()
{
dividerAlignment
=
.
top
}
/**
Prepares the line animation handlers.
- Parameter button: A UIButton.
*/
private
func
prepareLineAnimationHandler
(
button
:
UIButton
)
{
removeLineAnimationHandler
(
button
:
button
)
button
.
addTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
}
/**
Removes the line animation handlers.
- Parameter button: A UIButton.
*/
private
func
removeLineAnimationHandler
(
button
:
UIButton
)
{
button
.
removeTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
}
}
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