|
|
@ -13,21 +13,46 @@ public extension ProfilePictureView {
|
|
|
|
additionalProfile: Profile? = nil,
|
|
|
|
additionalProfile: Profile? = nil,
|
|
|
|
additionalProfileIcon: ProfileIcon = .none
|
|
|
|
additionalProfileIcon: ProfileIcon = .none
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
let (info, additionalInfo): (Info?, Info?) = Self.getProfilePictureInfo(
|
|
|
|
|
|
|
|
size: self.size,
|
|
|
|
|
|
|
|
publicKey: publicKey,
|
|
|
|
|
|
|
|
threadVariant: threadVariant,
|
|
|
|
|
|
|
|
customImageData: customImageData,
|
|
|
|
|
|
|
|
profile: profile,
|
|
|
|
|
|
|
|
profileIcon: profileIcon,
|
|
|
|
|
|
|
|
additionalProfile: additionalProfile,
|
|
|
|
|
|
|
|
additionalProfileIcon: additionalProfileIcon
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard let info: Info = info else { return }
|
|
|
|
|
|
|
|
update(info, additionalInfo: additionalInfo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func getProfilePictureInfo(
|
|
|
|
|
|
|
|
size: Size,
|
|
|
|
|
|
|
|
publicKey: String,
|
|
|
|
|
|
|
|
threadVariant: SessionThread.Variant,
|
|
|
|
|
|
|
|
customImageData: Data?,
|
|
|
|
|
|
|
|
profile: Profile?,
|
|
|
|
|
|
|
|
profileIcon: ProfileIcon = .none,
|
|
|
|
|
|
|
|
additionalProfile: Profile? = nil,
|
|
|
|
|
|
|
|
additionalProfileIcon: ProfileIcon = .none
|
|
|
|
|
|
|
|
) -> (Info?, Info?) {
|
|
|
|
// If we are given 'customImageData' then only use that
|
|
|
|
// If we are given 'customImageData' then only use that
|
|
|
|
guard customImageData == nil else { return update(Info(imageData: customImageData)) }
|
|
|
|
guard customImageData == nil else { return (Info(imageData: customImageData), nil) }
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise there are conversation-type-specific behaviours
|
|
|
|
// Otherwise there are conversation-type-specific behaviours
|
|
|
|
switch threadVariant {
|
|
|
|
switch threadVariant {
|
|
|
|
case .community:
|
|
|
|
case .community:
|
|
|
|
let placeholderImage: UIImage = {
|
|
|
|
let placeholderImage: UIImage = {
|
|
|
|
switch self.size {
|
|
|
|
switch size {
|
|
|
|
case .navigation, .message: return #imageLiteral(resourceName: "SessionWhite16")
|
|
|
|
case .navigation, .message: return #imageLiteral(resourceName: "SessionWhite16")
|
|
|
|
case .list: return #imageLiteral(resourceName: "SessionWhite24")
|
|
|
|
case .list: return #imageLiteral(resourceName: "SessionWhite24")
|
|
|
|
case .hero: return #imageLiteral(resourceName: "SessionWhite40")
|
|
|
|
case .hero: return #imageLiteral(resourceName: "SessionWhite40")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
update(
|
|
|
|
return (
|
|
|
|
Info(
|
|
|
|
Info(
|
|
|
|
imageData: placeholderImage.pngData(),
|
|
|
|
imageData: placeholderImage.pngData(),
|
|
|
|
inset: UIEdgeInsets(
|
|
|
|
inset: UIEdgeInsets(
|
|
|
@ -38,13 +63,14 @@ public extension ProfilePictureView {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
icon: profileIcon,
|
|
|
|
icon: profileIcon,
|
|
|
|
forcedBackgroundColor: .theme(.classicDark, color: .borderSeparator)
|
|
|
|
forcedBackgroundColor: .theme(.classicDark, color: .borderSeparator)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
nil
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
case .legacyGroup, .group:
|
|
|
|
case .legacyGroup, .group:
|
|
|
|
guard !publicKey.isEmpty else { return }
|
|
|
|
guard !publicKey.isEmpty else { return (nil, nil) }
|
|
|
|
|
|
|
|
|
|
|
|
update(
|
|
|
|
return (
|
|
|
|
Info(
|
|
|
|
Info(
|
|
|
|
imageData: (
|
|
|
|
imageData: (
|
|
|
|
profile.map { ProfileManager.profileAvatar(profile: $0) } ??
|
|
|
|
profile.map { ProfileManager.profileAvatar(profile: $0) } ??
|
|
|
@ -53,14 +79,14 @@ public extension ProfilePictureView {
|
|
|
|
text: (profile?.displayName(for: threadVariant))
|
|
|
|
text: (profile?.displayName(for: threadVariant))
|
|
|
|
.defaulting(to: publicKey),
|
|
|
|
.defaulting(to: publicKey),
|
|
|
|
size: (additionalProfile != nil ?
|
|
|
|
size: (additionalProfile != nil ?
|
|
|
|
self.size.multiImageSize :
|
|
|
|
size.multiImageSize :
|
|
|
|
self.size.viewSize
|
|
|
|
size.viewSize
|
|
|
|
)
|
|
|
|
)
|
|
|
|
).pngData()
|
|
|
|
).pngData()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
icon: profileIcon
|
|
|
|
icon: profileIcon
|
|
|
|
),
|
|
|
|
),
|
|
|
|
additionalInfo: additionalProfile
|
|
|
|
additionalProfile
|
|
|
|
.map { otherProfile in
|
|
|
|
.map { otherProfile in
|
|
|
|
Info(
|
|
|
|
Info(
|
|
|
|
imageData: (
|
|
|
|
imageData: (
|
|
|
@ -68,7 +94,7 @@ public extension ProfilePictureView {
|
|
|
|
PlaceholderIcon.generate(
|
|
|
|
PlaceholderIcon.generate(
|
|
|
|
seed: otherProfile.id,
|
|
|
|
seed: otherProfile.id,
|
|
|
|
text: otherProfile.displayName(for: threadVariant),
|
|
|
|
text: otherProfile.displayName(for: threadVariant),
|
|
|
|
size: self.size.multiImageSize
|
|
|
|
size: size.multiImageSize
|
|
|
|
).pngData()
|
|
|
|
).pngData()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
icon: additionalProfileIcon
|
|
|
|
icon: additionalProfileIcon
|
|
|
@ -91,9 +117,9 @@ public extension ProfilePictureView {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
case .contact:
|
|
|
|
case .contact:
|
|
|
|
guard !publicKey.isEmpty else { return }
|
|
|
|
guard !publicKey.isEmpty else { return (nil, nil) }
|
|
|
|
|
|
|
|
|
|
|
|
update(
|
|
|
|
return (
|
|
|
|
Info(
|
|
|
|
Info(
|
|
|
|
imageData: (
|
|
|
|
imageData: (
|
|
|
|
profile.map { ProfileManager.profileAvatar(profile: $0) } ??
|
|
|
|
profile.map { ProfileManager.profileAvatar(profile: $0) } ??
|
|
|
@ -102,13 +128,14 @@ public extension ProfilePictureView {
|
|
|
|
text: (profile?.displayName(for: threadVariant))
|
|
|
|
text: (profile?.displayName(for: threadVariant))
|
|
|
|
.defaulting(to: publicKey),
|
|
|
|
.defaulting(to: publicKey),
|
|
|
|
size: (additionalProfile != nil ?
|
|
|
|
size: (additionalProfile != nil ?
|
|
|
|
self.size.multiImageSize :
|
|
|
|
size.multiImageSize :
|
|
|
|
self.size.viewSize
|
|
|
|
size.viewSize
|
|
|
|
)
|
|
|
|
)
|
|
|
|
).pngData()
|
|
|
|
).pngData()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
icon: profileIcon
|
|
|
|
icon: profileIcon
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
nil
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|