Skip to content

Commit

Permalink
💄 :: [#921] 재생목록 화면 presentationStyle 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 31, 2024
1 parent 864fc7f commit 00cedc0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ private extension MainContainerViewController {
let playlistButtonAction = UIAction { [navigationController, playlistFactory] _ in
guard let playlistFactory else { return }
let playlistViewController = playlistFactory.makeViewController()
navigationController?.topViewController?.showBottomSheet(
content: playlistViewController,
size: .fixed(APP_HEIGHT())
)
playlistViewController.modalPresentationStyle = .overFullScreen
navigationController?.topViewController?.present(playlistViewController, animated: true)
}
playlistFloatingActionButton.addAction(
playlistButtonAction,
Expand All @@ -118,10 +116,8 @@ private extension MainContainerViewController {
.bind { [navigationController, playlistFactory] _ in
guard let playlistFactory else { return }
let playlistViewController = playlistFactory.makeViewController()
navigationController?.topViewController?.showBottomSheet(
content: playlistViewController,
size: .fixed(APP_HEIGHT())
)
playlistViewController.modalPresentationStyle = .overFullScreen
navigationController?.topViewController?.present(playlistViewController, animated: true)
}
.disposed(by: disposeBag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public final class PlaylistViewController: UIViewController, SongCartViewType {
public var songCartView: BaseFeature.SongCartView!
public var bottomSheetView: BaseFeature.BottomSheetView!

private lazy var panGestureRecognizer = UIPanGestureRecognizer(
target: self,
action: #selector(handlePanGesture(_:))
)

lazy var input = PlaylistViewModel.Input(
viewWillAppearEvent: self.rx.methodInvoked(#selector(UIViewController.viewWillAppear)).map { _ in },
viewWillDisappearEvent: self.rx.methodInvoked(#selector(UIViewController.viewWillDisappear(_:))).map { _ in },
Expand Down Expand Up @@ -67,6 +72,7 @@ public final class PlaylistViewController: UIViewController, SongCartViewType {
super.loadView()
playlistView = PlaylistView(frame: self.view.frame)
self.view.addSubview(playlistView)
self.playlistView.titleBarView.addGestureRecognizer(panGestureRecognizer)
}

override public func viewDidLoad() {
Expand All @@ -86,6 +92,51 @@ public final class PlaylistViewController: UIViewController, SongCartViewType {
}
}

private extension PlaylistViewController {
@objc func handlePanGesture(_ gestureRecognizer: UIPanGestureRecognizer) {
let distance = gestureRecognizer.translation(in: self.view)
let screenHeight = Utility.APP_HEIGHT()

switch gestureRecognizer.state {
case .began:
return

case .changed:
let distanceY = max(distance.y, 0)
view.frame = CGRect(x: 0, y: distanceY, width: view.frame.width, height: screenHeight)
// let opacity = 1 - (distanceY / screenHeight)
// updateOpacity(value: Float(opacity))

case .ended:
let velocity = gestureRecognizer.velocity(in: self.view)

// 빠르게 드래그하거나 화면의 40% 이상 드래그 했을 경우 dismiss
if velocity.y > 1000 || view.frame.origin.y > (screenHeight * 0.4) {
dismiss(animated: true)
} else {
UIView.animate(
withDuration: 0.35,
delay: 0.0,
usingSpringWithDamping: 0.8,
initialSpringVelocity: 0.8,
options: [.curveEaseInOut],
animations: {
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: screenHeight)
self.updateOpacity(value: 1)
}
)
}

default:
break
}
}

func updateOpacity(value: Float) {
playlistView.layer.opacity = value
}
}

private extension PlaylistViewController {
private func bindViewModel() {
bindCountOfSongs(output: output)
Expand Down

0 comments on commit 00cedc0

Please sign in to comment.