-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'iOS/release' into iOS/task/SaveJourney-Using-Local
- Loading branch information
Showing
11 changed files
with
319 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
iOS/Features/Spot/Sources/Spot/Presentation/SpotViewController+Gesture.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// SpotViewController+Gesture.swift | ||
// Spot | ||
// | ||
// Created by μ 민건 on 12/10/23. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
// MARK: - Constants | ||
|
||
private enum Metric { | ||
|
||
static let movedXPositionToBackScene: CGFloat = 50.0 | ||
static let animationDuration: Double = 0.3 | ||
|
||
} | ||
|
||
// MARK: - Gesture | ||
|
||
internal extension SpotViewController { | ||
|
||
func configureLeftToRightSwipeGesture() { | ||
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(panGestureDismiss(_:))) | ||
self.view.addGestureRecognizer(panGesture) | ||
} | ||
|
||
@objc | ||
private func panGestureDismiss(_ sender: UIPanGestureRecognizer) { | ||
let touchPoint = sender.location(in: self.view.window) | ||
let width = self.view.frame.width | ||
let height = self.view.frame.height | ||
switch sender.state { | ||
case .began: | ||
self.initialTouchPoint = touchPoint | ||
case .changed: | ||
if touchPoint.x - self.initialTouchPoint.x > .zero { | ||
self.view.frame = CGRect(x: touchPoint.x - self.initialTouchPoint.x, | ||
y: .zero, | ||
width: width, | ||
height: height) | ||
} | ||
case .ended, .cancelled: | ||
if touchPoint.x - self.initialTouchPoint.x > Metric.movedXPositionToBackScene { | ||
self.navigationDelegate?.popToHome() | ||
} else { | ||
self.view.frame = CGRect(x: .zero, | ||
y: .zero, | ||
width: width, | ||
height: height) | ||
} | ||
default: | ||
UIView.animate(withDuration: Metric.animationDuration) { | ||
self.view.frame = CGRect(x: .zero, | ||
y: .zero, | ||
width: width, | ||
height: height) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.