diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index cabc4b4..e75211a 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -23,6 +23,12 @@ } } } + }, + "Chat ID:" : { + + }, + "Companion ID:" : { + }, "Fun Fest" : { "comment" : "Fun Fest", @@ -79,6 +85,9 @@ }, "Активные сессии" : { + }, + "Без звука (скоро)" : { + }, "Безопасность" : { @@ -175,6 +184,9 @@ } } } + }, + "Закрепить (скоро)" : { + }, "Закрыть" : { "comment" : "Закрыть", @@ -385,6 +397,9 @@ }, "Неизвестная ошибка. Попробуйте позже." : { + }, + "Неизвестный" : { + }, "Неизвестный пользователь" : { @@ -551,6 +566,9 @@ }, "Уведомления" : { + }, + "Удалить чат (скоро)" : { + }, "Центр авторов" : { "comment" : "Creator Center", @@ -565,6 +583,9 @@ }, "Частые вопросы" : { "comment" : "FAQ navigation title" + }, + "Чат" : { + }, "Чаты" : { @@ -582,6 +603,9 @@ }, "Черновики доступны в боковом меню в разделе Drafts." : { "comment" : "FAQ answer: drafts" + }, + "Экран чата в разработке" : { + }, "Язык" : { diff --git a/yobble/Views/Tab/ChatsTab.swift b/yobble/Views/Tab/ChatsTab.swift index 398aa7e..c2f8b3f 100644 --- a/yobble/Views/Tab/ChatsTab.swift +++ b/yobble/Views/Tab/ChatsTab.swift @@ -10,6 +10,7 @@ import SwiftUI struct ChatsTab: View { var currentUserId: String? = nil @StateObject private var viewModel = PrivateChatsViewModel() + @State private var selectedChatId: String? var body: some View { content @@ -54,11 +55,39 @@ struct ChatsTab: View { } ForEach(viewModel.chats) { chat in - ChatRowView(chat: chat, currentUserId: currentUserId) - .contentShape(Rectangle()) - .onAppear { - viewModel.loadMoreIfNeeded(currentItem: chat) + Button { + selectedChatId = chat.chatId + } label: { + 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 { @@ -437,3 +466,63 @@ struct ChatsTab_Previews: PreviewProvider { .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: "") + } +}