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
8b0aa85d
Commit
8b0aa85d
authored
Aug 22, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added selected property for TabBar that identifies which button is currently selected
parent
15e00b24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
33 deletions
+43
-33
Sources/iOS/TabBar.swift
+43
-33
No files found.
Sources/iOS/TabBar.swift
View file @
8b0aa85d
...
@@ -37,37 +37,7 @@ public enum TabBarLineAlignment: Int {
...
@@ -37,37 +37,7 @@ public enum TabBarLineAlignment: Int {
}
}
open
class
TabBar
:
View
{
open
class
TabBar
:
View
{
/// A reference to the line UIView.
/// Will render the view.
internal
var
line
:
UIView
!
/// The line color.
open
var
lineColor
:
UIColor
?
{
get
{
return
line
.
backgroundColor
}
set
(
value
)
{
line
.
backgroundColor
=
value
}
}
/// A value for the line alignment.
open
var
lineAlignment
=
TabBarLineAlignment
.
bottom
{
didSet
{
layoutSubviews
()
}
}
/// The line height.
open
var
lineHeight
:
CGFloat
{
get
{
return
line
.
height
}
set
(
value
)
{
line
.
height
=
value
}
}
/// Will render the view.
open
var
willRenderView
:
Bool
{
open
var
willRenderView
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
}
...
@@ -115,6 +85,9 @@ open class TabBar: View {
...
@@ -115,6 +85,9 @@ open class TabBar: View {
return
CGSize
(
width
:
width
,
height
:
49
)
return
CGSize
(
width
:
width
,
height
:
49
)
}
}
/// The currently selected button.
open
var
selected
:
UIButton
?
/// Buttons.
/// Buttons.
open
var
buttons
=
[
UIButton
]()
{
open
var
buttons
=
[
UIButton
]()
{
didSet
{
didSet
{
...
@@ -128,6 +101,36 @@ open class TabBar: View {
...
@@ -128,6 +101,36 @@ open class TabBar: View {
}
}
}
}
/// A reference to the line UIView.
internal
var
line
:
UIView
!
/// The line color.
open
var
lineColor
:
UIColor
?
{
get
{
return
line
.
backgroundColor
}
set
(
value
)
{
line
.
backgroundColor
=
value
}
}
/// A value for the line alignment.
open
var
lineAlignment
=
TabBarLineAlignment
.
bottom
{
didSet
{
layoutSubviews
()
}
}
/// The line height.
open
var
lineHeight
:
CGFloat
{
get
{
return
line
.
height
}
set
(
value
)
{
line
.
height
=
value
}
}
/// Layer Reference.
/// Layer Reference.
open
internal(set)
var
divider
:
Divider
!
open
internal(set)
var
divider
:
Divider
!
...
@@ -144,7 +147,12 @@ open class TabBar: View {
...
@@ -144,7 +147,12 @@ open class TabBar: View {
b
.
addTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
b
.
addTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
touchUpInside
)
}
}
grid
.
reload
()
grid
.
reload
()
line
.
frame
=
CGRect
(
x
:
0
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
buttons
.
first
!.
width
,
height
:
lineHeight
)
if
nil
==
selected
{
selected
=
buttons
.
first
}
line
.
frame
=
CGRect
(
x
:
selected
!.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
selected
!.
width
,
height
:
lineHeight
)
}
}
divider
.
reload
()
divider
.
reload
()
}
}
...
@@ -153,7 +161,9 @@ open class TabBar: View {
...
@@ -153,7 +161,9 @@ open class TabBar: View {
/// Handles the button touch event.
/// Handles the button touch event.
@objc
@objc
internal
func
handleButton
(
button
:
UIButton
)
{
internal
func
handleButton
(
button
:
UIButton
)
{
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
]
in
selected
=
button
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
if
let
s
=
self
{
s
.
line
.
x
=
button
.
x
s
.
line
.
x
=
button
.
x
s
.
line
.
width
=
button
.
width
s
.
line
.
width
=
button
.
width
...
...
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