mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
added a TombstonedAvatarImage view to be used for the .tombstoned case
This commit is contained in:
@@ -6485,6 +6485,7 @@ class JoinedRoomProxyMock: JoinedRoomProxyProtocol, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
var underlyingTimeline: TimelineProxyProtocol!
|
var underlyingTimeline: TimelineProxyProtocol!
|
||||||
var predecessorRoom: PredecessorRoom?
|
var predecessorRoom: PredecessorRoom?
|
||||||
|
var successorRoom: SuccessorRoom?
|
||||||
var id: String {
|
var id: String {
|
||||||
get { return underlyingId }
|
get { return underlyingId }
|
||||||
set(value) { underlyingId = value }
|
set(value) { underlyingId = value }
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ struct PlaceholderAvatarImage: View {
|
|||||||
@Environment(\.redactionReasons) private var redactionReasons
|
@Environment(\.redactionReasons) private var redactionReasons
|
||||||
|
|
||||||
private let textForImage: String
|
private let textForImage: String
|
||||||
/// When `nil` the tombstoned colors will be used
|
|
||||||
private let contentID: String?
|
private let contentID: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -23,9 +22,7 @@ struct PlaceholderAvatarImage: View {
|
|||||||
// This text's frame doesn't look right when redacted
|
// This text's frame doesn't look right when redacted
|
||||||
if redactionReasons != .placeholder {
|
if redactionReasons != .placeholder {
|
||||||
Text(textForImage)
|
Text(textForImage)
|
||||||
.foregroundColor(avatarColor?.text ??
|
.foregroundColor(avatarColor?.text ?? .white)
|
||||||
// tombstoned room foreground
|
|
||||||
.compound.iconTertiary)
|
|
||||||
.font(.system(size: geometry.size.width * 0.5625, weight: .semibold))
|
.font(.system(size: geometry.size.width * 0.5625, weight: .semibold))
|
||||||
.minimumScaleFactor(0.001)
|
.minimumScaleFactor(0.001)
|
||||||
.frame(alignment: .center)
|
.frame(alignment: .center)
|
||||||
@@ -46,9 +43,7 @@ struct PlaceholderAvatarImage: View {
|
|||||||
return Color(.systemGray4) // matches the default text redaction
|
return Color(.systemGray4) // matches the default text redaction
|
||||||
}
|
}
|
||||||
|
|
||||||
return avatarColor?.background ??
|
return avatarColor?.background ?? .compound.iconPrimary
|
||||||
// tombstoned room background
|
|
||||||
.compound.bgSubtlePrimary
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var avatarColor: DecorativeColor? {
|
private var avatarColor: DecorativeColor? {
|
||||||
@@ -75,10 +70,6 @@ struct PlaceholderAvatarImage_Previews: PreviewProvider, TestablePreview {
|
|||||||
.clipShape(Circle())
|
.clipShape(Circle())
|
||||||
.frame(width: 150, height: 100)
|
.frame(width: 150, height: 100)
|
||||||
|
|
||||||
PlaceholderAvatarImage(name: "!", contentID: nil)
|
|
||||||
.clipShape(Circle())
|
|
||||||
.frame(width: 100, height: 100)
|
|
||||||
|
|
||||||
PlaceholderAvatarImage(name: nil, contentID: "@fooserid:matrix.org")
|
PlaceholderAvatarImage(name: nil, contentID: "@fooserid:matrix.org")
|
||||||
.clipShape(Circle())
|
.clipShape(Circle())
|
||||||
.frame(width: 30, height: 30)
|
.frame(width: 30, height: 30)
|
||||||
|
|||||||
@@ -96,11 +96,7 @@ struct RoomAvatarImage: View {
|
|||||||
onTap: onAvatarTap)
|
onTap: onAvatarTap)
|
||||||
}
|
}
|
||||||
case .tombstoned:
|
case .tombstoned:
|
||||||
LoadableAvatarImage(url: nil,
|
TombstonedAvatarImage(avatarSize: avatarSize)
|
||||||
name: "!",
|
|
||||||
contentID: nil, avatarSize: avatarSize,
|
|
||||||
mediaProvider: mediaProvider,
|
|
||||||
onTap: onAvatarTap)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2025 New Vector Ltd.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
// Please see LICENSE files in the repository root for full details.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Compound
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct TombstonedAvatarImage: View {
|
||||||
|
@ScaledMetric private var frameSize: CGFloat
|
||||||
|
|
||||||
|
init(avatarSize: Avatars.Size) {
|
||||||
|
_frameSize = ScaledMetric(wrappedValue: avatarSize.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
GeometryReader { geometry in
|
||||||
|
ZStack(alignment: .center) {
|
||||||
|
Color.compound.bgSubtlePrimary
|
||||||
|
|
||||||
|
Text(verbatim: "!")
|
||||||
|
.foregroundColor(.compound.iconTertiary)
|
||||||
|
.font(.system(size: geometry.size.width * 0.5625, weight: .semibold))
|
||||||
|
.minimumScaleFactor(0.001)
|
||||||
|
.frame(alignment: .center)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.aspectRatio(1, contentMode: .fill)
|
||||||
|
.frame(width: frameSize, height: frameSize)
|
||||||
|
.background(Color.compound.bgCanvasDefault)
|
||||||
|
.clipShape(Circle())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TombstonedAvatarImage_Previews: PreviewProvider, TestablePreview {
|
||||||
|
static var previews: some View {
|
||||||
|
TombstonedAvatarImage(avatarSize: .room(on: .home))
|
||||||
|
.previewLayout(.sizeThatFits)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1013,6 +1013,12 @@ extension PreviewTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testTombstonedAvatarImage() async throws {
|
||||||
|
for (index, preview) in TombstonedAvatarImage_Previews._allPreviews.enumerated() {
|
||||||
|
try await assertSnapshots(matching: preview, step: index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testTypingIndicatorView() async throws {
|
func testTypingIndicatorView() async throws {
|
||||||
for (index, preview) in TypingIndicatorView_Previews._allPreviews.enumerated() {
|
for (index, preview) in TypingIndicatorView_Previews._allPreviews.enumerated() {
|
||||||
try await assertSnapshots(matching: preview, step: index)
|
try await assertSnapshots(matching: preview, step: index)
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:acc53e8fc7d224fc2ec0ce663efde39aaa625dcf11de3ca43f52704c814d0825
|
oid sha256:eaa4236ec02b96b3883fccefc5e45b0b296448ab52ecc87201a837e5b1b23a83
|
||||||
size 101058
|
size 96810
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:acc53e8fc7d224fc2ec0ce663efde39aaa625dcf11de3ca43f52704c814d0825
|
oid sha256:eaa4236ec02b96b3883fccefc5e45b0b296448ab52ecc87201a837e5b1b23a83
|
||||||
size 101058
|
size 96810
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ec055acc51709c62fe9d76a93db885da6de917eb014bde88c51307b9582e352e
|
oid sha256:21089ce2daaa37f7e86031e11eab89d2dd9e80bb319c004fb86a9fc0e83d84f1
|
||||||
size 59276
|
size 55228
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ec055acc51709c62fe9d76a93db885da6de917eb014bde88c51307b9582e352e
|
oid sha256:21089ce2daaa37f7e86031e11eab89d2dd9e80bb319c004fb86a9fc0e83d84f1
|
||||||
size 59276
|
size 55228
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:da0585b2cb692b7a8560c0b7953bfe6c6a0c3c93b900ac0d22d0f2263fc01742
|
||||||
|
size 6601
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:da0585b2cb692b7a8560c0b7953bfe6c6a0c3c93b900ac0d22d0f2263fc01742
|
||||||
|
size 6601
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:d29a91cf15e22b917e43d2343dd092903144193687d4a6bb94c50254806919da
|
||||||
|
size 4044
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:d29a91cf15e22b917e43d2343dd092903144193687d4a6bb94c50254806919da
|
||||||
|
size 4044
|
||||||
Reference in New Issue
Block a user