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
41139013
Commit
41139013
authored
Jun 05, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix delegations never fired on tab swipe
parent
87ac65d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
Sources/iOS/TabsController.swift
+20
-18
No files found.
Sources/iOS/TabsController.swift
View file @
41139013
...
@@ -374,10 +374,10 @@ fileprivate extension TabsController {
...
@@ -374,10 +374,10 @@ fileprivate extension TabsController {
switch
swipeGesture
.
direction
{
switch
swipeGesture
.
direction
{
case
.
right
:
case
.
right
:
guard
(
selectedIndex
-
1
)
>=
0
else
{
return
}
guard
(
selectedIndex
-
1
)
>=
0
else
{
return
}
select
(
at
:
selectedIndex
-
1
)
internalSelect
(
at
:
selectedIndex
-
1
,
isTriggeredByUserInteraction
:
true
)
case
.
left
:
case
.
left
:
guard
(
selectedIndex
+
1
)
<
viewControllers
.
count
else
{
return
}
guard
(
selectedIndex
+
1
)
<
viewControllers
.
count
else
{
return
}
select
(
at
:
selectedIndex
+
1
)
internalSelect
(
at
:
selectedIndex
+
1
,
isTriggeredByUserInteraction
:
true
)
default
:
default
:
break
break
}
}
...
@@ -391,10 +391,26 @@ extension TabsController {
...
@@ -391,10 +391,26 @@ extension TabsController {
- Parameter at index: An Int.
- Parameter at index: An Int.
*/
*/
open
func
select
(
at
index
:
Int
)
{
open
func
select
(
at
index
:
Int
)
{
internalSelect
(
at
:
index
,
isTriggeredByUserInteraction
:
false
)
}
/**
Transitions to the view controller that is at the given index.
- Parameter at index: An Int.
- Parameter isTriggeredByUserInteraction: A boolean indicating whether the
state was changed by a user interaction, true if yes, false otherwise.
*/
private
func
internalSelect
(
at
index
:
Int
,
isTriggeredByUserInteraction
:
Bool
)
{
guard
index
!=
selectedIndex
else
{
guard
index
!=
selectedIndex
else
{
return
return
}
}
if
isTriggeredByUserInteraction
{
guard
!
(
false
==
delegate
?
.
tabsController
?(
tabsController
:
self
,
shouldSelect
:
viewControllers
[
index
]))
else
{
return
}
}
Motion
.
async
{
[
weak
self
]
in
Motion
.
async
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
...
@@ -402,7 +418,7 @@ extension TabsController {
...
@@ -402,7 +418,7 @@ extension TabsController {
s
.
tabBar
.
select
(
at
:
index
)
s
.
tabBar
.
select
(
at
:
index
)
s
.
transition
(
to
:
s
.
viewControllers
[
index
],
isTriggeredByUserInteraction
:
false
)
{
[
weak
self
]
(
isFinishing
)
in
s
.
transition
(
to
:
s
.
viewControllers
[
index
],
isTriggeredByUserInteraction
:
isTriggeredByUserInteraction
)
{
[
weak
self
]
(
isFinishing
)
in
guard
isFinishing
else
{
guard
isFinishing
else
{
return
return
}
}
...
@@ -424,20 +440,6 @@ extension TabsController: TabBarDelegate, _TabBarDelegate {
...
@@ -424,20 +440,6 @@ extension TabsController: TabBarDelegate, _TabBarDelegate {
return
return
}
}
guard
i
!=
selectedIndex
else
{
internalSelect
(
at
:
i
,
isTriggeredByUserInteraction
:
true
)
return
}
guard
!
(
false
==
delegate
?
.
tabsController
?(
tabsController
:
self
,
shouldSelect
:
viewControllers
[
i
]))
else
{
return
}
transition
(
to
:
viewControllers
[
i
],
isTriggeredByUserInteraction
:
true
)
{
[
weak
self
]
(
isFinishing
)
in
guard
isFinishing
else
{
return
}
self
?
.
selectedIndex
=
i
}
}
}
}
}
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