patch edit screen

This commit is contained in:
cheykrym 2025-12-11 03:48:04 +03:00
parent b3617a58d4
commit f5009157ca
2 changed files with 36 additions and 4 deletions

View File

@ -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"

View File

@ -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 {