Skip to content

Commit 8871285

Browse files
authored
Merge pull request #180 from boostcampwm-2024/fix/#175-hotfix-for-demo
[FIX/#175] 데모를 위한 일부 기능 오류 수정
2 parents 92b5e78 + e0926f1 commit 8871285

File tree

9 files changed

+113
-13
lines changed

9 files changed

+113
-13
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/DomainLayer/PhotoGetherDomain/PhotoGetherDomainInterface/Entity/UserInfo.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ public struct UserInfo: Identifiable, Equatable, Codable {
1616
case bottomTrailing
1717
case topTrailing
1818
case bottomLeading
19+
20+
public var color: UserColor {
21+
switch self {
22+
case .topLeading: return .orange
23+
case .bottomTrailing: return .brown
24+
case .topTrailing: return .blue
25+
case .bottomLeading: return .gray
26+
}
27+
}
1928
}
2029

2130
public init(
@@ -31,4 +40,11 @@ public struct UserInfo: Identifiable, Equatable, Codable {
3140
self.viewPosition = viewPosition
3241
self.roomID = roomID
3342
}
43+
44+
public enum UserColor: String, Codable {
45+
case orange = "#FF7561"
46+
case brown = "#E7C892"
47+
case blue = "#82BBE6"
48+
case gray = "#7D7C84"
49+
}
3450
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import UIKit
2+
3+
public extension UIColor {
4+
convenience init(hex: String) {
5+
let hexString = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
6+
var int = UInt64()
7+
Scanner(string: hexString).scanHexInt64(&int)
8+
9+
let red, green, blue, alpha: UInt64
10+
switch hexString.count {
11+
case 6: // 6자리 (RGB)
12+
(red, green, blue, alpha) = ((int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF, 0xFF)
13+
case 8: // 8자리 (RGBA)
14+
(red, green, blue, alpha) = ((int >> 24) & 0xFF, (int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF)
15+
default:
16+
(red, green, blue, alpha) = (0, 0, 0, 0xFF) // 유효하지 않은 경우 기본값
17+
}
18+
19+
self.init(
20+
red: CGFloat(red) / 255.0,
21+
green: CGFloat(green) / 255.0,
22+
blue: CGFloat(blue) / 255.0,
23+
alpha: CGFloat(alpha) / 255.0
24+
)
25+
}
26+
}

PhotoGether/PresentationLayer/EditPhotoRoomFeature/EditPhotoRoomFeature/Source/View/StickerView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,11 @@ final class StickerView: UIView {
206206

207207
if owner == user {
208208
layerView.layer.borderColor = PTGColor.primaryGreen.color.cgColor
209+
nicknameLabel.backgroundColor = PTGColor.primaryGreen.color
209210
} else {
210-
layerView.layer.borderColor = PTGColor.gray70.color.cgColor
211+
guard let hexColor = owner?.viewPosition.color.rawValue else { return }
212+
layerView.layer.borderColor = UIColor(hex: hexColor).cgColor
213+
nicknameLabel.backgroundColor = UIColor(hex: hexColor)
211214
}
212215
}
213216

PhotoGether/PresentationLayer/PhotoRoomFeature/PhotoRoomFeature/Source/View/PhotoRoomBottomView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ final class PhotoRoomBottomView: UIView {
5959
filterButton.imageView?.tintColor = isHost ? .white : PTGColor.gray85.color
6060

6161
switchCameraButton.setImage(PTGImage.switchIcon.image, for: .normal)
62+
63+
switchCameraButton.isHidden = true
64+
filterButton.isHidden = true
6265
}
6366

6467
func setCameraButtonTimer(_ count: Int) {
@@ -68,6 +71,10 @@ final class PhotoRoomBottomView: UIView {
6871
func stopCameraButtonTimer() {
6972
cameraButton.stopTimer()
7073
}
74+
75+
func highlightCameraButton() {
76+
cameraButton.layer.borderColor = PTGColor.primaryGreen.color.cgColor
77+
}
7178
}
7279

7380
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

PhotoGether/PresentationLayer/WaitingRoomFeature/WaitingRoomFeature/Source/View/WaitingRoomView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ final class WaitingRoomView: UIView {
3030
guard let title = StartButtonTitle(from: count) else { return }
3131
startButton.setTitle(to: title.rawValue)
3232
}
33+
34+
func enableStartButton() {
35+
self.startButton.isEnabled = true
36+
self.startButton.backgroundColor = PTGColor.primaryGreen.color
37+
}
3338
}
3439

3540
private extension WaitingRoomView {
@@ -81,6 +86,8 @@ private extension WaitingRoomView {
8186
func configureUI() {
8287
self.backgroundColor = PTGColor.gray90.color
8388
startButton.setTitle(to: "촬영시작")
89+
startButton.isEnabled = false
90+
startButton.backgroundColor = .gray
8491
}
8592
}
8693

PhotoGether/PresentationLayer/WaitingRoomFeature/WaitingRoomFeature/Source/ViewController/WaitingRoomViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public final class WaitingRoomViewController: BaseViewController {
112112
// MARK: 토스트 메시지 노출
113113
case .shouldShowToast(let message):
114114
self.showToast(message: message, duration: 3.0)
115+
116+
case .readyToStart:
117+
self.waitingRoomView.enableStartButton()
115118
}
116119
}.store(in: &cancellables)
117120
}

PhotoGether/PresentationLayer/WaitingRoomFeature/WaitingRoomFeature/Source/ViewModel/WaitingRoomViewModel.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public final class WaitingRoomViewModel {
1818
case shouldShowShareSheet(String)
1919
case navigateToPhotoRoom
2020
case shouldShowToast(String)
21+
case readyToStart
2122
}
2223

2324
private let sendOfferUseCase: SendOfferUseCase
@@ -28,6 +29,7 @@ public final class WaitingRoomViewModel {
2829
private let toggleLocalMicStateUseCase: ToggleLocalMicStateUseCase
2930

3031
private var isHost: Bool
32+
private var inviteLinkMessage: String?
3133
private var cancellables = Set<AnyCancellable>()
3234
private let output = PassthroughSubject<Output, Never>()
3335

@@ -130,15 +132,21 @@ public final class WaitingRoomViewModel {
130132
}
131133

132134
private func handleLinkButtonDidTap() {
135+
if let inviteLinkMessage {
136+
self.output.send(.shouldShowShareSheet(inviteLinkMessage))
137+
return
138+
}
133139
createRoomUseCase.execute()
134140
.receive(on: RunLoop.main)
135141
.sink(receiveCompletion: { [weak self] completion in
136142
if case let .failure(error) = completion {
137143
debugPrint(error.localizedDescription)
138144
self?.output.send(.shouldShowToast("Failed to create room"))
139145
}
140-
}, receiveValue: { [weak self] roomLink in
141-
self?.output.send(.shouldShowShareSheet(roomLink))
146+
}, receiveValue: { [weak self] inviteLinkMessage in
147+
self?.inviteLinkMessage = inviteLinkMessage
148+
self?.output.send(.shouldShowShareSheet(inviteLinkMessage))
149+
self?.output.send(.readyToStart)
142150
})
143151
.store(in: &cancellables)
144152
}

0 commit comments

Comments
 (0)