Compare commits

..

2 Commits

Author SHA1 Message Date
2396a707ec fix back 2025-12-11 19:24:09 +03:00
904f0085e7 chat patch 2025-12-11 18:59:55 +03:00

View File

@ -61,20 +61,20 @@ struct PrivateChatView: View {
}
.navigationTitle(toolbarTitle)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
// .navigationBarBackButtonHidden(true)
// .toolbar {
// ToolbarItem(placement: .principal) {
// chatToolbarContent
// }
// }
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button(action: { dismiss() }) {
Image(systemName: "chevron.left")
.font(.system(size: 17, weight: .semibold))
.foregroundColor(.accentColor)
}
}
// ToolbarItem(placement: .navigationBarLeading) {
// Button(action: { dismiss() }) {
// Image(systemName: "chevron.left")
// .font(.system(size: 17, weight: .semibold))
// .foregroundColor(.accentColor)
// }
// }
ToolbarItem(placement: .principal) {
Button(action: openProfile) {
@ -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 {