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
8363fcbd
Commit
8363fcbd
authored
Aug 23, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated PageController logic for scrolling transition style
parent
deba7ed3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
5 deletions
+41
-5
Sources/iOS/PageController.swift
+41
-5
No files found.
Sources/iOS/PageController.swift
View file @
8363fcbd
...
@@ -55,6 +55,9 @@ public protocol PageControllerDelegate {
...
@@ -55,6 +55,9 @@ public protocol PageControllerDelegate {
@objc(PageController)
@objc(PageController)
open
class
PageController
:
RootController
{
open
class
PageController
:
RootController
{
/// The currently selected UIViewController.
open
internal(set)
var
selectedIndex
:
Int
=
0
/// Reference to the TabBar.
/// Reference to the TabBar.
open
internal(set)
var
tabBar
:
TabBar
!
open
internal(set)
var
tabBar
:
TabBar
!
...
@@ -66,13 +69,24 @@ open class PageController: RootController {
...
@@ -66,13 +69,24 @@ open class PageController: RootController {
return
rootViewController
as?
UIPageViewController
return
rootViewController
as?
UIPageViewController
}
}
/// A reference to the UIViewControllers.
open
var
viewControllers
=
[
UIViewController
]()
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
}
}
public
override
init
(
rootViewController
:
UIViewController
)
{
public
override
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
rootViewController
:
UIPageViewController
())
super
.
init
(
rootViewController
:
UIPageViewController
(
transitionStyle
:
.
scroll
,
navigationOrientation
:
.
horizontal
,
options
:
nil
))
pageViewController
?
.
setViewControllers
([
rootViewController
],
direction
:
.
forward
,
animated
:
true
,
completion
:
nil
)
viewControllers
.
append
(
rootViewController
)
pageViewController
?
.
setViewControllers
(
viewControllers
,
direction
:
.
forward
,
animated
:
true
,
completion
:
nil
)
}
public
init
(
viewControllers
:
[
UIViewController
],
selectedIndex
:
Int
,
direction
:
UIPageViewControllerNavigationDirection
,
animated
:
Bool
)
{
super
.
init
(
rootViewController
:
UIPageViewController
(
transitionStyle
:
.
scroll
,
navigationOrientation
:
.
horizontal
,
options
:
nil
))
self
.
selectedIndex
=
selectedIndex
self
.
viewControllers
.
append
(
contentsOf
:
viewControllers
)
pageViewController
?
.
setViewControllers
([
self
.
viewControllers
[
selectedIndex
]],
direction
:
direction
,
animated
:
animated
,
completion
:
nil
)
}
}
/**
/**
...
@@ -120,9 +134,9 @@ open class PageController: RootController {
...
@@ -120,9 +134,9 @@ open class PageController: RootController {
return
return
}
}
v
.
isDoubleSided
=
false
v
.
delegate
=
self
v
.
delegate
=
self
v
.
dataSource
=
self
v
.
dataSource
=
self
v
.
isDoubleSided
=
false
}
}
/// Prepares the tabBar.
/// Prepares the tabBar.
...
@@ -137,6 +151,7 @@ open class PageController: RootController {
...
@@ -137,6 +151,7 @@ open class PageController: RootController {
extension
PageController
{
extension
PageController
{
open
func
setViewControllers
(
_
viewControllers
:
[
UIViewController
]?,
direction
:
UIPageViewControllerNavigationDirection
,
animated
:
Bool
,
completion
:
(
@escaping
(
Bool
)
->
Swift
.
Void
)?
=
nil
)
{
open
func
setViewControllers
(
_
viewControllers
:
[
UIViewController
]?,
direction
:
UIPageViewControllerNavigationDirection
,
animated
:
Bool
,
completion
:
(
@escaping
(
Bool
)
->
Swift
.
Void
)?
=
nil
)
{
pageViewController
?
.
setViewControllers
(
viewControllers
,
direction
:
direction
,
animated
:
animated
,
completion
:
completion
)
pageViewController
?
.
setViewControllers
(
viewControllers
,
direction
:
direction
,
animated
:
animated
,
completion
:
completion
)
}
}
}
}
...
@@ -147,10 +162,31 @@ extension PageController: UIPageViewControllerDelegate {
...
@@ -147,10 +162,31 @@ extension PageController: UIPageViewControllerDelegate {
extension
PageController
:
UIPageViewControllerDataSource
{
extension
PageController
:
UIPageViewControllerDataSource
{
public
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerBefore
viewController
:
UIViewController
)
->
UIViewController
?
{
public
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerBefore
viewController
:
UIViewController
)
->
UIViewController
?
{
return
nil
guard
let
current
=
viewControllers
.
index
(
of
:
viewController
)
else
{
return
nil
}
let
previous
=
current
-
1
guard
previous
>=
0
,
viewControllers
.
count
>
previous
else
{
return
nil
}
return
viewControllers
[
previous
]
}
}
public
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerAfter
viewController
:
UIViewController
)
->
UIViewController
?
{
public
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerAfter
viewController
:
UIViewController
)
->
UIViewController
?
{
return
nil
guard
let
current
=
viewControllers
.
index
(
of
:
viewController
)
else
{
return
nil
}
let
next
=
current
+
1
let
count
=
viewControllers
.
count
guard
count
!=
next
,
count
>
next
else
{
return
nil
}
return
viewControllers
[
next
]
}
}
}
}
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