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
fc2556fc
Unverified
Commit
fc2556fc
authored
Jan 19, 2018
by
Daniel Dahan
Committed by
GitHub
Jan 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1019 from seubseub/master
Add Swipe Gesture at TabsController
parents
57540153
1202727e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
Sources/iOS/TabsController.swift
+54
-0
No files found.
Sources/iOS/TabsController.swift
View file @
fc2556fc
...
...
@@ -110,6 +110,18 @@ open class TabsController: TransitionController {
@IBInspectable
open
let
tabBar
=
TabBar
()
/// A value that decide viewcontrollers swipeable. default value is false
open
var
isSwipeEnabled
:
Bool
=
false
{
didSet
{
if
isSwipeEnabled
{
prepareSwipeGesture
()
}
else
{
removeSwipeGesture
()
}
}
}
/// A delegation reference.
open
weak
var
delegate
:
TabsControllerDelegate
?
...
...
@@ -340,6 +352,48 @@ extension TabsController {
}
}
}
/**
Prepare Swipe Gesture.
*/
fileprivate
func
prepareSwipeGesture
()
{
removeSwipeGesture
()
let
swipeRight
=
UISwipeGestureRecognizer
(
target
:
self
,
action
:
#selector(
respondToSwipeGesture(gesture:)
)
)
swipeRight
.
direction
=
.
right
self
.
view
.
addGestureRecognizer
(
swipeRight
)
let
swipeLeft
=
UISwipeGestureRecognizer
(
target
:
self
,
action
:
#selector(
respondToSwipeGesture(gesture:)
)
)
swipeLeft
.
direction
=
.
left
self
.
view
.
addGestureRecognizer
(
swipeLeft
)
}
/**
Remove Swipe Gesture.
*/
fileprivate
func
removeSwipeGesture
()
{
if
self
.
view
.
gestureRecognizers
!=
nil
{
for
gesture
in
self
.
view
.
gestureRecognizers
!
{
guard
let
swipeGesture
=
gesture
as?
UISwipeGestureRecognizer
else
{
continue
}
if
swipeGesture
.
direction
==
.
left
||
swipeGesture
.
direction
==
.
right
{
self
.
view
.
removeGestureRecognizer
(
swipeGesture
)
}
}
}
}
@objc
func
respondToSwipeGesture
(
gesture
:
UIGestureRecognizer
)
{
if
let
swipeGesture
=
gesture
as?
UISwipeGestureRecognizer
{
switch
swipeGesture
.
direction
{
case
.
right
:
guard
(
selectedIndex
-
1
)
>=
0
else
{
return
}
select
(
at
:
selectedIndex
-
1
)
case
.
left
:
guard
(
selectedIndex
+
1
)
<
viewControllers
.
count
else
{
return
}
select
(
at
:
selectedIndex
+
1
)
default
:
break
}
}
}
}
extension
TabsController
:
TabBarDelegate
,
_TabBarDelegate
{
...
...
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