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
98
99
100
101
102
103
104
105
106
107
108
#if DEBUG
import SwiftUI
#Preview("Account avatar") {
HStack(spacing: 24) {
AccountAvatar(account: PreviewContent.account, size: 44)
AccountAvatar(account: nil, size: 64)
}
.padding()
}
#Preview("Author avatar") {
PreviewHost { _ in
AuthorAvatar(author: PreviewContent.author, size: 64)
.padding()
}
}
#Preview("Post loading placeholders") {
PostLoadingPlaceholder(label: "Loading posts", count: 3)
}
#Preview("Content row style") {
List {
Text("A post uses the shared row spacing.")
.modifier(ContentListRowStyle())
}
.listStyle(.plain)
}
#Preview("Screen size reader") {
PreviewScreenSize()
}
private struct PreviewScreenSize: View {
@State private var size = CGSize.zero
var body: some View {
Text("Screen: \(Int(size.width)) × \(Int(size.height))")
.background { PadScreenSizeReader { size = $0 } }
.padding()
}
}
#Preview("Content preferences notice without an error") {
PreviewHost { _ in
VStack {
ContentPreferencesRefreshNotice()
Text("No notice appears when content preferences load.")
.foregroundStyle(.secondary)
}
.padding()
}
}
#Preview("View metrics panel without test flags") {
VStack {
ViewUpdateMetricsPanel()
Text("The metrics panel appears only with its UI test flags.")
.foregroundStyle(.secondary)
}
.padding()
}
#Preview("Notification activity headers") {
VStack(spacing: 20) {
NotificationActivityHeader(reason: .like, date: PreviewContent.date, isRead: false) {
Text("Mae Rivers liked your post")
}
NotificationActivityHeader(reason: .repost, date: PreviewContent.date, isRead: true) {
Text("Alex Kim reposted your post")
}
NotificationActivityHeader(reason: .follow, date: PreviewContent.date, isRead: false) {
Text("Sam Lee followed you")
}
}
.padding()
}
#Preview("Notification rows") {
PreviewHost { _ in
List {
ForEach(
[FeedNotification.Reason.like, .repost, .follow, .reply, .mention, .quote], id: \.rawValue
) { reason in
let notification = FeedNotification(
id: reason.rawValue, author: PreviewContent.author, reason: reason,
indexedAt: PreviewContent.date, isRead: false, postID: PreviewContent.post.id,
relatedPost: reason.includesPost ? PreviewContent.post : nil
)
NotificationRow(
state: NotificationGroupState(group: NotificationGroup(notifications: [notification])),
openRoute: { _ in }, openComposer: { _, _ in }, showGroup: { _ in }
)
.listRowInsets(EdgeInsets())
}
}
.listStyle(.plain)
}
}
#Preview("Notification refresh control") {
List {
Text("Pull to refresh")
}
.refreshable {}
.background { ScrollRefreshControl(isRefreshing: true, isActive: true) }
}
#endif