From f5009157ca623563ca4f2199f9ae12c13d5a49db Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 11 Dec 2025 03:48:04 +0300 Subject: [PATCH] patch edit screen --- yobble/Resources/Localizable.xcstrings | 13 +++++++++- yobble/Views/Contacts/ContactEditView.swift | 27 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index e016220..4a65c94 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -2984,11 +2984,22 @@ "Удаление контакта \"%1$@\" появится позже." : { "comment" : "Contacts delete placeholder message" }, + "Удаление контакта появится позже." : { + "comment" : "Contact edit delete placeholder message", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Contact deletion will be available later." + } + } + } + }, "Удалить из заблокированных?" : { "comment" : "Unblock confirmation title" }, "Удалить контакт" : { - "comment" : "Contacts context action delete" + "comment" : "Contact edit delete action\nContacts context action delete" }, "Удалить фото" : { "comment" : "Avatar delete" diff --git a/yobble/Views/Contacts/ContactEditView.swift b/yobble/Views/Contacts/ContactEditView.swift index 6e93b8f..971f135 100644 --- a/yobble/Views/Contacts/ContactEditView.swift +++ b/yobble/Views/Contacts/ContactEditView.swift @@ -57,14 +57,12 @@ struct ContactEditView: View { let contact: ContactEditInfo @State private var displayName: String - @State private var originalDisplayName: String @State private var activeAlert: ContactEditAlert? init(contact: ContactEditInfo) { self.contact = contact let initialName = contact.preferredName _displayName = State(initialValue: initialName) - _originalDisplayName = State(initialValue: initialName) } var body: some View { @@ -74,6 +72,15 @@ struct ContactEditView: View { Section(header: Text(NSLocalizedString("Публичная информация", comment: "Profile info section title"))) { TextField(NSLocalizedString("Отображаемое имя", comment: "Display name field placeholder"), text: $displayName) } + + Section { + Button(role: .destructive) { + handleDeleteTap() + } label: { + Text(NSLocalizedString("Удалить контакт", comment: "Contact edit delete action")) + .frame(maxWidth: .infinity, alignment: .center) + } + } } .navigationTitle(NSLocalizedString("Контакт", comment: "Contact edit title")) .navigationBarTitleDisplayMode(.inline) @@ -153,7 +160,14 @@ struct ContactEditView: View { } private var hasChanges: Bool { - displayName.trimmingCharacters(in: .whitespacesAndNewlines) != originalDisplayName.trimmingCharacters(in: .whitespacesAndNewlines) + let trimmed = displayName.trimmingCharacters(in: .whitespacesAndNewlines) + guard !trimmed.isEmpty else { return false } + + if let existing = contact.customName?.trimmedNonEmpty { + return trimmed != existing + } + + return true } private func showAvatarUnavailableAlert() { @@ -169,6 +183,13 @@ struct ContactEditView: View { message: NSLocalizedString("Редактирование контакта появится позже.", comment: "Message profile edit contact alert message") ) } + + private func handleDeleteTap() { + activeAlert = ContactEditAlert( + title: NSLocalizedString("Скоро", comment: "Common soon title"), + message: NSLocalizedString("Удаление контакта появится позже.", comment: "Contact edit delete placeholder message") + ) + } } private struct ContactEditAlert: Identifiable {