fix contact add and contact edit
This commit is contained in:
parent
048b9eaf1c
commit
fc3a534496
@ -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>
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user