Skip to content
This repository was archived by the owner on Jun 17, 2018. It is now read-only.

Commit f3f18cd

Browse files
committed
Rename internal method
1 parent d041217 commit f3f18cd

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

Pod/Classes/MenuView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ open class MenuView: UIScrollView {
9797

9898
// MARK: - Internal method
9999

100-
internal func moveToMenu(_ page: Int, animated: Bool = true) {
100+
internal func move(toPage page: Int, animated: Bool = true) {
101101
// hide menu view when constructing itself
102102
if !animated {
103103
alpha = 0
@@ -112,7 +112,7 @@ open class MenuView: UIScrollView {
112112
viewDelegate?.willMove(toMenuItem: menuItemView, fromMenuItem: previousMenuItemView)
113113
}
114114

115-
updateCurrentPage(page)
115+
update(currentPage: page)
116116

117117
let duration = animated ? menuOptions.animationDuration : 0
118118
UIView.animate(withDuration: duration, animations: { [unowned self] () -> Void in
@@ -340,7 +340,7 @@ extension MenuView: Pagable {
340340
var nextPage: Int {
341341
return currentPage + 1 > menuItemCount - 1 ? 0 : currentPage + 1
342342
}
343-
func updateCurrentPage(_ page: Int) {
343+
func update(currentPage page: Int) {
344344
currentIndex = page
345345
}
346346
}

Pod/Classes/PagingMenuController.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
3333

3434
menuView.delegate = self
3535
menuView.viewDelegate = delegate
36-
menuView.updateCurrentPage(options.defaultPage)
36+
menuView.update(currentPage: options.defaultPage)
3737
view.addSubview(menuView)
3838
}
3939
}
@@ -89,7 +89,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
8989
// reset selected menu item view position
9090
switch menuOptions.displayMode {
9191
case .standard, .infinite:
92-
self.moveToMenuPage(menuView.currentPage)
92+
self.move(toPage: menuView.currentPage)
9393
default: break
9494
}
9595
}, completion: nil)
@@ -110,7 +110,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
110110
setupMenuView()
111111
setupMenuController()
112112

113-
moveToMenuPage(currentPage, animated: false)
113+
move(toPage: currentPage, animated: false)
114114
}
115115

116116
fileprivate func setupMenuView() {
@@ -133,7 +133,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
133133
layoutPagingViewController()
134134
}
135135

136-
open func moveToMenuPage(_ page: Int, animated: Bool = true) {
136+
open func move(toPage page: Int, animated: Bool = true) {
137137
switch options.componentType {
138138
case .menuView, .all:
139139
// ignore an unexpected page number
@@ -142,15 +142,15 @@ open class PagingMenuController: UIViewController, PagingValidator {
142142
let lastPage = menuView.currentPage
143143
guard page != lastPage else {
144144
// place views on appropriate position
145-
menuView.moveToMenu(page, animated: animated)
145+
menuView.move(toPage: page, animated: animated)
146146
pagingViewController?.positionMenuController()
147147
return
148148
}
149149

150150
switch options.componentType {
151151
case .all: break
152152
default:
153-
menuView.moveToMenu(page, animated: animated)
153+
menuView.move(toPage: page, animated: animated)
154154
return
155155
}
156156
case .pagingController:
@@ -167,9 +167,9 @@ open class PagingMenuController: UIViewController, PagingValidator {
167167
let nextPage = page % pagingViewController.controllers.count
168168
let nextPagingViewController = pagingViewController.controllers[nextPage]
169169
delegate?.willMove(toMenu: nextPagingViewController, fromMenu: previousPagingViewController)
170-
menuView?.moveToMenu(page)
170+
menuView?.move(toPage: page)
171171

172-
pagingViewController.updateCurrentPage(nextPage)
172+
pagingViewController.update(currentPage: nextPage)
173173
pagingViewController.currentViewController = nextPagingViewController
174174

175175
let duration = animated ? options.animationDuration : 0
@@ -291,7 +291,7 @@ extension PagingMenuController: UIScrollViewDelegate {
291291
default: return
292292
}
293293

294-
moveToMenuPage(nextPage)
294+
move(toPage: nextPage)
295295
}
296296

297297
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
@@ -301,7 +301,7 @@ extension PagingMenuController: UIScrollViewDelegate {
301301
}
302302

303303
let nextPage = nextPageFromCurrentPoint
304-
moveToMenuPage(nextPage)
304+
move(toPage: nextPage)
305305
}
306306
}
307307

@@ -418,7 +418,7 @@ extension PagingMenuController: GestureHandler {
418418
newPage = page
419419
}
420420

421-
moveToMenuPage(newPage)
421+
move(toPage: newPage)
422422
}
423423

424424
internal func handleSwipeGesture(_ recognizer: UISwipeGestureRecognizer) {
@@ -438,7 +438,7 @@ extension PagingMenuController: GestureHandler {
438438
default: return
439439
}
440440

441-
moveToMenuPage(newPage)
441+
move(toPage: newPage)
442442
}
443443
}
444444

Pod/Classes/PagingViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ open class PagingViewController: UIViewController {
3232

3333
super.init(nibName: nil, bundle: nil)
3434

35-
updateCurrentPage(options.defaultPage)
35+
update(currentPage: options.defaultPage)
3636
setup()
3737
}
3838

@@ -63,7 +63,7 @@ open class PagingViewController: UIViewController {
6363
constructPagingViewControllers()
6464
layoutPagingViewControllers()
6565

66-
updateCurrentPage(options.defaultPage)
66+
update(currentPage: options.defaultPage)
6767
currentViewController = controllers[currentPage]
6868
hideVisibleControllers()
6969
}
@@ -91,9 +91,9 @@ open class PagingViewController: UIViewController {
9191
fileprivate func constructPagingViewControllers() {
9292
for (index, controller) in controllers.enumerated() {
9393
// construct three child view controllers at a maximum, previous(optional), current and next(optional)
94-
if !shouldLoadPage(index) {
94+
if !shouldLoad(page: index) {
9595
// remove unnecessary child view controllers
96-
if isVisibleController(controller) {
96+
if isVisible(controller: controller) {
9797
controller.willMove(toParentViewController: nil)
9898
controller.view!.removeFromSuperview()
9999
controller.removeFromParentViewController()
@@ -104,7 +104,7 @@ open class PagingViewController: UIViewController {
104104
}
105105

106106
// ignore if it's already added
107-
if isVisibleController(controller) {
107+
if isVisible(controller: controller) {
108108
continue
109109
}
110110

@@ -130,7 +130,7 @@ open class PagingViewController: UIViewController {
130130

131131
var viewsDictionary: [String: AnyObject] = ["contentScrollView": contentScrollView]
132132
for (index, controller) in controllers.enumerated() {
133-
if !shouldLoadPage(index) {
133+
if !shouldLoad(page: index) {
134134
continue
135135
}
136136

@@ -207,7 +207,7 @@ extension PagingViewController: Pagable {
207207

208208
return currentPage + 1 > menuOptions.itemsOptions.count - 1 ? 0 : currentPage + 1
209209
}
210-
func updateCurrentPage(_ page: Int) {
210+
func update(currentPage page: Int) {
211211
currentIndex = page
212212
}
213213
}
@@ -228,7 +228,7 @@ extension PagingViewController: ViewCleanable {
228228
}
229229

230230
extension PagingViewController: PageLoadable {
231-
func shouldLoadPage(_ page: Int) -> Bool {
231+
func shouldLoad(page page: Int) -> Bool {
232232
switch (options.menuControllerSet, options.lazyLoadingPage) {
233233
case (.single, _),
234234
(_, .one):
@@ -247,7 +247,7 @@ extension PagingViewController: PageLoadable {
247247
return true
248248
}
249249

250-
func isVisibleController(_ controller: UIViewController) -> Bool {
250+
func isVisible(controller controller: UIViewController) -> Bool {
251251
return self.childViewControllers.contains(controller)
252252
}
253253

Pod/Classes/Protocols/Pagable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ protocol Pagable {
1212
var currentPage: Int { get }
1313
var previousPage: Int { get }
1414
var nextPage: Int { get }
15-
func updateCurrentPage(_ page: Int)
15+
func update(currentPage page: Int)
1616
}
1717

1818
extension Pagable {
19-
func updateCurrentPage(_ page: Int) {}
19+
func update(currentPage page: Int) {}
2020
}

Pod/Classes/Protocols/PageLoadable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import Foundation
1010

1111
protocol PageLoadable {
12-
func shouldLoadPage(_ page: Int) -> Bool
13-
func isVisibleController(_ controller: UIViewController) -> Bool
12+
func shouldLoad(page page: Int) -> Bool
13+
func isVisible(controller controller: UIViewController) -> Bool
1414
func showVisibleControllers()
1515
func hideVisibleControllers()
1616
}

0 commit comments

Comments
 (0)