Skip to content

Commit

Permalink
🔧 컨플릭트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chopmozzi committed Dec 6, 2023
1 parent 6a41923 commit 963074e
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ final class PlaybackViewController: BaseViewController {
return collectionView
}()

private let reportButton: UIBarButtonItem = {
let button: UIButton = UIButton()
button.setImage(UIImage(systemName: "ellipsis"), for: .normal)
let barButtonItem: UIBarButtonItem = UIBarButtonItem(customView: button)
barButtonItem.customView?.transform = CGAffineTransform(rotationAngle: .pi / 2)
return barButtonItem
}()

// MARK: - Properties

private var dataSource: UICollectionViewDiffableDataSource<Section, Models.PlaybackVideo>?
Expand Down Expand Up @@ -125,47 +117,6 @@ final class PlaybackViewController: BaseViewController {

override func setUI() {
super.setUI()
addWindowPlayerSlider()
guard let button = reportButton.customView as? UIButton else { return }
button.addTarget(self, action: #selector(reportButtonDidTap), for: .touchUpInside)
self.navigationItem.rightBarButtonItem = reportButton
self.navigationController?.navigationBar.tintColor = .layoverWhite
}

private func addWindowPlayerSlider() {
let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene
let window = windowScene?.windows.first
guard let playerSliderWidth: CGFloat = windowScene?.screen.bounds.width else { return }
guard let windowHeight: CGFloat = windowScene?.screen.bounds.height else { return }
guard let tabBarHeight: CGFloat = self.tabBarController?.tabBar.frame.height else { return }
playerSlider.frame = CGRect(x: 0, y: (windowHeight - tabBarHeight - LOSlider.loSliderHeight / 2), width: playerSliderWidth, height: LOSlider.loSliderHeight)
window?.addSubview(playerSlider)
playerSlider.window?.windowLevel = UIWindow.Level.normal + 1
}

private func setPlayerSlider(at playbackView: PlaybackView) {
let interval: CMTime = CMTimeMakeWithSeconds(1, preferredTimescale: Int32(NSEC_PER_SEC))
playbackView.playerView.player?.addPeriodicTimeObserver(forInterval: interval, queue: .main, using: { [weak self] currentTime in
self?.updateSlider(currentTime: currentTime, playerView: playbackView.playerView)
})
playerSlider.addTarget(self, action: #selector(didChangedSliderValue(_:)), for: .valueChanged)
}

private func updateSlider(currentTime: CMTime, playerView: PlayerView) {
guard let currentItem: AVPlayerItem = playerView.player?.currentItem else { return }
let duration: CMTime = currentItem.duration
if CMTIME_IS_INVALID(duration) { return }
playerSlider.value = Float(CMTimeGetSeconds(currentTime) / CMTimeGetSeconds(duration))
}

private func slowShowPlayerSlider() async {
do {
try await Task.sleep(nanoseconds: 1_000_000_00)
playerSlider.isHidden = false
} catch {
os_log("Fail Waiting show Player Slider")
}
}

@objc private func didChangedSliderValue(_ sender: LOSlider) {
Expand All @@ -176,20 +127,6 @@ final class PlaybackViewController: BaseViewController {
private func moveToBackViewController() {
interactor?.moveToBack()
}

@objc private func reportButtonDidTap() {
let alert: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let reportAction: UIAlertAction = UIAlertAction(title: "신고", style: .destructive, handler: {
[weak self] _ in
self?.router?.routeToReport()
})
let cancelAction: UIAlertAction = UIAlertAction(title: "취소", style: .cancel)
alert.addAction(reportAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: {
self.interactor?.leavePlaybackView()
})
}
}

extension PlaybackViewController: PlaybackDisplayLogic {
Expand All @@ -215,11 +152,6 @@ extension PlaybackViewController: PlaybackDisplayLogic {
curCell.addPlayerSlider(tabBarHeight: tabBarHeight)
curCell.playbackView.addTargetPlayerSlider()
curCell.playbackView.playPlayer()
setPlayerSlider(at: curCell.playbackView)
// Slider가 원점으로 돌아가는 시간 필요
Task {
await slowShowPlayerSlider()
}
}
}

Expand Down

0 comments on commit 963074e

Please sign in to comment.