Learning to SwiftUI. Trying to navigate to a new view from navigation bar buttton clicked.
The sample code below:
var body: some View {
NavigationView {
List(0...< 5) { item in
NavigationLink(destination: EventDetails()){
EventView()
}
}
.navigationBarTitle("Events")
.navigationBarItems(trailing:
NavigationLink(destination: CreateEvent()){
Text("Create Event")
}
)
}
}
CreateEvent
onto the navigation stack or are you trying to present it modally? – DresserCreateEvent
should really be presented modally, not pushed onto the navigation stack. The reason is that if you have a list of events that each push a detail view onto the stack when pressed, creating a new event is really a secondary action unrelated to the navigation stack and should really be handled as a temporary view - like creating a new contact in the contacts app or a new calendar event in the calendar app. – Dresser