-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from boostcampwm2023/iOS/feat#115
feat: 동영상 선택, 편집 기능
- Loading branch information
Showing
17 changed files
with
559 additions
and
24 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
35 changes: 35 additions & 0 deletions
35
iOS/Layover/Layover/Scenes/EditVideo/EditVideoConfigurator.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,35 @@ | ||
// | ||
// EditVideoConfigurator.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/29. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
final class EditVideoConfigurator: Configurator { | ||
|
||
typealias ViewController = EditVideoViewController | ||
|
||
static let shared = EditVideoConfigurator() | ||
|
||
private init() { } | ||
|
||
func configure(_ viewController: ViewController) { | ||
let viewController = viewController | ||
let videoFileWorker = VideoFileWorker() | ||
let interactor = EditVideoInteractor() | ||
let presenter = EditVideoPresenter() | ||
let router = EditVideoRouter() | ||
|
||
router.viewController = viewController | ||
router.dataStore = interactor | ||
viewController.interactor = interactor | ||
viewController.router = router | ||
interactor.presenter = presenter | ||
interactor.videoFileWorker = videoFileWorker | ||
presenter.viewController = viewController | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
iOS/Layover/Layover/Scenes/EditVideo/EditVideoInteractor.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,54 @@ | ||
// | ||
// EditVideoInteractor.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/29. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import AVFoundation | ||
import UIKit | ||
|
||
protocol EditVideoBusinessLogic { | ||
func fetchVideo(request: EditVideoModels.FetchVideo.Request) | ||
func deleteVideo() | ||
} | ||
|
||
protocol EditVideoDataStore { | ||
var videoURL: URL? { get set } | ||
} | ||
|
||
final class EditVideoInteractor: EditVideoBusinessLogic, EditVideoDataStore { | ||
|
||
// MARK: - Properties | ||
|
||
typealias Models = EditVideoModels | ||
|
||
var videoFileWorker: VideoFileWorker? | ||
var presenter: EditVideoPresentationLogic? | ||
|
||
var videoURL: URL? | ||
|
||
func fetchVideo(request: EditVideoModels.FetchVideo.Request) { | ||
let isEdited = request.editedVideoURL != nil | ||
guard let videoURL = isEdited ? request.editedVideoURL : videoURL else { return } | ||
|
||
Task { | ||
let duration = try await AVAsset(url: videoURL).load(.duration) | ||
let seconds = CMTimeGetSeconds(duration) | ||
let response = Models.FetchVideo.Response(isEdited: isEdited, | ||
videoURL: videoURL, | ||
duration: seconds, | ||
isWithinRange: request.videoRange ~= seconds) | ||
await MainActor.run { | ||
presenter?.presentVideo(with: response) | ||
} | ||
} | ||
} | ||
|
||
func deleteVideo() { | ||
guard let videoURL else { return } | ||
videoFileWorker?.delete(at: videoURL) | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
iOS/Layover/Layover/Scenes/EditVideo/EditVideoModels.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,32 @@ | ||
// | ||
// EditVideoModels.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/29. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
enum EditVideoModels { | ||
|
||
enum FetchVideo { | ||
struct Request { | ||
var editedVideoURL: URL? | ||
var videoRange: ClosedRange<Double> = 3.0...60.0 | ||
} | ||
struct Response { | ||
let isEdited: Bool | ||
let videoURL: URL | ||
let duration: Double | ||
var isWithinRange: Bool | ||
} | ||
struct ViewModel { | ||
let isEdited: Bool | ||
let videoURL: URL | ||
let duration: Double | ||
let canNext: Bool | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
iOS/Layover/Layover/Scenes/EditVideo/EditVideoPresenter.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,29 @@ | ||
// | ||
// EditVideoPresenter.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/29. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol EditVideoPresentationLogic { | ||
func presentVideo(with response: EditVideoModels.FetchVideo.Response) | ||
} | ||
|
||
final class EditVideoPresenter: EditVideoPresentationLogic { | ||
|
||
// MARK: - Properties | ||
|
||
typealias Models = EditVideoModels | ||
weak var viewController: EditVideoDisplayLogic? | ||
|
||
func presentVideo(with response: EditVideoModels.FetchVideo.Response) { | ||
let viewModel = Models.FetchVideo.ViewModel(isEdited: response.isEdited, | ||
videoURL: response.videoURL, | ||
duration: response.duration, | ||
canNext: response.isWithinRange) | ||
viewController?.displayVideo(viewModel: viewModel) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
iOS/Layover/Layover/Scenes/EditVideo/EditVideoRouter.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,32 @@ | ||
// | ||
// EditVideoRouter.swift | ||
// Layover | ||
// | ||
// Created by kong on 2023/11/29. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol EditVideoRoutingLogic { | ||
func routeToNext() | ||
} | ||
|
||
protocol EditVideoDataPassing { | ||
var dataStore: EditVideoDataStore? { get } | ||
} | ||
|
||
final class EditVideoRouter: NSObject, EditVideoRoutingLogic, EditVideoDataPassing { | ||
|
||
// MARK: - Properties | ||
|
||
weak var viewController: EditVideoViewController? | ||
var dataStore: EditVideoDataStore? | ||
|
||
// MARK: - Routing | ||
|
||
func routeToNext() { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.