Compare commits
2 Commits
b1d9112806
...
2396a707ec
| Author | SHA1 | Date | |
|---|---|---|---|
| 2396a707ec | |||
| 904f0085e7 |
@ -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,6 +117,11 @@ 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 {
|
||||||
@ -154,10 +159,6 @@ struct PrivateChatView: View {
|
|||||||
isComposerFocused = false
|
isComposerFocused = false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.refreshable {
|
|
||||||
viewModel.refresh()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var emptyState: some View {
|
private var emptyState: some View {
|
||||||
@ -199,23 +200,26 @@ 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) }
|
||||||
|
|
||||||
VStack(alignment: isCurrentUser ? .trailing : .leading, spacing: 6) {
|
messageBubble(for: message, isCurrentUser: isCurrentUser)
|
||||||
// if !isCurrentUser {
|
|
||||||
// Text(senderName(for: message))
|
|
||||||
// .font(.caption)
|
|
||||||
// .foregroundColor(.secondary)
|
|
||||||
// }
|
|
||||||
|
|
||||||
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))
|
Text(contentText(for: message))
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.foregroundColor(isCurrentUser ? .white : .primary)
|
.foregroundColor(isCurrentUser ? .white : .primary)
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
|
|
||||||
Text(timestamp(for: message))
|
if !timeText.isEmpty {
|
||||||
|
Text(timeText)
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
.foregroundColor(isCurrentUser ? Color.white.opacity(0.8) : .secondary)
|
.foregroundColor(isCurrentUser ? Color.white.opacity(0.85) : .secondary)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
@ -224,10 +228,6 @@ 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 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user