42 lines
831 B
Swift
42 lines
831 B
Swift
import SwiftUI
|
|
|
|
enum AppRoute: Hashable {
|
|
case avatarBox
|
|
case feedbackView
|
|
case feedbackDetail(type: FeedbackView.FeedbackType)
|
|
// Add other routes here as needed
|
|
|
|
@ViewBuilder
|
|
var view: some View {
|
|
switch self {
|
|
case .avatarBox:
|
|
AvatarBoxView()
|
|
case .feedbackView:
|
|
FeedbackView()
|
|
case .feedbackDetail(let type):
|
|
FeedbackDetailView(feedbackType: type)
|
|
}
|
|
}
|
|
}
|
|
|
|
@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()
|
|
}
|
|
}
|