Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 재생화면 VIP 싸이클 적용 #160

Merged
merged 19 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
835A61A62B0B4DDD002F22A5 /* Dashboard-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 835A61A52B0B4DDD002F22A5 /* Dashboard-Regular.ttf */; };
835A61A92B0B5A31002F22A5 /* LoginConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835A61A82B0B5A31002F22A5 /* LoginConfigurator.swift */; };
836C33872B15A29600ECAFB0 /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C33862B15A29600ECAFB0 /* Toast.swift */; };
836C338B2B15D22C00ECAFB0 /* PlaybackConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C338A2B15D22C00ECAFB0 /* PlaybackConfigurator.swift */; };
836C338D2B15D91F00ECAFB0 /* VideoDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C338C2B15D91F00ECAFB0 /* VideoDTO.swift */; };
836C338F2B160CC700ECAFB0 /* MemberDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C338E2B160CC700ECAFB0 /* MemberDTO.swift */; };
836C33912B17629400ECAFB0 /* MapRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C33902B17629400ECAFB0 /* MapRouter.swift */; };
83C35E1B2B108C3500D8DD5C /* PlaybackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */; };
83C35E1E2B10923C00D8DD5C /* PlaybackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C35E1D2B10923C00D8DD5C /* PlaybackCell.swift */; };
FC2511A02B045C0A004717BC /* SignUpInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC25119F2B045C0A004717BC /* SignUpInteractor.swift */; };
Expand Down Expand Up @@ -234,6 +238,10 @@
835A61A82B0B5A31002F22A5 /* LoginConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginConfigurator.swift; sourceTree = "<group>"; };
835A61AA2B0B85FD002F22A5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
836C33862B15A29600ECAFB0 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = "<group>"; };
836C338A2B15D22C00ECAFB0 /* PlaybackConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackConfigurator.swift; sourceTree = "<group>"; };
836C338C2B15D91F00ECAFB0 /* VideoDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoDTO.swift; sourceTree = "<group>"; };
836C338E2B160CC700ECAFB0 /* MemberDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemberDTO.swift; sourceTree = "<group>"; };
836C33902B17629400ECAFB0 /* MapRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapRouter.swift; sourceTree = "<group>"; };
83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackView.swift; sourceTree = "<group>"; };
83C35E1D2B10923C00D8DD5C /* PlaybackCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackCell.swift; sourceTree = "<group>"; };
FC25119F2B045C0A004717BC /* SignUpInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpInteractor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -450,6 +458,8 @@
19A169372B17BCA800DB34C0 /* PostDTO.swift */,
19A169392B17BCC400DB34C0 /* MemberDTO.swift */,
19A1693B2B17BD1C00DB34C0 /* BoardDTO.swift */,
836C338C2B15D91F00ECAFB0 /* VideoDTO.swift */,
836C338E2B160CC700ECAFB0 /* MemberDTO.swift */,
);
path = DTOs;
sourceTree = "<group>";
Expand Down Expand Up @@ -511,6 +521,7 @@
835A619B2B068115002F22A5 /* PlaybackViewController.swift */,
835A619C2B068115002F22A5 /* PlaybackInteractor.swift */,
83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */,
836C338A2B15D22C00ECAFB0 /* PlaybackConfigurator.swift */,
);
path = Playback;
sourceTree = "<group>";
Expand All @@ -533,6 +544,7 @@
FC2511AA2B04EA6B004717BC /* MapConfigurator.swift */,
FC2511B02B04EAEC004717BC /* MapModels.swift */,
FC767FA92B126D080088CF9B /* LOAnnotation.swift */,
836C33902B17629400ECAFB0 /* MapRouter.swift */,
);
path = Map;
sourceTree = "<group>";
Expand Down Expand Up @@ -947,6 +959,7 @@
FC930E7C2B0CD80800AA48E3 /* ProfileConfigurator.swift in Sources */,
FC2511A62B049020004717BC /* SignUpConfigurator.swift in Sources */,
194552392B05230E00299768 /* HomeCarouselCollectionViewCell.swift in Sources */,
836C338F2B160CC700ECAFB0 /* MemberDTO.swift in Sources */,
FC767FAA2B126D080088CF9B /* LOAnnotation.swift in Sources */,
19A169472B17D12500DB34C0 /* MockTagPlayListWorker.swift in Sources */,
193686722B15BCA7008902CD /* UserEndPointFactory.swift in Sources */,
Expand Down Expand Up @@ -982,6 +995,7 @@
1972CCD82B13A2EC00C3C762 /* SignUpEndPointFactory.swift in Sources */,
19A169262B176C5F00DB34C0 /* TagPlayListModels.swift in Sources */,
FC767F842B1214A80088CF9B /* MockUserWorker.swift in Sources */,
836C338B2B15D22C00ECAFB0 /* PlaybackConfigurator.swift in Sources */,
FC930E782B0CD75C00AA48E3 /* ProfileModels.swift in Sources */,
FC68E29B2B02325D001AABFF /* Requestable.swift in Sources */,
FC2511A22B045C3F004717BC /* SignUpPresenter.swift in Sources */,
Expand All @@ -990,12 +1004,14 @@
FC68E29D2B02326A001AABFF /* Responsable.swift in Sources */,
FC2511A02B045C0A004717BC /* SignUpInteractor.swift in Sources */,
FC767F862B1214C10088CF9B /* CheckUserNameDTO.swift in Sources */,
836C338D2B15D91F00ECAFB0 /* VideoDTO.swift in Sources */,
FC5BE1232B1490660036366D /* EditProfileConfigurator.swift in Sources */,
1945522A2B04883800299768 /* UIView+.swift in Sources */,
FCE52FFA2B0FCB0A002CDB75 /* URLSession+.swift in Sources */,
19743C052B06940D001E405A /* PlayerView.swift in Sources */,
83C35E1B2B108C3500D8DD5C /* PlaybackView.swift in Sources */,
835A61A02B068115002F22A5 /* PlaybackModels.swift in Sources */,
836C33912B17629400ECAFB0 /* MapRouter.swift in Sources */,
19C7AFCE2B02410F003B35F2 /* AuthManager.swift in Sources */,
FC9BB82C2B094E5500EB72A9 /* UICollectionViewLayout+.swift in Sources */,
194552232B0478B400299768 /* HomeRouter.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Models/Board.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct Board {
struct Board: Hashable {
let identifier: Int
let title: String
let description: String?
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Models/Member.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct Member {
struct Member: Hashable {
let identifier: Int
let username: String
let introduce: String
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Models/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct Post {
struct Post: Hashable {
let member: Member
let board: Board
let tag: [String]
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Network/DTOs/MemberDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct MemberDTO: Decodable {
struct MemberDTO: Codable {
let id: Int
let username, introduce: String
let profileImageURL: String
Expand Down
26 changes: 26 additions & 0 deletions iOS/Layover/Layover/Network/DTOs/VideoDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// VideoDTO.swift
// Layover
//
// Created by 황지웅 on 11/28/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//

import Foundation

struct VideoDTO: Codable {
let title: String
let content: String
let location: String
let tags: [String]
// TODO: 프로필 완성되면 변경
let member: MemberDTO
let sdURL: URL
let hdURL: URL

enum CodingKeys: String, CodingKey {
case title, content, location, tags, member
case sdURL = "sd_url"
case hdURL = "hd_url"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ final class HomeCarouselCollectionViewCell: UICollectionViewCell {
loopingPlayerView.isPlaying
}

// 다른 방법도 많이 알려주세요
var moveToPlaybackSceneCallback: (() -> Void) = { }

// MARK: - Object lifecycle

override init(frame: CGRect) {
Expand Down Expand Up @@ -117,4 +120,14 @@ final class HomeCarouselCollectionViewCell: UICollectionViewCell {
func pauseVideo() {
loopingPlayerView.pause()
}

func addLoopingViewGesture() {
let loopingViewGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(moveToPlaybackScene))
loopingPlayerView.addGestureRecognizer(loopingViewGesture)
}

@objc func moveToPlaybackScene() {
moveToPlaybackSceneCallback()
loopingPlayerView.pause()
}
}
2 changes: 2 additions & 0 deletions iOS/Layover/Layover/Scenes/Home/HomeConfigurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ final class HomeConfigurator: Configurator {
interactor.videoFileWorker = videoFileWorker
viewController.router = router
viewController.interactor = interactor

router.dataStore = interactor
}
}
14 changes: 13 additions & 1 deletion iOS/Layover/Layover/Scenes/Home/HomeInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import UIKit

protocol HomeBusinessLogic {
func fetchVideos(with: HomeModels.CarouselVideos.Request)
func moveToPlaybackScene(with: HomeModels.MoveToPlaybackScene.Request)
func selectVideo(with request: HomeModels.SelectVideo.Request)
}

protocol HomeDataStore {
var videos: [Post]? { get set }
var index: Int? { get set }
var selectedVideoURL: URL? { get set }
}

Expand All @@ -26,12 +29,15 @@ final class HomeInteractor: HomeDataStore {
var videoFileWorker: VideoFileWorkerProtocol?
var presenter: HomePresentationLogic?

var videos: [Post]?

var index: Int?

var selectedVideoURL: URL?

func selectVideo(with request: Models.SelectVideo.Request) {
selectedVideoURL = videoFileWorker?.copyToNewURL(at: request.videoURL)
}

}

// MARK: - Use Case
Expand All @@ -47,4 +53,10 @@ extension HomeInteractor: HomeBusinessLogic {
])
presenter?.presentVideoURL(with: response)
}

func moveToPlaybackScene(with request: Models.MoveToPlaybackScene.Request) {
videos = request.videos
index = request.index
presenter?.presentPlaybackScene()
}
}
17 changes: 17 additions & 0 deletions iOS/Layover/Layover/Scenes/Home/HomeModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,21 @@ enum HomeModels {

}
}

enum MoveToPlaybackScene {
struct Request {
let index: Int
let videos: [Post]
}

struct Response {
let index: Int
let videos: [Post]
}

struct ViewModel {
let index: Int
let videos: [Post]
}
}
}
7 changes: 7 additions & 0 deletions iOS/Layover/Layover/Scenes/Home/HomePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit

protocol HomePresentationLogic {
func presentVideoURL(with response: HomeModels.CarouselVideos.Response)
func presentPlaybackScene()
}

final class HomePresenter: HomePresentationLogic {
Expand All @@ -25,4 +26,10 @@ final class HomePresenter: HomePresentationLogic {
let viewModel = HomeModels.CarouselVideos.ViewModel(videoURLs: response.videoURLs)
viewController?.displayVideoURLs(with: viewModel)
}

// MARK: - UseCase Present PlaybackScene

func presentPlaybackScene() {
viewController?.routeToPlayback()
}
}
18 changes: 17 additions & 1 deletion iOS/Layover/Layover/Scenes/Home/HomeRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import UIKit
protocol HomeRoutingLogic {
func routeToNext()
func routeToEditVideo()
func routeToPlayback()
}

protocol HomeDataPassing {
var dataStore: HomeDataStore? { get }
}

class HomeRouter: NSObject, HomeRoutingLogic, HomeDataPassing {
final class HomeRouter: NSObject, HomeRoutingLogic, HomeDataPassing {

// MARK: - Properties

Expand All @@ -31,6 +32,16 @@ class HomeRouter: NSObject, HomeRoutingLogic, HomeDataPassing {
viewController?.navigationController?.setViewControllers([nextViewController], animated: true)
}

func routeToPlayback() {
let playbackViewController: PlaybackViewController = PlaybackViewController()
guard let source = dataStore,
let destination = playbackViewController.router?.dataStore
else { return }
destination.parentView = .home
destination.index = source.index
destination.videos = transData(videos: source.videos ?? [])
viewController?.navigationController?.pushViewController(playbackViewController, animated: true)
}
func routeToEditVideo() {
let nextViewController = EditVideoViewController()
guard let source = dataStore,
Expand All @@ -44,6 +55,11 @@ class HomeRouter: NSObject, HomeRoutingLogic, HomeDataPassing {
viewController?.navigationController?.pushViewController(nextViewController, animated: true)
}

private func transData(videos: [Post]) -> [PlaybackModels.PlaybackVideo] {
videos.map { video in
return PlaybackModels.PlaybackVideo(post: video)
}
}
// MARK: - Data Passing

// func passDataTo(_ destinationDS: inout NextDataStore, from sourceDS: HomeDataStore) {
Expand Down
63 changes: 63 additions & 0 deletions iOS/Layover/Layover/Scenes/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit

protocol HomeDisplayLogic: AnyObject {
func displayVideoURLs(with viewModel: HomeModels.CarouselVideos.ViewModel)
func routeToPlayback()
}

final class HomeViewController: BaseViewController {
Expand Down Expand Up @@ -57,6 +58,64 @@ final class HomeViewController: BaseViewController {
for: indexPath) as? HomeCarouselCollectionViewCell else { return UICollectionViewCell() }
cell.setVideo(url: url, loopingAt: .zero)
cell.configure(title: "요리왕 비룡 데뷔", tags: ["#천상의맛", "#갈갈갈", "#빨리주세요"])
cell.moveToPlaybackSceneCallback = {
self.interactor?.moveToPlaybackScene(
with: Models.MoveToPlaybackScene.Request(
index: indexPath.row,
videos: [
Post(
member: Member(
identifier: 1,
username: "찹모찌",
introduce: "찹모찌데스",
profileImageURL: URL(string: "https://i.ibb.co/qML8vdN/2023-11-25-9-08-01.png")!),
board: Board(
identifier: 1,
title: "찹찹찹",
description: "찹모찌의 뜻은 뭘까?",
thumbnailImageURL: nil,
videoURL: URL(string: "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/m3u8s/11331.m3u8")!,
latitude: nil,
longitude: nil),
tag: ["찹", "모", "찌"]
),
Post(
member: Member(
identifier: 2,
username: "로인설",
introduce: "로인설데스",
profileImageURL: URL(string: "https://i.ibb.co/qML8vdN/2023-11-25-9-08-01.png")!),
board: Board(
identifier: 2,
title: "설설설",
description: "로인설의 뜻은 뭘까?",
thumbnailImageURL: nil,
videoURL: URL(string: "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/m3u8s/11331.m3u8")!,
latitude: nil,
longitude: nil),
tag: ["로", "인", "설"]
),
Post(
member: Member(
identifier: 3,
username: "콩콩콩",
introduce: "콩콩콩데스",
profileImageURL: URL(string: "https://i.ibb.co/qML8vdN/2023-11-25-9-08-01.png")!),
board: Board(
identifier: 1,
title: "콩콩콩",
description: "콩콩콩의 뜻은 뭘까?",
thumbnailImageURL: nil,
videoURL: URL(string: "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/m3u8s/11331.m3u8")!,
latitude: nil,
longitude: nil),
tag: ["콩", "콩", "콩"]
)
]
)
)
}
cell.addLoopingViewGesture()
return cell
}

Expand Down Expand Up @@ -223,4 +282,8 @@ extension HomeViewController: HomeDisplayLogic {
self.playVideoAtCenterCell()
}
}

func routeToPlayback() {
router?.routeToPlayback()
}
}
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Scenes/Login/LoginRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class LoginRouter: LoginRoutingLogic, LoginDataPassing {
func navigateToAppleSignUp() {
let signUpViewController = SignUpViewController()
guard let source = dataStore,
var destination = signUpViewController.router?.dataStore
let destination = signUpViewController.router?.dataStore
else { return }

destination.signUpType = .apple
Expand Down
Loading