diff --git a/Linphone/Assets.xcassets/not-trusted.imageset/Contents.json b/Linphone/Assets.xcassets/not-trusted.imageset/Contents.json index 919aa20b8..1c6125525 100644 --- a/Linphone/Assets.xcassets/not-trusted.imageset/Contents.json +++ b/Linphone/Assets.xcassets/not-trusted.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "not_trusted.svg", + "filename" : "not-trusted.svg", "idiom" : "universal", "scale" : "1x" }, diff --git a/Linphone/Assets.xcassets/not-trusted.imageset/not-trusted.svg b/Linphone/Assets.xcassets/not-trusted.imageset/not-trusted.svg new file mode 100644 index 000000000..52bc2f61f --- /dev/null +++ b/Linphone/Assets.xcassets/not-trusted.imageset/not-trusted.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linphone/Assets.xcassets/not-trusted.imageset/not_trusted.svg b/Linphone/Assets.xcassets/not-trusted.imageset/not_trusted.svg deleted file mode 100644 index b16dc774d..000000000 --- a/Linphone/Assets.xcassets/not-trusted.imageset/not_trusted.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index 213b92b88..3b55d42ca 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -1,7 +1,7 @@ import Foundation public enum AppGitInfo { - public static let branch = "feature/trust_list" - public static let commit = "692a308d7" + public static let branch = "master" + public static let commit = "d5d1600b4" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/UI/Main/Contacts/Model/ContactAvatarModel.swift b/Linphone/UI/Main/Contacts/Model/ContactAvatarModel.swift index 139658f11..091ec6fc9 100644 --- a/Linphone/UI/Main/Contacts/Model/ContactAvatarModel.swift +++ b/Linphone/UI/Main/Contacts/Model/ContactAvatarModel.swift @@ -45,6 +45,8 @@ class ContactAvatarModel: ObservableObject, Identifiable { @Published var photo: String = "" @Published var lastPresenceInfo: String = "" @Published var presenceStatus: ConsolidatedPresence = .Offline + @Published var unsafeFriend: Bool = false + @Published var trustedFriend: Bool = false private var friendDelegate: FriendDelegate? @@ -89,6 +91,9 @@ class ContactAvatarModel: ObservableObject, Identifiable { var lastPresenceInfoTmp = "" var presenceStatusTmp: ConsolidatedPresence = .Offline + let unsafeFriendTmp = (friend?.securityLevel ?? .None) == .Unsafe + let trustedFriendTmp = (friend?.securityLevel ?? .None) == .EndToEndEncryptedAndVerified + if let friend = friend, withPresence == true { lastPresenceInfoTmp = "" @@ -128,6 +133,8 @@ class ContactAvatarModel: ObservableObject, Identifiable { self.photo = photoTmp self.lastPresenceInfo = lastPresenceInfoTmp self.presenceStatus = presenceStatusTmp + self.unsafeFriend = unsafeFriendTmp + self.trustedFriend = trustedFriendTmp } } } diff --git a/Linphone/Utils/Avatar.swift b/Linphone/Utils/Avatar.swift index 7bf7aa227..d41d09511 100644 --- a/Linphone/Utils/Avatar.swift +++ b/Linphone/Utils/Avatar.swift @@ -27,65 +27,79 @@ struct Avatar: View { @ObservedObject var contactAvatarModel: ContactAvatarModel let avatarSize: CGFloat - let hidePresence: Bool - - init(contactAvatarModel: ContactAvatarModel, avatarSize: CGFloat, hidePresence: Bool = false) { - self.contactAvatarModel = contactAvatarModel - self.avatarSize = avatarSize - self.hidePresence = hidePresence - } + let hidePresence: Bool + + init(contactAvatarModel: ContactAvatarModel, avatarSize: CGFloat, hidePresence: Bool = false) { + self.contactAvatarModel = contactAvatarModel + self.avatarSize = avatarSize + self.hidePresence = hidePresence + } var body: some View { - if !contactAvatarModel.photo.isEmpty { - let uniqueUrl = ContactsManager.shared.getImagePath(friendPhotoPath: contactAvatarModel.photo) - //let finalUrl = uniqueUrl.appendingQueryItem("v", value: UUID().uuidString) - - AsyncImage(url: uniqueUrl) { image in - switch image { - case .empty: - ProgressView() - .frame(width: avatarSize, height: avatarSize) - case .success(let image): - ZStack { - image + ZStack { + if !contactAvatarModel.photo.isEmpty { + let uniqueUrl = ContactsManager.shared.getImagePath(friendPhotoPath: contactAvatarModel.photo) + //let finalUrl = uniqueUrl.appendingQueryItem("v", value: UUID().uuidString) + + AsyncImage(url: uniqueUrl) { image in + switch image { + case .empty: + ProgressView() + .frame(width: avatarSize, height: avatarSize) + case .success(let image): + ZStack { + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: avatarSize, height: avatarSize) + .clipShape(Circle()) + } + case .failure: + Image("profil-picture-default") .resizable() - .aspectRatio(contentMode: .fill) .frame(width: avatarSize, height: avatarSize) .clipShape(Circle()) - HStack { - Spacer() - VStack { - Spacer() - if !hidePresence && (contactAvatarModel.presenceStatus == .Online || contactAvatarModel.presenceStatus == .Busy) { - Image(contactAvatarModel.presenceStatus == .Online ? "presence-online" : "presence-busy") - .resizable() - .frame(width: avatarSize/4, height: avatarSize/4) - .padding(.trailing, avatarSize == 50 || avatarSize == 35 ? 1 : 3) - .padding(.bottom, avatarSize == 50 || avatarSize == 35 ? 1 : 3) - } - } - } - .frame(width: avatarSize, height: avatarSize) + @unknown default: + EmptyView() } - case .failure: - Image("profil-picture-default") - .resizable() - .frame(width: avatarSize, height: avatarSize) - .clipShape(Circle()) - @unknown default: - EmptyView() } + } else if !contactAvatarModel.name.isEmpty { + ZStack { + Image(uiImage: contactsManager.textToImage( + firstName: contactAvatarModel.name, + lastName: contactAvatarModel.name.components(separatedBy: " ").count > 1 + ? contactAvatarModel.name.components(separatedBy: " ")[1] + : "")) + .resizable() + .frame(width: avatarSize, height: avatarSize) + .clipShape(Circle()) + } + } else { + Image("profil-picture-default") + .resizable() + .frame(width: avatarSize, height: avatarSize) + .clipShape(Circle()) } - } else if !contactAvatarModel.name.isEmpty { - ZStack { - Image(uiImage: contactsManager.textToImage( - firstName: contactAvatarModel.name, - lastName: contactAvatarModel.name.components(separatedBy: " ").count > 1 - ? contactAvatarModel.name.components(separatedBy: " ")[1] - : "")) - .resizable() - .frame(width: avatarSize, height: avatarSize) - .clipShape(Circle()) + + if contactAvatarModel.friend != nil && !hidePresence { + if contactAvatarModel.unsafeFriend || contactAvatarModel.trustedFriend { + Circle() + .stroke(contactAvatarModel.trustedFriend ? Color.blueInfo500 : Color.redDanger500, lineWidth: 2) + .frame(width: avatarSize, height: avatarSize) + + HStack { + VStack { + Spacer() + Image(contactAvatarModel.trustedFriend ? "trusted" : "not-trusted") + .resizable() + .frame(width: avatarSize/4, height: avatarSize/4) + .padding(.trailing, avatarSize == 50 || avatarSize == 35 ? 1 : 3) + .padding(.bottom, avatarSize == 50 || avatarSize == 35 ? 1 : 3) + } + Spacer() + } + .frame(width: avatarSize, height: avatarSize) + } HStack { Spacer() @@ -102,11 +116,6 @@ struct Avatar: View { } .frame(width: avatarSize, height: avatarSize) } - } else { - Image("profil-picture-default") - .resizable() - .frame(width: avatarSize, height: avatarSize) - .clipShape(Circle()) } } }