Apologies, I missed the code formatting in the original post; see below.
//
// ContentView.swift
// ZoomNavigationTransitionSample
//
// Created by Matthew DuBois on 6/15/25.
//
import SwiftUI
struct ContentView: View {
@State private var isPresentingSheet = false
@Namespace private var namespace
var body: some View {
NavigationStack {
List {
Text("Some content")
}
.navigationTitle("Sample")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Button") {
isPresentingSheet = true
}
.matchedTransitionSource(id: "button", in: namespace)
}
}
.sheet(isPresented: $isPresentingSheet) {
Text("Some sheet content")
.navigationTransition(.zoom(sourceID: "button", in: namespace))
.presentationDetents([.medium])
}
}
}
}
#Preview {
ContentView()
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: