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
fbdef004
Commit
fbdef004
authored
Sep 07, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pr-848: updated pull request to simplify code changes
parent
415577d7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
75 deletions
+39
-75
Sources/iOS/TabsController.swift
+39
-21
Sources/iOS/TransitionController.swift
+0
-54
No files found.
Sources/iOS/TabsController.swift
View file @
fbdef004
...
@@ -90,17 +90,8 @@ open class TabsController: TransitionController {
...
@@ -90,17 +90,8 @@ open class TabsController: TransitionController {
}
}
}
}
fileprivate
var
_isAllDirectionSlideEnable
:
Bool
=
false
/// user can slide views left, right naturally.
/// user can slide views left, right naturally.
open
var
isAllDirectionSlideEnabled
:
Bool
{
open
var
isAllDirectionSlideEnabled
=
true
get
{
return
_isAllDirectionSlideEnable
}
set
(
newVal
)
{
_isAllDirectionSlideEnable
=
newVal
}
}
/// A reference to the currently selected view controller index value.
/// A reference to the currently selected view controller index value.
@IBInspectable
@IBInspectable
...
@@ -163,6 +154,43 @@ open class TabsController: TransitionController {
...
@@ -163,6 +154,43 @@ open class TabsController: TransitionController {
prepareTabBar
()
prepareTabBar
()
prepareTabItems
()
prepareTabItems
()
}
}
open
override
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?)
{
guard
let
fvc
=
rootViewController
else
{
return
}
let
tvc
=
viewController
tvc
.
view
.
isHidden
=
false
tvc
.
view
.
frame
=
container
.
bounds
let
fvcIndex
=
viewControllers
.
index
(
of
:
fvc
)
let
tvcIndex
=
viewControllers
.
index
(
of
:
viewController
)
var
isAuto
=
false
switch
tvc
.
motionModalTransitionType
{
case
.
auto
:
isAuto
=
true
tvc
.
motionModalTransitionType
=
fvcIndex
!
<
tvcIndex
!
?
.
slide
(
direction
:
.
left
)
:
.
slide
(
direction
:
.
right
)
default
:
break
}
view
.
isUserInteractionEnabled
=
false
Motion
.
shared
.
transition
(
from
:
fvc
,
to
:
tvc
,
in
:
container
)
{
[
weak
self
,
tvc
=
tvc
,
isAuto
=
isAuto
,
completion
=
completion
]
(
isFinished
)
in
guard
let
s
=
self
else
{
return
}
if
isAuto
{
tvc
.
motionModalTransitionType
=
.
auto
}
s
.
rootViewController
=
tvc
s
.
view
.
isUserInteractionEnabled
=
true
completion
?(
isFinished
)
}
}
}
}
internal
extension
TabsController
{
internal
extension
TabsController
{
...
@@ -273,7 +301,7 @@ fileprivate extension TabsController {
...
@@ -273,7 +301,7 @@ fileprivate extension TabsController {
extension
TabsController
:
TabBarDelegate
{
extension
TabsController
:
TabBarDelegate
{
@objc
@objc
open
func
tabBar
(
tabBar
:
TabBar
,
did
Select
tabItem
:
TabItem
)
{
open
func
tabBar
(
tabBar
:
TabBar
,
will
Select
tabItem
:
TabItem
)
{
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
return
return
}
}
...
@@ -286,15 +314,6 @@ extension TabsController: TabBarDelegate {
...
@@ -286,15 +314,6 @@ extension TabsController: TabBarDelegate {
return
return
}
}
if
(
_isAllDirectionSlideEnable
)
{
tabsTransition
(
tabsController
:
self
,
to
:
viewControllers
[
i
],
completion
:
{
[
weak
self
]
(
isFinished
)
in
guard
isFinished
else
{
return
}
self
?
.
selectedIndex
=
i
})
}
else
{
transition
(
to
:
viewControllers
[
i
])
{
[
weak
self
]
(
isFinished
)
in
transition
(
to
:
viewControllers
[
i
])
{
[
weak
self
]
(
isFinished
)
in
guard
isFinished
else
{
guard
isFinished
else
{
return
return
...
@@ -303,5 +322,4 @@ extension TabsController: TabBarDelegate {
...
@@ -303,5 +322,4 @@ extension TabsController: TabBarDelegate {
self
?
.
selectedIndex
=
i
self
?
.
selectedIndex
=
i
}
}
}
}
}
}
}
Sources/iOS/TransitionController.swift
View file @
fbdef004
...
@@ -128,60 +128,6 @@ open class TransitionController: UIViewController {
...
@@ -128,60 +128,6 @@ open class TransitionController: UIViewController {
}
}
/**
/**
A method to swap rootViewController objects specially in tabsController.
- Parameter tabsController: indicate tabsController. if tabsController nil then default transition method will be executed.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active rootViewController
to the toViewController has completed.
*/
open
func
tabsTransition
(
tabsController
:
TabsController
?,
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
guard
let
fvc
=
rootViewController
else
{
return
}
let
tvc
=
viewController
tvc
.
view
.
isHidden
=
false
tvc
.
view
.
frame
=
container
.
bounds
if
(
tabsController
==
nil
)
{
tvc
.
motionModalTransitionType
=
motionTransitionType
view
.
isUserInteractionEnabled
=
false
Motion
.
shared
.
transition
(
from
:
fvc
,
to
:
tvc
,
in
:
container
)
{
[
weak
self
,
tvc
=
tvc
,
completion
=
completion
]
(
isFinished
)
in
guard
let
s
=
self
else
{
return
}
s
.
rootViewController
=
tvc
s
.
view
.
isUserInteractionEnabled
=
true
completion
?(
isFinished
)
}
}
let
fvcIndex
=
tabsController
?
.
viewControllers
.
index
(
of
:
fvc
)
let
tvcIndex
=
tabsController
?
.
viewControllers
.
index
(
of
:
viewController
)
if
(
fvcIndex
!
<
tvcIndex
!
)
{
tvc
.
motionModalTransitionType
=
.
slide
(
direction
:
.
left
)
}
else
{
tvc
.
motionModalTransitionType
=
.
slide
(
direction
:
.
right
)
}
view
.
isUserInteractionEnabled
=
false
Motion
.
shared
.
transition
(
from
:
fvc
,
to
:
tvc
,
in
:
container
)
{
[
weak
self
,
tvc
=
tvc
,
completion
=
completion
]
(
isFinished
)
in
guard
let
s
=
self
else
{
return
}
s
.
rootViewController
=
tvc
s
.
view
.
isUserInteractionEnabled
=
true
completion
?(
isFinished
)
}
}
/**
To execute in the order of the layout chain, override this
To execute in the order of the layout chain, override this
method. `layoutSubviews` should be called immediately, unless you
method. `layoutSubviews` should be called immediately, unless you
have a certain need.
have a certain need.
...
...
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