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
4ca95ebc
Commit
4ca95ebc
authored
Jul 25, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjusting line animation on TabBar changes
parent
31330fc6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
27 deletions
+42
-27
Sources/iOS/TabBar.swift
+13
-12
Sources/iOS/TabsController.swift
+29
-15
No files found.
Sources/iOS/TabBar.swift
View file @
4ca95ebc
...
...
@@ -78,14 +78,21 @@ open class TabBar: Bar {
}
/// An enum that determines the tab bar style.
open
var
tabBarStyle
=
TabBarStyle
.
normal
{
open
var
tabBarStyle
=
TabBarStyle
.
scrollable
{
didSet
{
layoutSubviews
()
}
}
/// A reference to the scroll view when the tab bar style is scrollable.
open
fileprivate
(
set
)
var
scrollView
:
UIScrollView
!
open
let
scrollView
=
UIScrollView
()
/// Does the scroll view bounce.
open
var
isScrollBounceEnabled
=
true
{
didSet
{
scrollView
.
bounces
=
true
}
}
/// A delegation reference.
open
weak
var
delegate
:
TabBarDelegate
?
...
...
@@ -270,11 +277,7 @@ open class TabBar: Bar {
layoutDivider
()
let
buttonsWidth
=
buttons
.
reduce
(
0
)
{
$0
+
$1
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
}
if
.
scrollable
==
tabBarStyle
&&
buttonsWidth
>
p
{
if
.
scrollable
==
tabBarStyle
{
scrollView
.
frame
=
CGRect
(
x
:
l
,
y
:
0
,
width
:
p
,
height
:
height
)
var
w
:
CGFloat
=
0
...
...
@@ -288,14 +291,14 @@ open class TabBar: Bar {
w
+=
width
}
scrollView
.
contentSize
=
CGSize
(
width
:
buttonsWidth
,
height
:
height
)
scrollView
.
addSubview
(
line
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
}
else
{
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
centerViews
=
buttons
addSubview
(
line
)
}
addSubview
(
line
)
updateSelectionLine
()
}
...
...
@@ -354,8 +357,6 @@ extension TabBar {
/// Prepares the scroll view.
fileprivate
func
prepareScrollView
()
{
scrollView
=
UIScrollView
()
scrollView
.
bounces
=
false
scrollView
.
isPagingEnabled
=
false
scrollView
.
showsVerticalScrollIndicator
=
false
scrollView
.
showsHorizontalScrollIndicator
=
false
...
...
Sources/iOS/TabsController.swift
View file @
4ca95ebc
...
...
@@ -32,12 +32,7 @@ import UIKit
fileprivate
var
TabItemKey
:
UInt8
=
0
open
class
TabItem
:
FlatButton
{
open
override
func
prepare
()
{
super
.
prepare
()
pulseAnimation
=
.
none
}
}
open
class
TabItem
:
FlatButton
{}
@objc(TabBarAlignment)
public
enum
TabBarAlignment
:
Int
{
...
...
@@ -95,6 +90,7 @@ open class TabsController: UIViewController {
prepareTabBar
()
prepareContainer
()
prepareViewControllers
()
layoutSubviews
()
}
}
...
...
@@ -111,7 +107,7 @@ open class TabsController: UIViewController {
}
/// The transition type used during a transition.
open
var
transitionType
=
MotionTransitionType
.
autoReverse
(
presenting
:
.
fade
)
open
var
motionTransitionType
=
MotionTransitionType
.
fade
/**
An initializer that initializes the object with a NSCoder object.
...
...
@@ -150,8 +146,7 @@ open class TabsController: UIViewController {
open
func
layoutSubviews
()
{
layoutTabBar
()
layoutContainer
()
viewControllers
[
selectedIndex
]
.
view
.
frame
.
size
=
container
.
bounds
.
size
layoutViewController
(
at
:
selectedIndex
)
}
/**
...
...
@@ -165,10 +160,7 @@ open class TabsController: UIViewController {
view
.
contentScaleFactor
=
Screen
.
scale
prepareContainer
()
prepareTabBar
()
for
i
in
0
..<
viewControllers
.
count
{
prepareViewController
(
at
:
i
)
}
prepareViewControllers
()
}
}
...
...
@@ -224,6 +216,21 @@ extension TabsController {
view
.
addSubview
(
container
)
}
/// Prepares all the view controllers.
fileprivate
func
prepareViewControllers
()
{
let
n
=
viewControllers
.
count
for
i
in
0
..<
n
{
guard
i
!=
selectedIndex
else
{
continue
}
prepareViewController
(
at
:
i
)
}
prepareViewController
(
at
:
selectedIndex
)
}
/**
Loads a view controller based on its index in the viewControllers Array
and adds it as a child view controller.
...
...
@@ -267,7 +274,7 @@ extension TabsController {
container
.
height
=
view
.
height
}
container
.
width
=
view
.
bounds
.
width
container
.
width
=
view
.
width
}
/// Layout the TabBar.
...
...
@@ -291,6 +298,11 @@ extension TabsController {
v
.
isHidden
=
true
}
}
/// Layout the view controller at the given index.
fileprivate
func
layoutViewController
(
at
index
:
Int
)
{
viewControllers
[
index
]
.
view
.
frame
.
size
=
container
.
bounds
.
size
}
}
extension
TabsController
{
...
...
@@ -343,10 +355,12 @@ extension TabsController {
let
tvc
=
viewControllers
[
i
]
tvc
.
view
.
frame
.
size
=
container
.
bounds
.
size
tvc
.
motionModalTransitionType
=
t
ransitionType
tvc
.
motionModalTransitionType
=
motionT
ransitionType
Motion
.
shared
.
transition
(
from
:
fvc
,
to
:
tvc
,
in
:
container
)
selectedIndex
=
i
tabBar
?
.
select
(
at
:
selectedIndex
)
}
}
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