feat(main): 홈 대화 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-08 15:54:07 +09:00
parent 403eee262f
commit 09443761af
13 changed files with 938 additions and 23 deletions

View File

@@ -0,0 +1,89 @@
import SwiftUI
struct MainChatRoomListItem: View {
let room: MainChatRoomItem
let onTap: (Int, String) -> Void
var body: some View {
Button {
onTap(room.roomId, room.chatType)
} label: {
HStack(alignment: .center, spacing: SodaSpacing.s14) {
DownsampledKFImage(url: URL(string: room.targetImageUrl), size: CGSize(width: 58, height: 58))
.clipShape(Circle())
VStack(alignment: .leading, spacing: SodaSpacing.s12) {
HStack(alignment: .center, spacing: SodaSpacing.s6) {
Text(room.targetName)
.appFont(size: 18, weight: .bold)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
if room.isDirectMessage {
MainChatDirectTagView()
}
Spacer(minLength: SodaSpacing.s8)
Text(room.chatListDateText())
.appFont(size: 14, weight: .medium)
.foregroundColor(Color.gray500)
.lineLimit(1)
}
Text(room.lastMessage)
.appFont(size: 16, weight: .medium)
.foregroundColor(Color.gray500)
.lineLimit(1)
.truncationMode(.tail)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding(SodaSpacing.s14)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
}
}
private struct MainChatDirectTagView: View {
var body: some View {
Text(I18n.MainChat.directTag)
.appFont(size: 12, weight: .bold)
.italic()
.foregroundColor(.white)
.padding(.horizontal, SodaSpacing.s4)
.padding(.vertical, SodaSpacing.s4)
.background(Color.soda400)
.cornerRadius(4)
}
}
private extension MainChatRoomItem {
var isDirectMessage: Bool {
chatType == "DM"
}
func chatListDateText(now: Date = Date()) -> String {
DateParser.chatListDateText(fromUTC: lastMessageAt, fallback: lastMessageAt, now: now)
}
}
struct MainChatRoomListItem_Previews: PreviewProvider {
static var previews: some View {
MainChatRoomListItem(
room: MainChatRoomItem(
roomId: 1,
chatType: "DM",
targetName: "크리에이터 이름",
targetImageUrl: "https://picsum.photos/500/500",
lastMessage: "마지막 대화 내용이 들어가는 부분입니다. 한 줄 넘어가는경우 말줄임",
lastMessageAt: "2026-07-01T01:30:00Z"
),
onTap: { _, _ in }
)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}