1

I understand that NavigationLink's are generally as so:

ForEach(xx, id: \.id) { x in
   NavigationLink(
      destination: oneView(x: x)) {
        XItem(x: x) // Image + Text in VStack 
      }
}

However, what I want to do is the equivalent of something like this:

var body: some View {
        NavigationView {
            List {
                ScrollView(.horizontal, showsIndicators: false) {
                    VStack(alignment: .leading) {
                        HStack {
                            ForEach(xx, id: \.id) { x in
                                XItem(x: x) // Image + Text in VStack 
                                    .gesture(
                                        TapGesture()
                                            .onEnded { _ in
                                                NavigationLink(destination: oneView(x: x))
                                        }
                                    )
                                    .gesture(
                                        LongPressGesture(minimumDuration: 2)
                                            .onEnded { _ in
                                                NavigationLink(destination: twoView(x: x))
                                        }
                                    )

                            }
                        }
                    }
                }.frame(height: 250)
            }
            .navigationBarTitle(Text("x"))
        }
    }

With a single Image (or Image + Text in VStack) I want to navigate to a different View based on the type of Gesture. Appreciate any solutions!

Brendon
  • 673
  • 1
  • 8
  • 19

0 Answers0