Skip to content

Commit a46f6aa

Browse files
Merge pull request #178 from boostcampwm-2024/fix/#176-user-color
[�FEAT/#176] 유저 컬러를 추가해줬습니다
2 parents ba48609 + f8089da commit a46f6aa

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

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

0 commit comments

Comments
 (0)