// Toolbar & Modal Sheet
struct CategoryHome: View {
@EnvironmentObject var modelData: ModelData
/// โญ๏ธ 1. control the presentation of the `ProfileHost` view
@State private var showingProfile = false
var body: some View {
NavigationView {
List { /* list items ... */ }
.navigationTitle("Featured")
/// โญ๏ธ 2. add a button to the navigation bar
.toolbar {
Button { showingProfile.toggle() } label: {
Label("User Profile", systemImage: "person.crop.circle")
}
}
/// โญ๏ธ 3. present the `ProfileHost` view when the user taps the button.
.sheet(isPresented: $showingProfile) {
ProfileHost().environmentObject(modelData)
}
}
}
}