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
import SwiftUI
struct PostListItem: View {
@Environment(AppModel.self) private var model
let post: Post
var repostedBy: Post.Author?
var accessibilityIdentifierPrefix = ""
let openPost: (String) -> Void
let openProfile: (String) -> Void
let openComposer: (String?, String?) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 10) {
if let repostedBy {
RepostAttributionRow(postID: post.id, author: repostedBy) {
openProfile(repostedBy.id)
}
}
ReplyContextPosts(
post: post,
posts: model.replyContext(for: post),
openPost: openPost,
openProfile: openProfile,
openComposer: openComposer
)
PostRow(
post: post,
openPost: { openPost(post.id) },
openProfile: { openProfile(post.author.id) },
openActor: openProfile,
openQuotedPost: openPost,
openComposer: openComposer,
accessibilityIdentifierPrefix: accessibilityIdentifierPrefix
)
}
.modifier(ContentListRowStyle(openPost: model.canShowTimelineContent(post) ? { openPost(post.id) } : nil))
}
}
#if DEBUG
#Preview("Post list items") {
PreviewHost { _ in
ScrollView {
VStack(spacing: 0) {
PostListItem(
post: PreviewContent.post, openPost: { _ in }, openProfile: { _ in }, openComposer: { _, _ in })
PostListItem(
post: PreviewContent.post, repostedBy: PreviewContent.author,
openPost: { _ in }, openProfile: { _ in }, openComposer: { _, _ in })
}
}
}
}
#endif