51 lines
1.0 KiB
Swift
51 lines
1.0 KiB
Swift
import SwiftUI
|
|
|
|
@MainActor
|
|
enum AppRoute: Hashable {
|
|
case avatarBox
|
|
case feedbackView
|
|
case feedbackDetail(type: FeedbackView.FeedbackType)
|
|
case mediaUpload
|
|
case blindBox
|
|
case blindOutcome(media: MediaType)
|
|
|
|
@ViewBuilder
|
|
var view: some View {
|
|
switch self {
|
|
case .avatarBox:
|
|
AvatarBoxView()
|
|
case .feedbackView:
|
|
FeedbackView()
|
|
case .feedbackDetail(let type):
|
|
FeedbackDetailView(feedbackType: type)
|
|
case .mediaUpload:
|
|
MediaUploadView()
|
|
case .blindBox:
|
|
BlindBoxView()
|
|
case .blindOutcome(let media):
|
|
BlindOutcomeView(media: media)
|
|
}
|
|
}
|
|
}
|
|
|
|
@MainActor
|
|
class Router: ObservableObject {
|
|
static let shared = Router()
|
|
|
|
@Published var path = NavigationPath()
|
|
|
|
private init() {}
|
|
|
|
func navigate(to destination: AppRoute) {
|
|
path.append(destination)
|
|
}
|
|
|
|
func pop() {
|
|
path.removeLast()
|
|
}
|
|
|
|
func popToRoot() {
|
|
path = NavigationPath()
|
|
}
|
|
}
|