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
import SwiftUI
struct AppRouteDestination: View {
let route: AppRoute
let openRoute: (AppRoute) -> Void
let openComposer: (String?, String?) -> Void
var body: some View {
switch route {
case .post(let id):
PostDetailView(
postID: id,
openPost: { openRoute(.post($0)) },
openProfile: { openRoute(.profile($0)) },
openComposer: openComposer
)
case .profile(let id):
ProfileView(
actorID: id,
openPost: { openRoute(.post($0)) },
openProfile: { openRoute(.profile($0)) },
openConnections: { openRoute(.profileConnections(id, $0)) },
openComposer: openComposer
)
case .profileConnections(let id, let kind):
ProfileConnectionsView(actorID: id, kind: kind, openProfile: { openRoute(.profile($0)) })
case .compose:
EmptyView()
}
}
}
#if DEBUG
#Preview("Post destination") {
PreviewHost { _ in
NavigationStack {
AppRouteDestination(route: .post("post-1"), openRoute: { _ in }, openComposer: { _, _ in })
}
}
}
#Preview("Profile destination") {
PreviewHost { _ in
NavigationStack {
AppRouteDestination(
route: .profile(PreviewContent.author.id), openRoute: { _ in }, openComposer: { _, _ in })
}
}
}
#endif
struct ComposerSheet: View {
var replyTo: String?
var quotePostID: String?
var sharedImport: SharedImport?
var body: some View {
NavigationStack {
ComposeView(replyTo: replyTo, quotePostID: quotePostID, sharedImport: sharedImport)
}
.presentationDetents([.large])
.presentationDragIndicator(.visible)
}
}
#if DEBUG
#Preview("Composer sheet") {
PreviewHost { _ in ComposerSheet() }
}
#Preview("Reply sheet") {
PreviewHost { _ in ComposerSheet(replyTo: "post-1") }
}
#endif