- Notifications
You must be signed in to change notification settings - Fork1
swiftuiux/d3-custom-navigation-swiftui
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Experimenting with navigation link. if you find this idea interesting you can take and expend it into a more powerful solution.Live youtube
@Statevarroute:Router=.emptyvarbody:someView{NavigationView{VStack{Button("go1"){ route=.go1}Button("go2"){ route=.go2}Button("go3"){ route=.go3}}.navigation(route: $route)}.navigationViewStyle(.stack)}
structSubView:View{lettext:Stringvarbody:someView{Text("\(text)")}}
enumRouter{case go1case go2case go3case empty@ViewBuildervarbuilder:someView{switch(self){case.go1:SubView(text:"go1")case.go2:SubView(text:"go2")case.go3:SubView(text:"go3")default:EmptyView()}}}
structNavigationModifire:ViewModifier{@StatevarisActive:Bool=true@Bindingvarroute:Routerfunc body(content:Content)->someView{ content.background{NavigationLink(destination: route.builder, isActive: $isActive){EmptyView()}.hidden()}.onChange(of: isActive){if $0==false{ route=.empty}}}}extensionView{@ViewBuilderfunc navigation(route:Binding<Router>)->someView{if route.wrappedValue!=.empty{modifier(NavigationModifire(route: route))}else{self}}}
About
custom navigation swiftui navigation link swiftui routing
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published