patch edit screen
This commit is contained in:
parent
b3617a58d4
commit
f5009157ca
@ -2984,11 +2984,22 @@
|
|||||||
"Удаление контакта \"%1$@\" появится позже." : {
|
"Удаление контакта \"%1$@\" появится позже." : {
|
||||||
"comment" : "Contacts delete placeholder message"
|
"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" : "Unblock confirmation title"
|
||||||
},
|
},
|
||||||
"Удалить контакт" : {
|
"Удалить контакт" : {
|
||||||
"comment" : "Contacts context action delete"
|
"comment" : "Contact edit delete action\nContacts context action delete"
|
||||||
},
|
},
|
||||||
"Удалить фото" : {
|
"Удалить фото" : {
|
||||||
"comment" : "Avatar delete"
|
"comment" : "Avatar delete"
|
||||||
|
|||||||
@ -57,14 +57,12 @@ struct ContactEditView: View {
|
|||||||
let contact: ContactEditInfo
|
let contact: ContactEditInfo
|
||||||
|
|
||||||
@State private var displayName: String
|
@State private var displayName: String
|
||||||
@State private var originalDisplayName: String
|
|
||||||
@State private var activeAlert: ContactEditAlert?
|
@State private var activeAlert: ContactEditAlert?
|
||||||
|
|
||||||
init(contact: ContactEditInfo) {
|
init(contact: ContactEditInfo) {
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
let initialName = contact.preferredName
|
let initialName = contact.preferredName
|
||||||
_displayName = State(initialValue: initialName)
|
_displayName = State(initialValue: initialName)
|
||||||
_originalDisplayName = State(initialValue: initialName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -74,6 +72,15 @@ struct ContactEditView: View {
|
|||||||
Section(header: Text(NSLocalizedString("Публичная информация", comment: "Profile info section title"))) {
|
Section(header: Text(NSLocalizedString("Публичная информация", comment: "Profile info section title"))) {
|
||||||
TextField(NSLocalizedString("Отображаемое имя", comment: "Display name field placeholder"), text: $displayName)
|
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"))
|
.navigationTitle(NSLocalizedString("Контакт", comment: "Contact edit title"))
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
@ -153,7 +160,14 @@ struct ContactEditView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var hasChanges: Bool {
|
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() {
|
private func showAvatarUnavailableAlert() {
|
||||||
@ -169,6 +183,13 @@ struct ContactEditView: View {
|
|||||||
message: NSLocalizedString("Редактирование контакта появится позже.", comment: "Message profile edit contact alert message")
|
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 {
|
private struct ContactEditAlert: Identifiable {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user