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

Commit d041217

Browse files
committed
Rename delegate method
1 parent 73cee94 commit d041217

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

Example/PagingMenuControllerDemo/PagingMenuViewController.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,23 @@ class PagingMenuViewController: UIViewController {
2424

2525
extension PagingMenuViewController: PagingMenuControllerDelegate {
2626
// MARK: - PagingMenuControllerDelegate
27-
28-
func willMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController) {
27+
func willMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController) {
28+
print(previousMenuController)
29+
print(menuController)
2930
}
30-
31-
func didMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController) {
31+
32+
func didMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController) {
33+
print(previousMenuController)
34+
print(menuController)
3235
}
3336

34-
func willMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
37+
func willMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView) {
38+
print(previousMenuItemView)
39+
print(menuItemView)
3540
}
3641

37-
func didMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
42+
func didMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView) {
43+
print(previousMenuItemView)
44+
print(menuItemView)
3845
}
3946
}

Pod/Classes/MenuView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ open class MenuView: UIScrollView {
109109

110110
if let previousMenuItemView = previousMenuItemView,
111111
page != previousPage {
112-
viewDelegate?.willMoveToMenuItemView(menuItemView, previousMenuItemView: previousMenuItemView)
112+
viewDelegate?.willMove(toMenuItem: menuItemView, fromMenuItem: previousMenuItemView)
113113
}
114114

115115
updateCurrentPage(page)
@@ -140,7 +140,7 @@ open class MenuView: UIScrollView {
140140

141141
if let previousMenuItemView = previousMenuItemView,
142142
page != previousPage {
143-
self!.viewDelegate?.didMoveToMenuItemView(self!.currentMenuItemView, previousMenuItemView: previousMenuItemView)
143+
self!.viewDelegate?.didMove(toMenuItem: self!.currentMenuItemView, fromMenuItem: previousMenuItemView)
144144
}
145145
}
146146
}

Pod/Classes/PagingMenuController.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
import UIKit
1010

1111
public protocol PagingMenuControllerDelegate: class {
12-
func willMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController)
13-
func didMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController)
14-
func willMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView)
15-
func didMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView)
12+
func willMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController)
13+
func didMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController)
14+
func willMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView)
15+
func didMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView)
1616
}
1717

1818
public extension PagingMenuControllerDelegate {
19-
func willMoveToPageMenuController(menuController: UIViewController, previousMenuController: UIViewController) {}
20-
func didMoveToPageMenuController(menuController: UIViewController, previousMenuController: UIViewController) {}
21-
func willMoveToMenuItemView(menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {}
22-
func didMoveToMenuItemView(menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {}
19+
func willMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController) {}
20+
func didMove(toMenu menuController: UIViewController, fromMenu previousMenuController: UIViewController) {}
21+
func willMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView) {}
22+
func didMove(toMenuItem menuItemView: MenuItemView, fromMenuItem previousMenuItemView: MenuItemView) {}
2323
}
2424

2525
internal let MinimumSupportedViewCount = 1
@@ -128,7 +128,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
128128
case .menuView: return
129129
default: break
130130
}
131-
131+
132132
constructPagingViewController()
133133
layoutPagingViewController()
134134
}
@@ -159,14 +159,14 @@ open class PagingMenuController: UIViewController, PagingValidator {
159159
}
160160

161161
guard let pagingViewController = pagingViewController,
162-
let previousViewController = pagingViewController.currentViewController else { return }
162+
let previousPagingViewController = pagingViewController.currentViewController else { return }
163163

164164
// hide paging views if it's moving to far away
165165
hidePagingMenuControllers(page)
166166

167167
let nextPage = page % pagingViewController.controllers.count
168168
let nextPagingViewController = pagingViewController.controllers[nextPage]
169-
delegate?.willMoveToPageMenuController(nextPagingViewController, previousMenuController: previousViewController)
169+
delegate?.willMove(toMenu: nextPagingViewController, fromMenu: previousPagingViewController)
170170
menuView?.moveToMenu(page)
171171

172172
pagingViewController.updateCurrentPage(nextPage)
@@ -182,7 +182,7 @@ open class PagingMenuController: UIViewController, PagingValidator {
182182
// show paging views
183183
self?.showPagingMenuControllers()
184184

185-
self?.delegate?.didMoveToPageMenuController(nextPagingViewController, previousMenuController: previousViewController)
185+
self?.delegate?.didMove(toMenu: nextPagingViewController, fromMenu: previousPagingViewController)
186186
}
187187
}
188188

0 commit comments

Comments
 (0)