diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index 74432c5..ab87397 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -214,6 +214,9 @@ } } }, + "Блокировка контакта \"%1$@\" появится позже." : { + "comment" : "Contacts block placeholder message" + }, "В чате пока нет сообщений." : { }, @@ -413,6 +416,9 @@ }, "Заблокированные пользователи" : { + }, + "Заблокировать контакт" : { + "comment" : "Contacts context action block" }, "Заблокируйте аккаунт, чтобы скрыть его сообщения и взаимодействия" : { @@ -544,6 +550,9 @@ }, "Избранные сообщения" : { + }, + "Изменение контакта \"%1$@\" появится позже." : { + "comment" : "Contacts edit placeholder message" }, "Изменение пароля" : { "localizations" : { @@ -555,6 +564,9 @@ } } }, + "Изменить контакт" : { + "comment" : "Contacts context action edit" + }, "Изображение" : { "comment" : "Image message placeholder" }, @@ -2240,9 +2252,15 @@ } } }, + "Удаление контакта \"%1$@\" появится позже." : { + "comment" : "Contacts delete placeholder message" + }, "Удалить из заблокированных?" : { "comment" : "Unblock confirmation title" }, + "Удалить контакт" : { + "comment" : "Contacts context action delete" + }, "Удалить чат (скоро)" : { "localizations" : { "en" : { diff --git a/yobble/Views/Tab/ChatsTab.swift b/yobble/Views/Tab/ChatsTab.swift index a73e505..37e5e73 100644 --- a/yobble/Views/Tab/ChatsTab.swift +++ b/yobble/Views/Tab/ChatsTab.swift @@ -462,7 +462,7 @@ struct ChatsTab: View { } .hidden() ) - .listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16)) + .listRowInsets(EdgeInsets(top: 4, leading: 16, bottom: 4, trailing: 16)) // .listRowSeparator(.hidden) .onAppear { guard !isSearching else { return } diff --git a/yobble/Views/Tab/ContactsTab.swift b/yobble/Views/Tab/ContactsTab.swift index a450fdf..5097022 100644 --- a/yobble/Views/Tab/ContactsTab.swift +++ b/yobble/Views/Tab/ContactsTab.swift @@ -20,15 +20,40 @@ struct ContactsTab: View { } else { ForEach(contacts) { contact in Button { - activeAlert = .info( - title: NSLocalizedString("Скоро", comment: "Contacts placeholder title"), - message: String(format: NSLocalizedString("Просмотр \"%1$@\" появится позже.", comment: "Contacts placeholder message"), contact.displayName) - ) + showContactPlaceholder(for: contact) } label: { ContactRow(contact: contact) .contentShape(Rectangle()) } .buttonStyle(.plain) + .contextMenu { + Button { + handleContactAction(.edit, for: contact) + } label: { + Label( + NSLocalizedString("Изменить контакт", comment: "Contacts context action edit"), + systemImage: "square.and.pencil" + ) + } + + Button { + handleContactAction(.block, for: contact) + } label: { + Label( + NSLocalizedString("Заблокировать контакт", comment: "Contacts context action block"), + systemImage: "hand.raised.fill" + ) + } + + Button(role: .destructive) { + handleContactAction(.delete, for: contact) + } label: { + Label( + NSLocalizedString("Удалить контакт", comment: "Contacts context action delete"), + systemImage: "trash" + ) + } + } .listRowInsets(EdgeInsets(top: 0, leading: 12, bottom: 0, trailing: 12)) } } @@ -128,6 +153,23 @@ struct ContactsTab: View { isLoading = false } + + private func showContactPlaceholder(for contact: Contact) { + activeAlert = .info( + title: NSLocalizedString("Скоро", comment: "Contacts placeholder title"), + message: String( + format: NSLocalizedString("Просмотр \"%1$@\" появится позже.", comment: "Contacts placeholder message"), + contact.displayName + ) + ) + } + + private func handleContactAction(_ action: ContactAction, for contact: Contact) { + activeAlert = .info( + title: NSLocalizedString("Скоро", comment: "Contacts placeholder title"), + message: action.placeholderMessage(for: contact) + ) + } } private struct ContactRow: View { @@ -254,3 +296,29 @@ private enum ContactsAlert: Identifiable { } } } + +private enum ContactAction { + case edit + case block + case delete + + func placeholderMessage(for contact: Contact) -> String { + switch self { + case .edit: + return String( + format: NSLocalizedString("Изменение контакта \"%1$@\" появится позже.", comment: "Contacts edit placeholder message"), + contact.displayName + ) + case .block: + return String( + format: NSLocalizedString("Блокировка контакта \"%1$@\" появится позже.", comment: "Contacts block placeholder message"), + contact.displayName + ) + case .delete: + return String( + format: NSLocalizedString("Удаление контакта \"%1$@\" появится позже.", comment: "Contacts delete placeholder message"), + contact.displayName + ) + } + } +}