From f9246f1f259d66600b3fa09c7f0bd9cfb49f0a15 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Mon, 20 Apr 2026 12:26:28 +0200 Subject: [PATCH] Handle user initials generation from first and last name --- Linphone/Contacts/ContactsManager.swift | 21 ++++++++++++++++++--- Linphone/GeneratedGit.swift | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index 5828f373b..9e2b3375f 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -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) diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index 974914e8e..6a44c1c26 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -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" }