added a TombstonedAvatarImage view to be used for the .tombstoned case

This commit is contained in:
Mauro Romito
2025-06-05 17:53:27 +02:00
committed by Mauro
parent 26a7d5ac82
commit 4662eca9e2
13 changed files with 72 additions and 24 deletions
@@ -12,7 +12,6 @@ struct PlaceholderAvatarImage: View {
@Environment(\.redactionReasons) private var redactionReasons
private let textForImage: String
/// When `nil` the tombstoned colors will be used
private let contentID: String?
var body: some View {
@@ -23,9 +22,7 @@ struct PlaceholderAvatarImage: View {
// This text's frame doesn't look right when redacted
if redactionReasons != .placeholder {
Text(textForImage)
.foregroundColor(avatarColor?.text ??
// tombstoned room foreground
.compound.iconTertiary)
.foregroundColor(avatarColor?.text ?? .white)
.font(.system(size: geometry.size.width * 0.5625, weight: .semibold))
.minimumScaleFactor(0.001)
.frame(alignment: .center)
@@ -46,9 +43,7 @@ struct PlaceholderAvatarImage: View {
return Color(.systemGray4) // matches the default text redaction
}
return avatarColor?.background ??
// tombstoned room background
.compound.bgSubtlePrimary
return avatarColor?.background ?? .compound.iconPrimary
}
private var avatarColor: DecorativeColor? {
@@ -75,10 +70,6 @@ struct PlaceholderAvatarImage_Previews: PreviewProvider, TestablePreview {
.clipShape(Circle())
.frame(width: 150, height: 100)
PlaceholderAvatarImage(name: "!", contentID: nil)
.clipShape(Circle())
.frame(width: 100, height: 100)
PlaceholderAvatarImage(name: nil, contentID: "@fooserid:matrix.org")
.clipShape(Circle())
.frame(width: 30, height: 30)