mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-02 02:16:24 +00:00
Handle user initials generation from first and last name
This commit is contained in:
parent
30de5c1666
commit
f9246f1f25
2 changed files with 19 additions and 4 deletions
|
|
@ -197,9 +197,24 @@ final class ContactsManager: ObservableObject {
|
|||
}
|
||||
|
||||
func textToImage(firstName: String?, lastName: String?) -> UIImage {
|
||||
let firstInitial = firstName?.first.map { String($0) } ?? ""
|
||||
let lastInitial = lastName?.first.map { String($0) } ?? ""
|
||||
let textToDisplay = (firstInitial + lastInitial).uppercased()
|
||||
let firstParts = firstName?
|
||||
.split(separator: " ")
|
||||
.map(String.init) ?? []
|
||||
|
||||
let firstInitial = firstParts.first?.first.map(String.init) ?? ""
|
||||
let secondInitial = firstParts.count > 1 ? firstParts[1].first.map(String.init) ?? "" : ""
|
||||
|
||||
let lastInitial = lastName?.first.map(String.init) ?? ""
|
||||
|
||||
let textToDisplay: String
|
||||
|
||||
if !firstInitial.isEmpty && !secondInitial.isEmpty {
|
||||
textToDisplay = firstInitial + secondInitial
|
||||
} else if !firstInitial.isEmpty {
|
||||
textToDisplay = firstInitial + lastInitial
|
||||
} else {
|
||||
textToDisplay = lastInitial
|
||||
}
|
||||
|
||||
let size = CGSize(width: 200, height: 200)
|
||||
let renderer = UIGraphicsImageRenderer(size: size)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import Foundation
|
|||
|
||||
public enum AppGitInfo {
|
||||
public static let branch = "release/6.2"
|
||||
public static let commit = "4e93c8f4b"
|
||||
public static let commit = "30de5c166"
|
||||
public static let tag = "6.2.0-beta"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue