feat(chat): 유저 크리에이터 DM을 추가한다

This commit is contained in:
Yu Sung
2026-07-12 04:48:17 +09:00
parent ce191539f2
commit 2dfff32ac1
23 changed files with 2410 additions and 6 deletions

View File

@@ -0,0 +1,115 @@
import SwiftUI
struct UserCreatorChatTextMessageItemView: View {
let message: UserCreatorChatDisplayMessage
@ViewBuilder
var body: some View {
if message.mine {
mineMessageRow
} else {
receivedMessageRow
}
}
private var mineMessageRow: some View {
HStack(alignment: .bottom, spacing: SodaSpacing.s6) {
Spacer(minLength: SodaSpacing.s48)
mineMessageMeta
messageBubble
}
.frame(maxWidth: .infinity, alignment: .trailing)
}
private var receivedMessageRow: some View {
HStack(alignment: .top, spacing: SodaSpacing.s6) {
senderProfileImage
VStack(alignment: .leading, spacing: SodaSpacing.s4) {
senderNickname
HStack(alignment: .bottom, spacing: SodaSpacing.s6) {
messageBubble
timeText
}
}
Spacer(minLength: SodaSpacing.s48)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
private var senderProfileImage: some View {
DownsampledKFImage(
url: URL(string: message.senderProfileImageUrl ?? ""),
size: CGSize(width: SodaSpacing.s32, height: SodaSpacing.s32)
)
.clipShape(Circle())
}
private var senderNickname: some View {
Text(message.senderNickname ?? "")
.appFont(size: 12, weight: .medium)
.foregroundColor(Color.gray400)
.lineLimit(1)
.truncationMode(.tail)
}
private var messageBubble: some View {
Text(message.textMessage ?? "")
.appFont(size: 14, weight: .regular)
.foregroundColor(.white)
.padding(.horizontal, SodaSpacing.s14)
.padding(.vertical, SodaSpacing.s12)
.background(message.mine ? Color.soda400 : Color.gray900)
.clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
}
private var mineMessageMeta: some View {
VStack(alignment: .trailing, spacing: SodaSpacing.s4) {
statusText
timeText
}
}
private var timeText: some View {
Text(formatTime(from: message.createdAt))
.appFont(size: 11, weight: .regular)
.foregroundColor(Color.gray500)
}
@ViewBuilder
private var statusText: some View {
switch message.status {
case .sent:
EmptyView()
case .pending:
Text(I18n.UserCreatorChat.sendingStatus)
.appFont(size: 11, weight: .regular)
.foregroundColor(Color.gray500)
case .failed:
Text(I18n.UserCreatorChat.failedStatus)
.appFont(size: 11, weight: .regular)
.foregroundColor(Color.red400)
}
}
private func formatTime(from timestamp: Int64) -> String {
let date = Date(timeIntervalSince1970: TimeInterval(timestamp / 1000))
return date.convertDateFormat(dateFormat: "a hh:mm")
}
}
struct UserCreatorChatTextMessageItemView_Previews: PreviewProvider {
static var previews: some View {
VStack(spacing: SodaSpacing.s16) {
UserCreatorChatTextMessageItemView(
message: UserCreatorChatDisplayMessage(
pendingText: "안녕하세요",
requestId: "preview",
createdAt: 0
)
)
}
.padding(SodaSpacing.s24)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}