patch chats

This commit is contained in:
cheykrym 2025-10-06 05:42:08 +03:00
parent b8d22c814c
commit 851f5f2f3f
2 changed files with 117 additions and 4 deletions

View File

@ -23,6 +23,12 @@
} }
} }
} }
},
"Chat ID:" : {
},
"Companion ID:" : {
}, },
"Fun Fest" : { "Fun Fest" : {
"comment" : "Fun Fest", "comment" : "Fun Fest",
@ -79,6 +85,9 @@
}, },
"Активные сессии" : { "Активные сессии" : {
},
"Без звука (скоро)" : {
}, },
"Безопасность" : { "Безопасность" : {
@ -175,6 +184,9 @@
} }
} }
} }
},
"Закрепить (скоро)" : {
}, },
"Закрыть" : { "Закрыть" : {
"comment" : "Закрыть", "comment" : "Закрыть",
@ -385,6 +397,9 @@
}, },
"Неизвестная ошибка. Попробуйте позже." : { "Неизвестная ошибка. Попробуйте позже." : {
},
"Неизвестный" : {
}, },
"Неизвестный пользователь" : { "Неизвестный пользователь" : {
@ -551,6 +566,9 @@
}, },
"Уведомления" : { "Уведомления" : {
},
"Удалить чат (скоро)" : {
}, },
"Центр авторов" : { "Центр авторов" : {
"comment" : "Creator Center", "comment" : "Creator Center",
@ -565,6 +583,9 @@
}, },
"Частые вопросы" : { "Частые вопросы" : {
"comment" : "FAQ navigation title" "comment" : "FAQ navigation title"
},
"Чат" : {
}, },
"Чаты" : { "Чаты" : {
@ -582,6 +603,9 @@
}, },
"Черновики доступны в боковом меню в разделе Drafts." : { "Черновики доступны в боковом меню в разделе Drafts." : {
"comment" : "FAQ answer: drafts" "comment" : "FAQ answer: drafts"
},
"Экран чата в разработке" : {
}, },
"Язык" : { "Язык" : {

View File

@ -10,6 +10,7 @@ import SwiftUI
struct ChatsTab: View { struct ChatsTab: View {
var currentUserId: String? = nil var currentUserId: String? = nil
@StateObject private var viewModel = PrivateChatsViewModel() @StateObject private var viewModel = PrivateChatsViewModel()
@State private var selectedChatId: String?
var body: some View { var body: some View {
content content
@ -54,11 +55,39 @@ struct ChatsTab: View {
} }
ForEach(viewModel.chats) { chat in ForEach(viewModel.chats) { chat in
ChatRowView(chat: chat, currentUserId: currentUserId) Button {
.contentShape(Rectangle()) selectedChatId = chat.chatId
.onAppear { } label: {
viewModel.loadMoreIfNeeded(currentItem: chat) ChatRowView(chat: chat, currentUserId: currentUserId)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.contextMenu {
Button(action: {}) {
Label(NSLocalizedString("Закрепить (скоро)", comment: ""), systemImage: "pin")
} }
Button(action: {}) {
Label(NSLocalizedString("Без звука (скоро)", comment: ""), systemImage: "speaker.slash")
}
Button(role: .destructive, action: {}) {
Label(NSLocalizedString("Удалить чат (скоро)", comment: ""), systemImage: "trash")
}
}
.background(
NavigationLink(
destination: ChatPlaceholderView(chat: chat),
tag: chat.chatId,
selection: $selectedChatId
) {
EmptyView()
}
.hidden()
)
.onAppear {
viewModel.loadMoreIfNeeded(currentItem: chat)
}
} }
if viewModel.isLoadingMore { if viewModel.isLoadingMore {
@ -437,3 +466,63 @@ struct ChatsTab_Previews: PreviewProvider {
.environmentObject(ThemeManager()) .environmentObject(ThemeManager())
} }
} }
private struct ChatPlaceholderView: View {
let chat: PrivateChatListItem
private var companionId: String {
if let profileId = chat.chatData?.userId {
return profileId
}
if let senderId = chat.lastMessage?.senderId {
return senderId
}
return NSLocalizedString("Неизвестный", comment: "")
}
var body: some View {
VStack(spacing: 16) {
Text(NSLocalizedString("Экран чата в разработке", comment: ""))
.font(.headline)
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Chat ID:")
.font(.subheadline)
.foregroundColor(.secondary)
Text(chat.chatId)
.font(.body.monospaced())
}
if companionId != NSLocalizedString("Неизвестный", comment: "") {
HStack {
Text("Companion ID:")
.font(.subheadline)
.foregroundColor(.secondary)
Text(companionId)
.font(.body.monospaced())
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
}
.padding()
.navigationTitle(title)
.navigationBarTitleDisplayMode(.inline)
}
private var title: String {
if let full = chat.chatData?.fullName, !full.isEmpty {
return full
}
if let custom = chat.chatData?.customName, !custom.isEmpty {
return custom
}
if let login = chat.chatData?.login, !login.isEmpty {
return "@\(login)"
}
return NSLocalizedString("Чат", comment: "")
}
}