paololeonardi / WaterfallGrid

A waterfall grid layout view for SwiftUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to perform a selection

Insfgg99x opened this issue · comments

Is there any interface like this:
didSelectItemAtIndexPath
Thanks!

Hi @Insfgg99x

you could just attach a tap action to your grid views.

i.e.

WaterfallGrid(rectangles) { rectangle in
  RectangleView(rectangle: rectangle)
    .onTapGesture {
      print("Tap action")
    }
}

or

WaterfallGrid((0..<cards.count), id: \.self) { index in
  CardView(card: self.cards[index])
    .onTapGesture {
      print("Did select item at index \(index)")
    }
}

Hope this helps
Thanks!