Compare commits

..

No commits in common. "2396a707ec4c52490982cd375b30622382e1b9b3" and "b1d91128063c1c53145952f56f958f37ad019a2e" have entirely different histories.

View File

@ -61,20 +61,20 @@ struct PrivateChatView: View {
} }
.navigationTitle(toolbarTitle) .navigationTitle(toolbarTitle)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
// .navigationBarBackButtonHidden(true) .navigationBarBackButtonHidden(true)
// .toolbar { // .toolbar {
// ToolbarItem(placement: .principal) { // ToolbarItem(placement: .principal) {
// chatToolbarContent // chatToolbarContent
// } // }
// } // }
.toolbar { .toolbar {
// ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
// Button(action: { dismiss() }) { Button(action: { dismiss() }) {
// Image(systemName: "chevron.left") Image(systemName: "chevron.left")
// .font(.system(size: 17, weight: .semibold)) .font(.system(size: 17, weight: .semibold))
// .foregroundColor(.accentColor) .foregroundColor(.accentColor)
// } }
// } }
ToolbarItem(placement: .principal) { ToolbarItem(placement: .principal) {
Button(action: openProfile) { Button(action: openProfile) {
@ -117,11 +117,6 @@ struct PrivateChatView: View {
} else if let error = viewModel.errorMessage, viewModel.messages.isEmpty { } else if let error = viewModel.errorMessage, viewModel.messages.isEmpty {
errorView(message: error) errorView(message: error)
} else { } else {
messagesList
}
}
private var messagesList: some View {
ScrollView { ScrollView {
LazyVStack(alignment: .leading, spacing: 12) { LazyVStack(alignment: .leading, spacing: 12) {
if viewModel.isLoadingMore { if viewModel.isLoadingMore {
@ -159,6 +154,10 @@ struct PrivateChatView: View {
isComposerFocused = false isComposerFocused = false
} }
) )
.refreshable {
viewModel.refresh()
}
}
} }
private var emptyState: some View { private var emptyState: some View {
@ -200,26 +199,23 @@ struct PrivateChatView: View {
return HStack(alignment: .bottom, spacing: 12) { return HStack(alignment: .bottom, spacing: 12) {
if isCurrentUser { Spacer(minLength: 32) } if isCurrentUser { Spacer(minLength: 32) }
messageBubble(for: message, isCurrentUser: isCurrentUser) VStack(alignment: isCurrentUser ? .trailing : .leading, spacing: 6) {
// if !isCurrentUser {
// Text(senderName(for: message))
// .font(.caption)
// .foregroundColor(.secondary)
// }
if !isCurrentUser { Spacer(minLength: 32) } HStack(alignment: .bottom) {
}
.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)) Text(contentText(for: message))
.font(.body) .font(.body)
.foregroundColor(isCurrentUser ? .white : .primary) .foregroundColor(isCurrentUser ? .white : .primary)
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
if !timeText.isEmpty { Text(timestamp(for: message))
Text(timeText)
.font(.caption2) .font(.caption2)
.foregroundColor(isCurrentUser ? Color.white.opacity(0.85) : .secondary) .foregroundColor(isCurrentUser ? Color.white.opacity(0.8) : .secondary)
} }
} }
.padding(.vertical, 10) .padding(.vertical, 10)
@ -228,6 +224,10 @@ struct PrivateChatView: View {
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
.frame(maxWidth: messageBubbleMaxWidth, alignment: isCurrentUser ? .trailing : .leading) .frame(maxWidth: messageBubbleMaxWidth, alignment: isCurrentUser ? .trailing : .leading)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
if !isCurrentUser { Spacer(minLength: 32) }
}
.padding(.horizontal, 16)
} }
private var messageBubbleMaxWidth: CGFloat { private var messageBubbleMaxWidth: CGFloat {