Last active
June 21, 2020 08:09
-
-
Save gahntpo/6442b4dc4342b63e88bf3a9640a5cda3 to your computer and use it in GitHub Desktop.
Revisions
-
gahntpo revised this gist
Jun 21, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ struct FirstView: View { Text("Main view") .font(.title) // binding NavigationLink isAcitve to NavigationController NavigationLink(destination: FirstDetailView(), isActive: self.$nav.detailIsShown) { Text("show me the details") } } -
gahntpo created this gist
Jun 21, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ import SwiftUI struct ContentView: View { @EnvironmentObject var nav: NavigationController var body: some View { // binding TabView selection to NavigationController TabView(selection: self.$nav.selection){ FirstView() .tabItem { Text("First") }.tag(0) Text("Second View") .font(.title) .tabItem { Text("Second") }.tag(1) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environmentObject(NavigationController()) } } struct FirstView: View { @EnvironmentObject var nav: NavigationController var body: some View { NavigationView { VStack { Text("Main view") .font(.title) // binding NavigationLink isAcitve to NavigationController NavigationLink(destination: DetailView(), isActive: self.$nav.detailIsShown) { Text("show me the details") } } }.navigationViewStyle(StackNavigationViewStyle()) } }