Skip to content

Commit e0926f1

Browse files
Merge pull request #179 from boostcampwm-2024/fix/#177-sort-photos
[FIX/#177]์‚ฌ์ง„ ์ „๋‹ฌ๋˜๋Š” ์ˆœ์„œ ์ •๋ ฌํ•ด์„œ ๋ณด๋‚ด๊ธฐ
2 parents a46f6aa + 30b4174 commit e0926f1

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed
Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
11
import UIKit
22
import PhotoGetherDomainInterface
3-
import DesignSystem
43

54
public final class CaptureVideosUseCaseImpl: CaptureVideosUseCase {
65
public func execute() -> [UIImage] {
7-
guard let localImage = connectionRepository.capturedLocalVideo
8-
else { return [
9-
PTGImage.temp1.image,
10-
PTGImage.temp2.image,
11-
PTGImage.temp3.image,
12-
PTGImage.temp4.image]
13-
}
14-
let remoteImages = connectionRepository.clients.map { $0.captureVideo() }
6+
let localImage = connectionRepository.capturedLocalVideo ?? UIImage()
7+
8+
let localUserImageInfo = [(connectionRepository.localUserInfo?.viewPosition, localImage)]
9+
let remoteUserImagesInfo = connectionRepository.clients
10+
.map { ($0.remoteUserInfo?.viewPosition, $0.captureVideo()) }
1511

16-
return [localImage] + remoteImages
12+
return sortImages(localUserImageInfo + remoteUserImagesInfo)
1713
}
1814

1915
private let connectionRepository: ConnectionRepository
2016

2117
public init(connectionRepository: ConnectionRepository) {
2218
self.connectionRepository = connectionRepository
2319
}
20+
21+
private func sortImages(_ images: [(viewPosition: UserInfo.ViewPosition?, image: UIImage)]) -> [UIImage] {
22+
let convertedArray = images.map {
23+
(position: PositionOder(rawValue: $0.viewPosition?.rawValue ?? -1),
24+
image: $0.image)
25+
}
26+
27+
// ๋ฐฐ์—ด์˜ 2๋ฒˆ ์ธ๋ฑ์Šค๊ฐ€ ๋งˆ์ง€๋ง‰ ์ž๋ฆฌ์ด๊ธฐ ๋•Œ๋ฌธ์— nil์ผ ๊ฒฝ์šฐ 2๋กœ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค
28+
let sortedByViewPosition = convertedArray.sorted {
29+
let lhs = $0.position?.sequence ?? 2
30+
let rhs = $1.position?.sequence ?? 2
31+
return lhs < rhs
32+
}
33+
34+
return sortedByViewPosition.map { $0.image }
35+
}
36+
}
37+
38+
/// case์˜ ์ˆœ์„œ๋Š” ์ฐธ๊ฐ€์ž์˜ ์ฐธ๊ฐ€ ์ˆœ์„œ์— ๋”ฐ๋ฅธ ํ™”๋ฉด ๋ฐฐ์น˜์ด๊ณ  sequence๋Š” ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ ์ „๋‹ฌํ•  ๋•Œ์˜ ๋ฐฐ์—ด ์ˆœ์„œ์ž…๋‹ˆ๋‹ค
39+
private enum PositionOder: Int {
40+
case topLeading
41+
case bottomTrailing
42+
case topTrailing
43+
case bottomLeading
44+
45+
var sequence: Int {
46+
switch self {
47+
case .topLeading: 0
48+
case .topTrailing: 1
49+
case .bottomLeading: 2
50+
case .bottomTrailing: 3
51+
}
52+
}
2453
}

โ€ŽPhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swiftโ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ final class PhotoRoomBottomView: UIView {
7171
func stopCameraButtonTimer() {
7272
cameraButton.stopTimer()
7373
}
74+
75+
func highlightCameraButton() {
76+
cameraButton.layer.borderColor = PTGColor.primaryGreen.color.cgColor
77+
}
7478
}
7579

7680
extension PhotoRoomBottomView {

โ€ŽPhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/ViewController/PhotoRoomViewController.swiftโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public final class PhotoRoomViewController: BaseViewController, ViewControllerCo
137137
switch $0 {
138138
case .timer(let count):
139139
self.photoRoomBottomView.setCameraButtonTimer(count)
140+
self.photoRoomBottomView.highlightCameraButton()
140141
case .timerCompleted(let images, let userInfo):
141142
self.photoRoomBottomView.stopCameraButtonTimer()
142143

0 commit comments

Comments
ย (0)