@@ -328,9 +328,22 @@ struct MainView: View {
328328
329329 private var profileRegularDetailView : some View {
330330 Group {
331- if let todoId = profileSelectedTodoId {
332- TodoDetailView ( viewModel: profileViewCoordinator. makeTodoDetailViewModel ( todoId: todoId) )
333- . id ( todoId)
331+ if let profileRoute = profileViewCoordinator. router. root {
332+ switch profileRoute {
333+ case . activity( let todoId) :
334+ TodoDetailView ( viewModel: profileViewCoordinator. makeTodoDetailViewModel ( todoId: todoId) )
335+ . id ( todoId)
336+ case . settings, . theme, . pushNotification, . account:
337+ NavigationStack ( path: Binding (
338+ get: { profileViewCoordinator. router. detailPath } ,
339+ set: { profileViewCoordinator. router. detailPath = $0 }
340+ ) ) {
341+ profileRegularDestinationView ( profileRoute)
342+ . navigationDestination ( for: ProfileRoute . self) { route in
343+ profileRegularDestinationView ( route)
344+ }
345+ }
346+ }
334347 } else {
335348 ContentUnavailableView (
336349 String ( localized: " profile_select_detail " ) ,
@@ -340,6 +353,31 @@ struct MainView: View {
340353 }
341354 . background ( Color ( . secondarySystemBackground) . ignoresSafeArea ( ) )
342355 }
356+
357+ @ViewBuilder
358+ private func profileRegularDestinationView( _ route: ProfileRoute ) -> some View {
359+ switch route {
360+ case . activity( let todoId) :
361+ TodoDetailView ( viewModel: profileViewCoordinator. makeTodoDetailViewModel ( todoId: todoId) )
362+ . id ( todoId)
363+ case . settings:
364+ SettingView ( viewModel: profileViewCoordinator. settingViewModel)
365+ . environment ( profileViewCoordinator. router)
366+ case . theme:
367+ ThemeView (
368+ theme: Binding (
369+ get: { profileViewCoordinator. settingViewModel. state. theme } ,
370+ set: { profileViewCoordinator. settingViewModel. send ( . setTheme( $0) ) }
371+ )
372+ )
373+ case . pushNotification:
374+ PushNotificationSettingsView (
375+ viewModel: profileViewCoordinator. makePushNotificationSettingsViewModel ( )
376+ )
377+ case . account:
378+ AccountView ( viewModel: profileViewCoordinator. makeAccountViewModel ( ) )
379+ }
380+ }
343381}
344382
345383private extension MainView {
@@ -393,15 +431,6 @@ private extension MainView {
393431 )
394432 }
395433
396- var profileSelectedTodoId : String ? {
397- for route in profileViewCoordinator. router. path. reversed ( ) {
398- if case let . activity( todoId) = route {
399- return todoId
400- }
401- }
402- return nil
403- }
404-
405434}
406435private extension MainTab {
407436 var title : String {
0 commit comments