84 lines
2.6 KiB
Swift
84 lines
2.6 KiB
Swift
//
|
|
// 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) {
|
|
DownsampledKFImage(
|
|
url: URL(string: item.imageUrl),
|
|
size: CGSize(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일"
|
|
)
|
|
)
|
|
}
|