I have NavigationStack with a List. I would like a NavigationLink to only trigger when Image(systemName: "info.circle")
is tapped. Anywhere I place the NavigationLink, the whole row acts as a link button to new view.
NavigationStack(path: $navigationPath) {
List {
ForEach(aircraftVM.aircraftCollect, id: \.id) { aircraft in
HStack{
VStack(alignment: .leading) {
Text(aircraft.registration ?? "")
Text(aircraft.type ?? "")
.font(.callout)
.foregroundStyle(.secondary)
Text(aircraft.aircraftRemarks ?? "")
.font(.footnote)
.foregroundStyle(.secondary)
}
NavigationLink(value: aircraft) {
Image(systemName: "info.circle")
}
}
}
.onDelete(perform: delete)
}
.navigationDestination(for: AircraftEntity.self) { aircraft in
AircraftDatabaseDetailView(aircraft: aircraft)
}
I was curious and built out a working copy of your code. The key items are
.buttonStyle(.borderless)
and using aButton(action:,label:)