TabView SwiftUI return to Home page on click

62 views Asked by At

I've a project with TabView, inside every tab there is the possibility to navigate inside other page, I would like that when I click on the tab the navigation resets to the main page simil instagram. this is my tab View:

TabView(selection: self.$selection) {
                        NewsView()
                            .tabItem {
                                self.selection == 0 ? Image("menu_home_sel") : Image("menu_home")
                                Text("News")
                        }.tag(0)
                        .environmentObject(self.newsState)

                        SearchView()
                            .tabItem {
                                self.selection == 1 ? Image("menu_search_sel") : Image("menu_search")
                                Text("Cerca")
                        }.tag(1)
                        
                        LiveView()
                            .tabItem {
                                self.selection == 2 ? Image("menu_score_sel") : Image("menu_score")
                                Text("Live")
                        }.tag(2)
                        
                        ChatView()
                            .tabItem {
                                self.selection == 3 ? Image("menu_chat_sel") : Image("menu_chat")
                                Text("Chat")
                        }.tag(3)
                        
                        ProfileView()
                            .tabItem {
                                self.selection == 4 ? Image("menu_profile_sel") : Image("menu_profile")
                                Text("Profilo")
                        }.tag(4)
                    }
                    .accentColor(Color("#0082AF"))
0

There are 0 answers