-
-
Save laevandus/8de8c142960d80ab288386d4b772eb20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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