Exercise 2: Adding a Toolbar Button That Presents a Modal Sheet — Possible Solution ========================================================================================== struct NewTaskView: View { var body: some View { Text("New Task Form") .font(.title) .padding() } } struct TaskListView: View { @State private var isShowingSheet = false let tasks: [Task] = [ Task(title: "Buy groceries"), Task(title: "Finish report"), Task(title: "Call dentist"), Task(title: "Water plants"), Task(title: "Read a chapter") ] var body: some View { NavigationStack { List(tasks) { task in NavigationLink(task.title, value: task) } .navigationTitle("Tasks") .navigationDestination(for: Task.self) { task in TaskDetailView(task: task) } .toolbar { Button("Add") { isShowingSheet = true } } .sheet(isPresented: $isShowingSheet) { NewTaskView() } } } } HOW IT WORKS: isShowingSheet is a real @State private var, initially false. Tapping the toolbar's own "Add" Button sets it to true. The .sheet(isPresented: $isShowingSheet) modifier watches that same real binding - the moment it becomes true, SwiftUI automatically presents NewTaskView as a modal sheet floating above the current screen, and automatically resets isShowingSheet back to false once the user dismisses it (by swiping down, for instance) - the framework manages that reset without any extra code needed here. This is a genuinely different presentation style from the NavigationLink-based push navigation used for the task rows themselves - the sheet floats above TaskListView rather than replacing it in the navigation stack, and there's no back button involved in dismissing it. ANSWER: Adding @State private var isShowingSheet = false, a toolbar Button setting it true, and .sheet(isPresented: $isShowingSheet) presenting NewTaskView correctly shows a modal sheet when "Add" is tapped, using the exact isPresented pattern covered in the chapter. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly wires a Boolean @State flag through a toolbar button into .sheet(isPresented:), demonstrating the modal-presentation pattern as a genuinely separate mechanism from the push-navigation already built in Exercise 1.