Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created July 3, 2023 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/dcfe8924a5356f9807e97956775af5d8 to your computer and use it in GitHub Desktop.
Save sturdysturge/dcfe8924a5356f9807e97956775af5d8 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@Namespace var namespace
@State var selectedIndex = -1
let column = GridItem(.adaptive(minimum: 50))
var body: some View {
ZStack {
ScrollView {
LazyVGrid(columns: [column, column]) {
ForEach(0...99, id: \.self) { index in
if selectedIndex != index {
AdaptiveView(namespace: namespace, selectedIndex: $selectedIndex,
index: index, isSource: true)
} else {
Rectangle()
}
}
}
}
.padding()
if selectedIndex != -1 {
AdaptiveView(namespace: namespace, selectedIndex: $selectedIndex,
index: selectedIndex, isSource: false)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment