diff --git a/PhotoGether/DomainLayer/PhotoGetherDomain/PhotoGetherDomain/UseCaseImpl/CaptureVideosUseCaseImpl.swift b/PhotoGether/DomainLayer/PhotoGetherDomain/PhotoGetherDomain/UseCaseImpl/CaptureVideosUseCaseImpl.swift index 8be35bff..1e845b80 100644 --- a/PhotoGether/DomainLayer/PhotoGetherDomain/PhotoGetherDomain/UseCaseImpl/CaptureVideosUseCaseImpl.swift +++ b/PhotoGether/DomainLayer/PhotoGetherDomain/PhotoGetherDomain/UseCaseImpl/CaptureVideosUseCaseImpl.swift @@ -1,19 +1,15 @@ import UIKit import PhotoGetherDomainInterface -import DesignSystem public final class CaptureVideosUseCaseImpl: CaptureVideosUseCase { public func execute() -> [UIImage] { - guard let localImage = connectionRepository.capturedLocalVideo - else { return [ - PTGImage.temp1.image, - PTGImage.temp2.image, - PTGImage.temp3.image, - PTGImage.temp4.image] - } - let remoteImages = connectionRepository.clients.map { $0.captureVideo() } + let localImage = connectionRepository.capturedLocalVideo ?? UIImage() + + let localUserImageInfo = [(connectionRepository.localUserInfo?.viewPosition, localImage)] + let remoteUserImagesInfo = connectionRepository.clients + .map { ($0.remoteUserInfo?.viewPosition, $0.captureVideo()) } - return [localImage] + remoteImages + return sortImages(localUserImageInfo + remoteUserImagesInfo) } private let connectionRepository: ConnectionRepository @@ -21,4 +17,37 @@ public final class CaptureVideosUseCaseImpl: CaptureVideosUseCase { public init(connectionRepository: ConnectionRepository) { self.connectionRepository = connectionRepository } + + private func sortImages(_ images: [(viewPosition: UserInfo.ViewPosition?, image: UIImage)]) -> [UIImage] { + let convertedArray = images.map { + (position: PositionOder(rawValue: $0.viewPosition?.rawValue ?? -1), + image: $0.image) + } + + // 배열의 2번 인덱스가 마지막 자리이기 때문에 nil일 경우 2로 설정했습니다 + let sortedByViewPosition = convertedArray.sorted { + let lhs = $0.position?.sequence ?? 2 + let rhs = $1.position?.sequence ?? 2 + return lhs < rhs + } + + return sortedByViewPosition.map { $0.image } + } +} + +/// case의 순서는 참가자의 참가 순서에 따른 화면 배치이고 sequence는 이미지 데이터 전달할 때의 배열 순서입니다 +private enum PositionOder: Int { + case topLeading + case bottomTrailing + case topTrailing + case bottomLeading + + var sequence: Int { + switch self { + case .topLeading: 0 + case .topTrailing: 1 + case .bottomLeading: 2 + case .bottomTrailing: 3 + } + } } diff --git a/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swift b/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swift index e5fa1632..1430f4a4 100644 --- a/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swift +++ b/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swift @@ -68,6 +68,10 @@ final class PhotoRoomBottomView: UIView { func stopCameraButtonTimer() { cameraButton.stopTimer() } + + func highlightCameraButton() { + cameraButton.layer.borderColor = PTGColor.primaryGreen.color.cgColor + } } extension PhotoRoomBottomView { diff --git a/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/ViewController/PhotoRoomViewController.swift b/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/ViewController/PhotoRoomViewController.swift index 0c216c46..c677856d 100644 --- a/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/ViewController/PhotoRoomViewController.swift +++ b/PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/ViewController/PhotoRoomViewController.swift @@ -120,6 +120,7 @@ public final class PhotoRoomViewController: BaseViewController, ViewControllerCo switch $0 { case .timer(let count): self.photoRoomBottomView.setCameraButtonTimer(count) + self.photoRoomBottomView.highlightCameraButton() case .timerCompleted(let images, let userInfo): self.photoRoomBottomView.stopCameraButtonTimer()