@@ -10,9 +10,10 @@ import SwiftUI
1010struct MainView : View {
1111 @Environment ( \. diContainer) var container : DIContainer
1212 @State var viewModel : MainViewModel
13+ @Binding var selectedTab : MainTab
1314
1415 var body : some View {
15- TabView {
16+ TabView ( selection : $selectedTab ) {
1617 HomeView ( viewModel: HomeViewModel (
1718 fetchPreferencesUseCase: container. resolve ( FetchTodoCategoryPreferencesUseCase . self) ,
1819 updatePreferencesUseCase: container. resolve ( UpdateTodoCategoryPreferencesUseCase . self) ,
@@ -28,6 +29,7 @@ struct MainView: View {
2829 Image ( systemName: " house.fill " )
2930 Text ( String ( localized: " nav_home " ) )
3031 }
32+ . tag ( MainTab . home)
3133 TodayView ( viewModel: TodayViewModel (
3234 fetchTodosUseCase: container. resolve ( FetchTodosUseCase . self) ,
3335 fetchTodoByIdUseCase: container. resolve ( FetchTodoByIdUseCase . self) ,
@@ -39,6 +41,7 @@ struct MainView: View {
3941 Image ( systemName: " sun.max.fill " )
4042 Text ( String ( localized: " nav_today " ) )
4143 }
44+ . tag ( MainTab . today)
4245 PushNotificationListView ( viewModel: PushNotificationListViewModel (
4346 fetchUseCase: container. resolve ( FetchPushNotificationsUseCase . self) ,
4447 deleteUseCase: container. resolve ( DeletePushNotificationUseCase . self) ,
@@ -52,6 +55,7 @@ struct MainView: View {
5255 Text ( String ( localized: " nav_notifications " ) )
5356 }
5457 . badge ( viewModel. state. unreadPushCount)
58+ . tag ( MainTab . notification)
5559 ProfileView ( viewModel: ProfileViewModel (
5660 fetchUserDataUseCase: container. resolve ( FetchUserDataUseCase . self) ,
5761 fetchTodosUseCase: container. resolve ( FetchTodosUseCase . self) ,
@@ -64,6 +68,7 @@ struct MainView: View {
6468 Image ( systemName: " person.crop.circle.fill " )
6569 Text ( String ( localized: " nav_profile " ) )
6670 }
71+ . tag ( MainTab . profile)
6772 }
6873 . onAppear {
6974 viewModel. send ( . onAppear)
0 commit comments