chat patch
This commit is contained in:
parent
b1d9112806
commit
904f0085e7
@ -117,6 +117,11 @@ struct PrivateChatView: View {
|
||||
} else if let error = viewModel.errorMessage, viewModel.messages.isEmpty {
|
||||
errorView(message: error)
|
||||
} else {
|
||||
messagesList
|
||||
}
|
||||
}
|
||||
|
||||
private var messagesList: some View {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 12) {
|
||||
if viewModel.isLoadingMore {
|
||||
@ -154,10 +159,6 @@ struct PrivateChatView: View {
|
||||
isComposerFocused = false
|
||||
}
|
||||
)
|
||||
.refreshable {
|
||||
viewModel.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
@ -199,23 +200,26 @@ struct PrivateChatView: View {
|
||||
return HStack(alignment: .bottom, spacing: 12) {
|
||||
if isCurrentUser { Spacer(minLength: 32) }
|
||||
|
||||
VStack(alignment: isCurrentUser ? .trailing : .leading, spacing: 6) {
|
||||
// if !isCurrentUser {
|
||||
// Text(senderName(for: message))
|
||||
// .font(.caption)
|
||||
// .foregroundColor(.secondary)
|
||||
// }
|
||||
messageBubble(for: message, isCurrentUser: isCurrentUser)
|
||||
|
||||
HStack(alignment: .bottom) {
|
||||
if !isCurrentUser { Spacer(minLength: 32) }
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
private func messageBubble(for message: MessageItem, isCurrentUser: Bool) -> some View {
|
||||
let timeText = timestamp(for: message)
|
||||
|
||||
return VStack(alignment: isCurrentUser ? .trailing : .leading, spacing: 4) {
|
||||
Text(contentText(for: message))
|
||||
.font(.body)
|
||||
.foregroundColor(isCurrentUser ? .white : .primary)
|
||||
.multilineTextAlignment(.leading)
|
||||
|
||||
Text(timestamp(for: message))
|
||||
if !timeText.isEmpty {
|
||||
Text(timeText)
|
||||
.font(.caption2)
|
||||
.foregroundColor(isCurrentUser ? Color.white.opacity(0.8) : .secondary)
|
||||
|
||||
.foregroundColor(isCurrentUser ? Color.white.opacity(0.85) : .secondary)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 10)
|
||||
@ -224,10 +228,6 @@ struct PrivateChatView: View {
|
||||
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
|
||||
.frame(maxWidth: messageBubbleMaxWidth, alignment: isCurrentUser ? .trailing : .leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
if !isCurrentUser { Spacer(minLength: 32) }
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
private var messageBubbleMaxWidth: CGFloat {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user