fix top bar in msg

This commit is contained in:
cheykrym 2025-12-10 03:53:12 +03:00
parent f47181877e
commit 98de0eb313

View File

@ -21,6 +21,7 @@ struct PrivateChatView: View {
@State private var legacyComposerHeight: CGFloat = 40
@FocusState private var isComposerFocused: Bool
@EnvironmentObject private var messageCenter: IncomingMessageCenter
@Environment(\.dismiss) private var dismiss
init(chat: PrivateChatListItem, currentUserId: String?) {
self.chat = chat
@ -49,6 +50,7 @@ struct PrivateChatView: View {
}
.navigationTitle(toolbarTitle)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .principal) {
chatToolbarContent
@ -567,40 +569,55 @@ struct PrivateChatView: View {
private var chatToolbarContent: some View {
HStack(spacing: 12) {
backButton
VStack(alignment: .leading, spacing: 2) {
if let officialName = officialDisplayName {
HStack(spacing: 4) {
nameText(officialName, weight: .semibold)
Spacer(minLength: 0)
Image(systemName: "checkmark.seal.fill")
.foregroundColor(Color.accentColor)
.font(.caption)
}
} else {
nameText(title, weight: .semibold)
nameStatusView
Spacer(minLength: 0)
avatarView
}
.frame(maxWidth: .infinity, minHeight: headerAvatarSize, alignment: .center)
}
@ViewBuilder
private var nameStatusView: some View {
VStack(spacing: 2) {
if let officialName = officialDisplayName {
HStack(spacing: 4) {
nameText(officialName, weight: .semibold)
Image(systemName: "checkmark.seal.fill")
.foregroundColor(Color.accentColor)
.font(.caption)
}
Text(offlineStatusText)
.font(.caption)
.foregroundColor(.secondary)
}
if let url = avatarUrl,
let fileId = chat.chatData?.avatars?.current?.fileId,
let userId = currentUserId {
CachedAvatarView(url: url, fileId: fileId, userId: userId) {
headerPlaceholderAvatar
}
.aspectRatio(contentMode: .fill)
.frame(width: headerAvatarSize, height: headerAvatarSize)
.clipShape(Circle())
} else {
nameText(title, weight: .semibold)
}
Text(offlineStatusText)
.font(.caption)
.foregroundColor(.secondary)
}
.multilineTextAlignment(.center)
}
@ViewBuilder
private var avatarView: some View {
if let url = avatarUrl,
let fileId = chat.chatData?.avatars?.current?.fileId,
let userId = currentUserId {
CachedAvatarView(url: url, fileId: fileId, userId: userId) {
headerPlaceholderAvatar
}
.aspectRatio(contentMode: .fill)
.frame(width: headerAvatarSize, height: headerAvatarSize)
.clipShape(Circle())
} else {
headerPlaceholderAvatar
}
.frame(maxWidth: .infinity, alignment: .center)
}
private func nameText(_ text: String, weight: Font.Weight) -> some View {
@ -624,6 +641,16 @@ struct PrivateChatView: View {
}
}
private var backButton: some View {
Button(action: { dismiss() }) {
Image(systemName: "chevron.left")
.font(.system(size: 17, weight: .semibold))
.foregroundColor(.accentColor)
}
.frame(width: headerAvatarSize, height: headerAvatarSize)
.contentShape(Rectangle())
}
private var headerPlaceholderAvatar: some View {
Circle()
.fill(avatarBackgroundColor)