tombstoned and upgraded rooms implementation

added tests

tombstoned room avatar
This commit is contained in:
Mauro Romito
2025-06-03 12:52:31 +02:00
committed by Mauro
parent b628f5d2c2
commit 155b47e849
76 changed files with 438 additions and 171 deletions
@@ -12,6 +12,7 @@ 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 {
@@ -22,7 +23,9 @@ struct PlaceholderAvatarImage: View {
// This text's frame doesn't look right when redacted
if redactionReasons != .placeholder {
Text(textForImage)
.foregroundColor(avatarColor?.text ?? .white)
.foregroundColor(avatarColor?.text ??
// tombstoned room foreground
.compound.iconTertiary)
.font(.system(size: geometry.size.width * 0.5625, weight: .semibold))
.minimumScaleFactor(0.001)
.frame(alignment: .center)
@@ -43,7 +46,9 @@ struct PlaceholderAvatarImage: View {
return Color(.systemGray4) // matches the default text redaction
}
return avatarColor?.background ?? .compound.iconPrimary
return avatarColor?.background ??
// tombstoned room background
.compound.bgSubtlePrimary
}
private var avatarColor: DecorativeColor? {
@@ -70,6 +75,10 @@ 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)