Files
Mauro a2c1ca06dd Content Scanning View (#5831)
* implement a MediaView to delegate at the view level the usage of the content scanner service, to determine how to render the media.

* fix for a small design mismatch

* fix for greedy error state

* updated naming

* just making some screenshot that have been affected by a string change on Localazy

* pr suggestions + updated strings
2026-07-06 16:15:27 +02:00

65 lines
2.1 KiB
Swift

//
// Copyright 2026 Element Creations 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
/// The placeholder shown in place of a media item when the content scanner wasn't able to
/// validate it. Preview and download of the content are disabled.
///
/// This view only renders the failure title and message - the critical background is applied
/// to the whole message bubble by `TimelineItemBubbledStylerView`, so that any caption and
/// reply preview are included in the critical area too.
struct ContentScanningFailureView: View {
let failure: ContentScanningFailure
var body: some View {
HStack(spacing: 8) {
CompoundIcon(\.error, size: .medium, relativeTo: .compound.bodyMDSemibold)
.foregroundStyle(.compound.iconCriticalPrimary)
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.compound.bodyMDSemibold)
.foregroundStyle(.compound.textCriticalPrimary)
Text(message)
.font(.compound.bodySM)
.foregroundStyle(.compound.textSecondary)
}
}
.accessibilityElement(children: .combine)
}
private var title: String {
switch failure {
case .notSafe: L10n.contentScannerUnsafeTitle
case .notFound: L10n.contentScannerNotFoundTitle
}
}
private var message: String {
switch failure {
case .notSafe: L10n.contentScannerUnsafeMessage
case .notFound: L10n.contentScannerNotFound
}
}
}
// MARK: - Previews
struct ContentScanningFailureView_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
VStack(spacing: 16) {
ContentScanningFailureView(failure: .notSafe)
ContentScanningFailureView(failure: .notFound)
}
.frame(width: 260)
.padding()
}
}