fix contact add and contact edit

This commit is contained in:
cheykrym 2025-12-13 05:26:32 +03:00
parent 048b9eaf1c
commit fc3a534496
3 changed files with 40 additions and 4 deletions

View File

@ -3,4 +3,22 @@
uuid = "AEE1609A-17B4-4FCC-80A6-0D556940F4D7"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "09699199-8124-4F89-892D-6880A0EB7C04"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "yobble/Views/Contacts/ContactEditView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "74"
endingLineNumber = "74"
landmarkName = "ContactEditView"
landmarkType = "14">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -97,8 +97,8 @@ struct ContactAddView: View {
private var avatarInitial: String {
let trimmedName = displayName.trimmedNonEmpty ?? contact.preferredName
if let first = trimmedName.trimmingCharacters(in: .whitespacesAndNewlines).first {
return String(first).uppercased()
if let initials = initials(from: trimmedName) {
return initials
}
if let login = contact.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty {
return String(login.prefix(1)).uppercased()
@ -185,3 +185,12 @@ private extension String {
return value.isEmpty ? nil : value
}
}
private func initials(from text: String) -> String? {
let components = text
.split { $0.isWhitespace }
.filter { !$0.isEmpty }
let letters = components.prefix(2).compactMap { $0.first }
guard !letters.isEmpty else { return nil }
return letters.map { String($0).uppercased() }.joined()
}

View File

@ -203,8 +203,8 @@ struct ContactEditView: View {
private var avatarInitial: String {
let trimmedName = displayName.trimmedNonEmpty ?? contact.preferredName
if let first = trimmedName.trimmingCharacters(in: .whitespacesAndNewlines).first {
return String(first).uppercased()
if let initials = initials(from: trimmedName) {
return initials
}
if let login = contact.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty {
return String(login.prefix(1)).uppercased()
@ -336,3 +336,12 @@ private extension String {
return value.isEmpty ? nil : value
}
}
private func initials(from text: String) -> String? {
let components = text
.split { $0.isWhitespace }
.filter { !$0.isEmpty }
let letters = components.prefix(2).compactMap { $0.first }
guard !letters.isEmpty else { return nil }
return letters.map { String($0).uppercased() }.joined()
}