Skip to content

Commit

Permalink
Merge branch 'iOS/dev' into iOS/feat#226
Browse files Browse the repository at this point in the history
  • Loading branch information
anyukyung committed Dec 8, 2023
2 parents a73f4d0 + 464607f commit d2068f1
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 129 deletions.
16 changes: 8 additions & 8 deletions iOS/Layover/Layover/Network/Mock/MockData/PostList.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"id" : 1,
"encoded_video_url" : "https://assets.afcdn.com/video49/20210722/v_645516.m3u8",
"video_thumbnail_url" : "https://think-note.com/wp-content/uploads/2023/07/eta_3.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "최강 아이돌",
"content" : "게시글 설명"
},
Expand All @@ -32,8 +32,8 @@
"id" : 2,
"encoded_video_url" : "https://qc66zhsq1708.edge.naverncp.com/hls/fMG98EEU8c1UirV-awtm4qKJyhaHRcnDymRFlPLZbTs_/layover-station/IMG_0136_AVC_,HD,SD,_1Pass_30fps.mp4.smil/master.m3u8",
"video_thumbnail_url" : "video_thumbnail_link",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로듀스 101",
"content" : "게시글 설명"
},
Expand All @@ -50,8 +50,8 @@
"id" : 3,
"encoded_video_url" : "https://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8",
"video_thumbnail_url" : "https://cdnimg.melon.co.kr/resource/image/cds/musicstory/imgUrl20210831030133473.jpg/melon/quality/90/optimize",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로미스 나인",
"content" : "게시글 설명"
},
Expand All @@ -68,8 +68,8 @@
"id" : 4,
"encoded_video_url" : "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
"video_thumbnail_url" : "https://res.heraldm.com/content/image/2023/04/16/20230416000040_0.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "아이즈원",
"content" : "게시글 설명2"
},
Expand Down
16 changes: 8 additions & 8 deletions iOS/Layover/Layover/Network/Mock/MockData/PostListMore.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"id" : 5,
"encoded_video_url" : "https://assets.afcdn.com/video49/20210722/v_645516.m3u8",
"video_thumbnail_url" : "https://think-note.com/wp-content/uploads/2023/07/eta_3.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "최강 아이돌",
"content" : "게시글 설명"
},
Expand All @@ -32,8 +32,8 @@
"id" : 6,
"encoded_video_url" : "https://qc66zhsq1708.edge.naverncp.com/hls/fMG98EEU8c1UirV-awtm4qKJyhaHRcnDymRFlPLZbTs_/layover-station/IMG_0136_AVC_,HD,SD,_1Pass_30fps.mp4.smil/master.m3u8",
"video_thumbnail_url" : "video_thumbnail_link",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로듀스 101",
"content" : "게시글 설명"
},
Expand All @@ -50,8 +50,8 @@
"id" : 7,
"encoded_video_url" : "https://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8",
"video_thumbnail_url" : "https://cdnimg.melon.co.kr/resource/image/cds/musicstory/imgUrl20210831030133473.jpg/melon/quality/90/optimize",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로미스 나인",
"content" : "게시글 설명"
},
Expand All @@ -68,8 +68,8 @@
"id" : 8,
"encoded_video_url" : "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
"video_thumbnail_url" : "https://res.heraldm.com/content/image/2023/04/16/20230416000040_0.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "아이즈원",
"content" : "게시글 설명2"
},
Expand Down
3 changes: 2 additions & 1 deletion iOS/Layover/Layover/Scenes/Home/HomeConfigurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ final class HomeConfigurator: Configurator {
let router = HomeRouter()
let presenter = HomePresenter()
let interactor = HomeInteractor()
let homeWorker = MockHomeWorker()
// let homeWorker = MockHomeWorker()
let homeWorker = HomeWorker()
let videoFileWorker = VideoFileWorker()

router.viewController = viewController
Expand Down
31 changes: 15 additions & 16 deletions iOS/Layover/Layover/Scenes/Playback/Cell/PlaybackCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,51 @@ final class PlaybackCell: UICollectionViewCell {

var boardID: Int?

var playbackView: PlaybackView?
let playbackView: PlaybackView = PlaybackView()

override init(frame: CGRect) {
super.init(frame: frame)
configure()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
configure()
}

override func prepareForReuse() {
resetObserver()
}

func setPlaybackContents(info: PlaybackModels.PlaybackInfo) {
playbackView = nil
boardID = info.boardID
playbackView = PlaybackView(frame: .zero, content: info.content)
playbackView?.descriptionView.titleLabel.text = info.title
configure()
playbackView?.descriptionView.setText(info.content)
playbackView?.profileLabel.text = info.profileName
playbackView?.tagStackView.resetTagStackView()
playbackView.descriptionView.titleLabel.text = info.title
playbackView.descriptionView.setText(info.content)
playbackView.setDescriptionViewUI()
playbackView.profileLabel.text = info.profileName
playbackView.tagStackView.resetTagStackView()
info.tag.forEach { tag in
playbackView?.tagStackView.addTag(tag)
playbackView.tagStackView.addTag(tag)
}
}

func addAVPlayer(url: URL) {
playbackView?.resetPlayer()
playbackView?.addAVPlayer(url: url)
playbackView?.setPlayerSlider()
playbackView.resetPlayer()
playbackView.addAVPlayer(url: url)
playbackView.setPlayerSlider()
}

func addPlayerSlider(tabBarHeight: CGFloat) {
playbackView?.addWindowPlayerSlider(tabBarHeight)
playbackView.addWindowPlayerSlider(tabBarHeight)

}

func resetObserver() {
playbackView?.removeTimeObserver()
playbackView?.removePlayerSlider()
playbackView.removeTimeObserver()
playbackView.removePlayerSlider()
}

private func configure() {
guard let playbackView else { return }
playbackView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(playbackView)
NSLayoutConstraint.activate([
Expand Down
60 changes: 29 additions & 31 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protocol PlaybackBusinessLogic {

protocol PlaybackDataStore: AnyObject {
var parentView: PlaybackModels.ParentView? { get set }
var prevCell: PlaybackCell? { get set }
var previousCell: PlaybackCell? { get set }
var index: Int? { get set }
var isTeleport: Bool? { get set }
var isDelete: Bool? { get set }
Expand All @@ -46,7 +46,7 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {

var parentView: Models.ParentView?

var prevCell: PlaybackCell?
var previousCell: PlaybackCell?

var index: Int?

Expand Down Expand Up @@ -98,29 +98,29 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
// MARK: - UseCase Playback Video

func playInitialPlaybackCell(with request: PlaybackModels.DisplayPlaybackVideo.Request) {
prevCell = request.curCell
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(prevCell: nil, curCell: request.curCell)
previousCell = request.currentCell
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(previousCell: nil, currentCell: request.currentCell)
presenter?.presentPlayInitialPlaybackCell(with: response)
}

func playVideo(with request: PlaybackModels.DisplayPlaybackVideo.Request) {
guard let posts else { return }
var response: Models.DisplayPlaybackVideo.Response
if prevCell == request.curCell {
response = Models.DisplayPlaybackVideo.Response(prevCell: nil, curCell: prevCell)
if previousCell == request.currentCell {
response = Models.DisplayPlaybackVideo.Response(previousCell: nil, currentCell: previousCell)
presenter?.presentShowPlayerSlider(with: response)
isTeleport = false
return
}
// Home이 아닌 다른 뷰에서 왔을 경우(로드한 목록 무한 반복)
if parentView == .other {
if request.indexPathRow == (posts.count - 1) {
response = Models.DisplayPlaybackVideo.Response(indexPathRow: 1, prevCell: prevCell, curCell: nil)
response = Models.DisplayPlaybackVideo.Response(indexPathRow: 1, previousCell: previousCell, currentCell: nil)
} else if request.indexPathRow == 0 {
response = Models.DisplayPlaybackVideo.Response(indexPathRow: posts.count - 2, prevCell: prevCell, curCell: nil)
response = Models.DisplayPlaybackVideo.Response(indexPathRow: posts.count - 2, previousCell: previousCell, currentCell: nil)
} else {
response = Models.DisplayPlaybackVideo.Response(prevCell: prevCell, curCell: request.curCell)
prevCell = request.curCell
response = Models.DisplayPlaybackVideo.Response(previousCell: previousCell, currentCell: request.currentCell)
previousCell = request.currentCell
presenter?.presentMoveCellNext(with: response)
isTeleport = false
return
Expand All @@ -131,36 +131,36 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
}
// Home이면 다음 셀로 이동(추가적인 비디오 로드)
isTeleport = false
response = Models.DisplayPlaybackVideo.Response(prevCell: prevCell, curCell: request.curCell)
prevCell = request.curCell
response = Models.DisplayPlaybackVideo.Response(previousCell: previousCell, currentCell: request.currentCell)
previousCell = request.currentCell
presenter?.presentMoveCellNext(with: response)
}

func playTeleportVideo(with request: PlaybackModels.DisplayPlaybackVideo.Request) {
guard let posts else { return }
var response: Models.DisplayPlaybackVideo.Response
if let isTeleport, isTeleport == true, (request.indexPathRow == 1 || request.indexPathRow == (posts.count - 2)) {
response = Models.DisplayPlaybackVideo.Response(prevCell: prevCell, curCell: request.curCell)
prevCell = request.curCell
response = Models.DisplayPlaybackVideo.Response(previousCell: previousCell, currentCell: request.currentCell)
previousCell = request.currentCell
presenter?.presentMoveCellNext(with: response)
self.isTeleport = false
}

if let isDelete, isDelete == true {
response = Models.DisplayPlaybackVideo.Response(prevCell: nil, curCell: request.curCell)
prevCell = request.curCell
response = Models.DisplayPlaybackVideo.Response(previousCell: nil, currentCell: request.currentCell)
previousCell = request.currentCell
presenter?.presentMoveCellNext(with: response)
self.isDelete = false
}
}

func leavePlaybackView() {
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(prevCell: prevCell, curCell: nil)
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(previousCell: previousCell, currentCell: nil)
presenter?.presentLeavePlaybackView(with: response)
}

func resetVideo() {
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(prevCell: nil, curCell: prevCell)
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(previousCell: nil, currentCell: previousCell)
presenter?.presentResetPlaybackCell(with: response)
}

Expand All @@ -169,26 +169,24 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
let parentView else { return }
let response: Models.ConfigurePlaybackCell.Response
switch parentView {
case .home:
case .home, .myProfile:
response = Models.ConfigurePlaybackCell.Response(teleportIndex: nil)
case .other, .myProfile:
case .other:
response = Models.ConfigurePlaybackCell.Response(teleportIndex: posts.count + 1)
}
presenter?.presentConfigureCell(with: response)
}

func controlPlaybackMovie(with request: PlaybackModels.SeekVideo.Request) {
guard let prevCell,
let playbackView = prevCell.playbackView
else { return }
let willMoveLocation: Float64 = request.currentLocation * playbackView.getDuration()
let response: Models.SeekVideo.Response = Models.SeekVideo.Response(willMoveLocation: willMoveLocation, curCell: prevCell)
guard let previousCell else { return }
let willMoveLocation: Float64 = request.currentLocation * previousCell.playbackView.getDuration()
let response: Models.SeekVideo.Response = Models.SeekVideo.Response(willMoveLocation: willMoveLocation, currentCell: previousCell)
presenter?.presentSeekVideo(with: response)
}

func hidePlayerSlider() {
guard let prevCell else { return }
prevCell.playbackView?.playerSlider?.isHidden = true
guard let previousCell else { return }
previousCell.playbackView.playerSlider?.isHidden = true
}

func setSeeMoreButton() {
Expand All @@ -201,10 +199,10 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {

func deleteVideo(with request: PlaybackModels.DeletePlaybackVideo.Request) -> Task<Bool, Never> {
isDelete = true
guard let prevCell,
guard let previousCell,
let worker
else { return Task { false } }
guard let boardID = prevCell.boardID else { return Task { false } }
guard let boardID = previousCell.boardID else { return Task { false } }
return Task {
let result: Bool = await worker.deletePlaybackVideo(boardID: boardID)
let response: Models.DeletePlaybackVideo.Response = Models.DeletePlaybackVideo.Response(result: result, playbackVideo: request.playbackVideo)
Expand All @@ -216,7 +214,7 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
}

func resumeVideo() {
guard let prevCell else { return }
prevCell.playbackView?.playPlayer()
guard let previousCell else { return }
previousCell.playbackView.playPlayer()
}
}
26 changes: 13 additions & 13 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,30 @@ enum PlaybackModels {
enum DisplayPlaybackVideo {
struct Request {
let indexPathRow: Int?
let curCell: PlaybackCell?
let currentCell: PlaybackCell?
}

struct Response {
let indexPathRow: Int?
let prevCell: PlaybackCell?
let curCell: PlaybackCell?
let previousCell: PlaybackCell?
let currentCell: PlaybackCell?

init(indexPathRow: Int? = nil, prevCell: PlaybackCell?, curCell: PlaybackCell?) {
init(indexPathRow: Int? = nil, previousCell: PlaybackCell?, currentCell: PlaybackCell?) {
self.indexPathRow = indexPathRow
self.prevCell = prevCell
self.curCell = curCell
self.previousCell = previousCell
self.currentCell = currentCell
}
}

struct ViewModel {
let indexPathRow: Int?
var prevCell: PlaybackCell?
let curCell: PlaybackCell?
var previousCell: PlaybackCell?
let currentCell: PlaybackCell?

init(indexPathRow: Int? = nil, prevCell: PlaybackCell?, curCell: PlaybackCell?) {
init(indexPathRow: Int? = nil, previousCell: PlaybackCell?, currentCell: PlaybackCell?) {
self.indexPathRow = indexPathRow
self.prevCell = prevCell
self.curCell = curCell
self.previousCell = previousCell
self.currentCell = currentCell
}
}
}
Expand Down Expand Up @@ -121,12 +121,12 @@ enum PlaybackModels {

struct Response {
let willMoveLocation: Float64
let curCell: PlaybackCell
let currentCell: PlaybackCell
}

struct ViewModel {
let willMoveLocation: Float64
let curCell: PlaybackCell
let currentCell: PlaybackCell
}
}

Expand Down
Loading

0 comments on commit d2068f1

Please sign in to comment.