feat(chat-talk): 톡 목록 조회 API 연동 및 목록 UI 구성
This commit is contained in:
87
SodaLive/Sources/Chat/Talk/TalkItemView.swift
Normal file
87
SodaLive/Sources/Chat/Talk/TalkItemView.swift
Normal file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// TalkItemView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 8/29/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct TalkItemView: View {
|
||||
|
||||
let item: TalkRoom
|
||||
|
||||
@State private var backgroundColor = Color(hex: "009D68")
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 13) {
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.placeholder { Circle().fill(Color.gray.opacity(0.2)) }
|
||||
.retry(maxCount: 2, interval: .seconds(1))
|
||||
.cancelOnDisappear(true)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 76, height: 76)
|
||||
.clipShape(Circle())
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(spacing: 4) {
|
||||
Text(item.title)
|
||||
.font(.custom(Font.preBold.rawValue, size: 18))
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(item.opponentType)
|
||||
.font(.custom(Font.preRegular.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "D9FCF4"))
|
||||
.lineLimit(1)
|
||||
.padding(.horizontal, 5)
|
||||
.padding(.vertical, 1)
|
||||
.background(backgroundColor)
|
||||
.cornerRadius(6)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(item.lastMessageTimeLabel)
|
||||
.font(.custom(Font.preRegular.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "78909C"))
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
if let message = item.lastMessagePreview {
|
||||
Text(message)
|
||||
.font(.custom(Font.preRegular.rawValue, size: 14))
|
||||
.foregroundColor(Color(hex: "b0bec5"))
|
||||
.lineLimit(2)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
switch item.opponentType.lowercased() {
|
||||
case "clone":
|
||||
self.backgroundColor = Color(hex: "0020C9")
|
||||
|
||||
case "creator":
|
||||
self.backgroundColor = Color(hex: "F86660")
|
||||
|
||||
default:
|
||||
self.backgroundColor = Color(hex: "009D68")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
TalkItemView(
|
||||
item: TalkRoom(
|
||||
chatRoomId: 1,
|
||||
title: "정인이",
|
||||
imageUrl: "https://picsum.photos/200",
|
||||
opponentType: "Character",
|
||||
lastMessagePreview: "태풍온다잖아 ㅜㅜ\n조심해 어디 나가지 말고 집에만...",
|
||||
lastMessageTimeLabel: "6월 15일"
|
||||
)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user