Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created June 15, 2024 11:16
Show Gist options
  • Save laevandus/8de8c142960d80ab288386d4b772eb20 to your computer and use it in GitHub Desktop.
Save laevandus/8de8c142960d80ab288386d4b772eb20 to your computer and use it in GitHub Desktop.
struct ContentView: View {
let colors: [[Color]] = [
[.red, .blue, .green],
[.yellow, .purple, .brown],
[.cyan, .gray]
]
@Namespace() var namespace
var body: some View {
NavigationStack {
Grid(horizontalSpacing: 50, verticalSpacing: 50) {
ForEach(colors, id: \.hashValue) { rowColors in
GridRow {
ForEach(rowColors, id: \.self) { color in
NavigationLink {
DetailView()
.navigationTransition(
.zoom(
sourceID: color,
in: namespace
)
)
} label: {
RoundedRectangle(cornerRadius: 5)
.foregroundStyle(color)
.frame(width: 48, height: 48)
}
.matchedTransitionSource(id: color, in: namespace)
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment