Q-Mobile / QGrid

🎛 QGrid: The missing SwiftUI collection view.
MIT License
1.64k stars 104 forks source link

Inconsistent state after rotation #40

Closed quantamrhino closed 4 years ago

quantamrhino commented 4 years ago

I have a 1 x 8 grid in portrait mode and 2x4 grid in landscape mode. I have a button in each view in the grid that toggles using @State I set button 1 and 2 on (it change color to green). I rotate the simulator to landscape mode. columns are displayed correctly (2 x 4 grid). but now, buttons 1 and 3 show the green button.

Looks like there's some recycling going on? Each gridview has the state internally.

quantamrhino commented 4 years ago

I think I see the issue. When counting, the 1-2-3-4 goes left to right (or top to bottom), when counting in landscape, the first column is counted from top to bottom, instead of a left->right, then next column (sort of zig zag order).

quantamrhino commented 4 years ago

Using environment to store to the state fixed this. I suspect Xcode 12 beta 2 bug now.