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