1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import SwiftUI
/// Full content warning overlay — hides all content behind a reveal button.
struct ContentWarningOverlay: View {
let name: String
let action: LabelAction
let onReveal: () -> Void
var body: some View {
VStack(spacing: 12) {
Image(systemName: action == .hide ? "eye.slash.fill" : "exclamationmark.triangle.fill")
.font(.title2)
.foregroundStyle(.secondary)
Text(name)
.font(.subheadline.weight(.semibold))
.foregroundStyle(.primary)
Text("This content has been flagged.")
.font(.caption)
.foregroundStyle(.secondary)
Button("Show anyway") {
onReveal()
}
.font(.caption.weight(.medium))
.buttonStyle(.bordered)
.tint(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.ultraThinMaterial)
}
}
/// Media warning overlay — centered bar with label name and Show button (Bluesky-style).
struct MediaWarningOverlay: View {
let name: String
let onReveal: () -> Void
var body: some View {
VStack {
Spacer()
HStack {
Image(systemName: "info.circle.fill")
.foregroundStyle(.secondary)
Text(name)
.font(.subheadline.weight(.medium))
Spacer()
Button("Show") {
onReveal()
}
.font(.subheadline.weight(.medium))
}
.padding(.horizontal, 16)
.padding(.vertical, 12)
.background(.thinMaterial, in: RoundedRectangle(cornerRadius: 10))
.padding(.horizontal, 12)
Spacer()
}
}
}
/// Small inline badge for low-severity labels.
struct LabelBadge: View {
let name: String
var body: some View {
HStack(spacing: 4) {
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 10))
Text(name)
.font(.caption2)
}
.foregroundStyle(.secondary)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background(.quaternary, in: .capsule)
}
}
#Preview {
VStack(spacing: 24) {
ContentWarningOverlay(name: "Nudity", action: .hide) {}
.frame(height: 200)
MediaWarningOverlay(name: "Sexual Content") {}
.frame(height: 200)
.background(Color.gray.opacity(0.2))
HStack {
LabelBadge(name: "sensitive")
LabelBadge(name: "gore")
}
.padding()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.black)
.preferredColorScheme(.dark)
.tint(Color.accentColor)
}