Skip to content

Commit

Permalink
[Fix] sopt-makers#360 - swipe back 제스처 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Apr 1, 2024
1 parent 91d85a9 commit c1ec784
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public protocol MissionCompletedViewControllable: ViewControllable { }
public protocol RankingViewControllable: ViewControllable & RankingCoordinatable { }
public protocol RankingCoordinatable {
var onCellTap: ((_ username: String, _ sentence: String) -> Void)? { get set }
var onSwiped: (() -> Void)? { get set }
var onNaviBackTap: (() -> Void)? { get set }
}
public protocol PartRankingViewControllable: ViewControllable & RankingCoordinatable { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ final class RankingCoordinator: DefaultCoordinator {

private func showRanking() {
var ranking = factory.makeRankingVC(rankingViewType: self.rankingViewType)
ranking.onSwiped = { [weak self] in
self?.router.popModule()
}

ranking.onCellTap = { [weak self] (username, sentence) in
self?.showOtherMissionList(username, sentence)
}
Expand All @@ -56,9 +54,7 @@ final class RankingCoordinator: DefaultCoordinator {

private func showPartRanking() {
var ranking = factory.makePartRankingVC(rankingViewType: self.rankingViewType)
ranking.onSwiped = { [weak self] in
self?.router.popModule()
}

ranking.onCellTap = { [weak self] (username, sentence) in
self?.showOtherMissionList(username, sentence)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class PartRankingVC: UIViewController, PartRankingViewControllable {
// MARK: - RankingCoordinatable

public var onCellTap: ((String, String) -> Void)?
public var onSwiped: (() -> Void)?
public var onNaviBackTap: (() -> Void)?

// MARK: - UI Components
Expand Down Expand Up @@ -77,7 +76,6 @@ public class PartRankingVC: UIViewController, PartRankingViewControllable {
self.setUI()
self.setLayout()
self.setDelegate()
self.setGesture()
self.registerCells()
self.bindViews()
self.bindViewModels()
Expand Down Expand Up @@ -138,27 +136,6 @@ extension PartRankingVC {
rankingCollectionView.delegate = self
}

private func setGesture() {
let swipeGesture = UIPanGestureRecognizer(target: self, action: #selector(swipeBack(_:)))
swipeGesture.delegate = self
self.rankingCollectionView.addGestureRecognizer(swipeGesture)
}

@objc
private func swipeBack(_ sender: UIPanGestureRecognizer) {
let velocity = sender.velocity(in: rankingCollectionView)
let velocityMinimum: CGFloat = 1000
guard let navigation = self.navigationController else { return }
let isScrollY: Bool = abs(velocity.x) > abs(velocity.y) + 200
let isNotRootView = navigation.viewControllers.count >= 2
if velocity.x >= velocityMinimum
&& isNotRootView
&& isScrollY {
self.rankingCollectionView.isScrollEnabled = false
self.onSwiped?()
}
}

private func registerCells() {
RankingChartCVC.register(target: rankingCollectionView)
RankingListCVC.register(target: rankingCollectionView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class RankingVC: UIViewController, RankingViewControllable {
// MARK: - RankingCoordinatable

public var onCellTap: ((String, String) -> Void)?
public var onSwiped: (() -> Void)?
public var onNaviBackTap: (() -> Void)?

// MARK: - UI Components
Expand Down Expand Up @@ -89,7 +88,6 @@ public class RankingVC: UIViewController, RankingViewControllable {
self.setUI()
self.setLayout()
self.setDelegate()
self.setGesture()
self.registerCells()
self.bindViews()
self.bindViewModels()
Expand Down Expand Up @@ -180,27 +178,6 @@ extension RankingVC {
rankingCollectionView.delegate = self
}

private func setGesture() {
let swipeGesture = UIPanGestureRecognizer(target: self, action: #selector(swipeBack(_:)))
swipeGesture.delegate = self
self.rankingCollectionView.addGestureRecognizer(swipeGesture)
}

@objc
private func swipeBack(_ sender: UIPanGestureRecognizer) {
let velocity = sender.velocity(in: rankingCollectionView)
let velocityMinimum: CGFloat = 1000
guard let navigation = self.navigationController else { return }
let isScrollY: Bool = abs(velocity.x) > abs(velocity.y) + 200
let isNotRootView = navigation.viewControllers.count >= 2
if velocity.x >= velocityMinimum
&& isNotRootView
&& isScrollY {
self.rankingCollectionView.isScrollEnabled = false
self.onSwiped?()
}
}

private func registerCells() {
RankingChartCVC.register(target: rankingCollectionView)
RankingListCVC.register(target: rankingCollectionView)
Expand Down

0 comments on commit c1ec784

Please sign in to comment.