To create a grid where the squares can be moved with matched geometry effect, you can use the following code in SwiftUI:
main.swift1312 chars44 linesIn this code, we have a SquareView with a Rectangle that has a blue fill. We use .matchedGeometryEffect to match the id of the blue square in the SquareView with the GridView. We have an @State variable isExpanded that toggles when the square is tapped. When the square is not expanded, it has a width and height of 100. When the square is expanded, it has a width and height of 300.
In the GridView, we have a LazyVGrid with three columns and a spacing of 15. We use a ForEach loop to create nine SquareView.
gistlibby LogSnag