0

I’m trying to treat an entire LazyVGrid as pages, and animate when switching forward or back. A simple slide animation would be fine.

I currently have something along the lines of

      LazyVGrid(
        columns: [array of column info],
        alignment: .center,
        spacing: 4
      ) {
        ForEach(cells) { cell in
          CellView(cell: cell)
        }
      }

I have pages of cells that get set on the state when you hit the fwd or back buttons, and they are immediately re-rendered. However, it would be cool to set a forward/back slide when the buttons are hit. I haven’t been able to figure this out easily with transition and animation.

If there’s an entirely different library doing this, I’d be open to trying it.

Thanks so much!

Hoopes
  • 3,943
  • 4
  • 44
  • 60
  • do you want to animate cell appearing of GridView? – YodagamaHeshan Dec 29 '20 at 00:48
  • I'm trying to animate the entire grid at once - to slide the whole grid left/right as i "turn the page", so to speak. If the grid has 8 cells, when i click a button, I want all 8 to slide off the right, and the next set of 8 to slide in from the left. – Hoopes Dec 29 '20 at 00:59
  • are you using TabView with the PageTabViewStyle? please add more context/code ! – YodagamaHeshan Dec 29 '20 at 01:10
  • No, but I just saw an article about that - I will definitely try it. As far as code, it's just a new app with a bunch of `cell` objects I'm trying to page through. I can try to create a test app if the TabView stuff doesn't do what i need. Thanks! – Hoopes Dec 29 '20 at 15:18
  • This is working great, thanks - you should make it a real answer so I can accept it. I was able to arrange my data in an array of array of cells (to make pages of cells), and was able to embed a `LazyVGrid` in the `TabView` - do you happen to know if it's possible to prevent changing tabs? LIke `tabView.disabled = true` ? – Hoopes Dec 30 '20 at 21:22
  • New question here: https://stackoverflow.com/questions/65524458/swiftui-tabview-pagetabviewstyle-prevent-changing-tab – Hoopes Dec 31 '20 at 18:44

0 Answers0