-
Notifications
You must be signed in to change notification settings - Fork 2
[FIX/#177]사진 전달되는 순서 정렬해서 보내기 #179
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b1bda5
fix/#177 :: 사진 전달되는 순서 정렬해서 보내기
Kiyoung-Kim-57 4568f23
chore/#177 :: localImage nil일 경우 빈 UIImage 전달하도록 변경
Kiyoung-Kim-57 6b6d7f4
chore/#177 :: 불필요한 모듈 import 제거
Kiyoung-Kim-57 efea361
chore/#177 :: 주석 description으로 변경
Kiyoung-Kim-57 253f8b8
fix/#177 :: 사진 촬영 때 카메라 하이라이트
Kiyoung-Kim-57 30b4174
Merge branch 'fix/#177-sort-photos' of https://github.com/boostcampwm…
Kiyoung-Kim-57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 39 additions & 10 deletions
49
...omainLayer/PhotoGetherDomain/PhotoGetherDomain/UseCaseImpl/CaptureVideosUseCaseImpl.swift
This file contains hidden or 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 |
|---|---|---|
| @@ -1,24 +1,53 @@ | ||
| 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 | ||
|
|
||
| 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 | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
디자인 시스템 의존성이 있을텐데 지워주시면 좋을것 같습니다 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6b6d7f4 오 감사합니다!!! 수정했습니다!