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
import SwiftUI
struct PadDetailColumnView: View {
let detail: PadColumn.Detail
let controls: (Bool) -> AnyView
var openPadRoute: ((AppRoute) -> Void)?
@State private var path: [AppRoute] = []
@State private var composeRequest: ComposeRequest?
var body: some View {
NavigationStack(path: $path) {
destination(AppRoute(detail: detail))
.toolbar {
ToolbarItem(placement: .topBarLeading) { controls(true) }
.sharedBackgroundVisibility(.hidden)
ToolbarItem(placement: .topBarTrailing) { controls(false) }
}
.navigationDestination(for: AppRoute.self) { route in
destination(route)
}
}
.sheet(item: $composeRequest) { request in
ComposerSheet(replyTo: request.replyTo, quotePostID: request.quotePostID)
}
}
private func destination(_ route: AppRoute) -> some View {
AppRouteDestination(
route: route,
openRoute: { route in
if let openPadRoute { openPadRoute(route) } else { path.append(route) }
},
openComposer: { composeRequest = ComposeRequest(replyTo: $0, quotePostID: $1) }
)
}
}