# Presentations

{% tabs %}
{% tab title="💾 程式" %}
:point\_right: SwiftUI Tutorials ⟩ [Working with UI Controls](https://developer.apple.com/tutorials/swiftui/working-with-ui-controls) ⟩ [Display a User Profile](https://developer.apple.com/tutorials/swiftui/working-with-ui-controls#Display-a-User-Profile) - Step 8.

```swift
// 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)
                }
        }
    }
}
```
{% endtab %}

{% tab title="📘 手冊" %}
* SwiftUI Tutorials ⟩ [Working with UI Controls](https://developer.apple.com/tutorials/swiftui/working-with-ui-controls) ⟩ [Display a User Profile](https://developer.apple.com/tutorials/swiftui/working-with-ui-controls#Display-a-User-Profile) - Step 8.
* SwiftUI ⟩ View ⟩ &#x20;
  * [Auxiliary Views](https://developer.apple.com/documentation/swiftui/view-auxiliary-views)
    * [ToolbarItem](https://developer.apple.com/documentation/swiftui/toolbaritem) (<mark style="color:red;">**struct**</mark>)
    * [toolbar(content:)](https://developer.apple.com/documentation/swiftui/view/toolbar\(content:\)-7vdkx) - where Content : [`View`](https://developer.apple.com/documentation/swiftui/view)
    * [.toolbar(content:)](https://developer.apple.com/documentation/swiftui/view/toolbar\(content:\)-5w0tj) - where Content : [ToolbarContent](https://developer.apple.com/documentation/swiftui/toolbarcontent)
    * [.toolbar(id:content:)](https://developer.apple.com/documentation/swiftui/view/toolbar\(id:content:\)) - where Content : [`CustomizableToolbarContent`](https://developer.apple.com/documentation/swiftui/customizabletoolbarcontent)
  * View Presentation
    * [.sheet(isPresented:onDismiss:content:)](https://developer.apple.com/documentation/swiftui/view/sheet\(ispresented:ondismiss:content:\))
{% endtab %}

{% tab title="📗 參考" %}
* Design+Code  ⟩ SwiftUI Handbook ⟩ [ToolBar](https://designcode.io/swiftui-handbook-toolbar)
* Swift with Majid ⟩ [Mastering toolbars in SwiftUI](https://swiftwithmajid.com/2020/07/15/mastering-toolbars-in-swiftui/)
* Sarun ⟩ [How to dismiss sheet in SwiftUI](https://sarunw.com/posts/swiftui-dismiss-sheet/)
{% endtab %}

{% tab title="🖥️ 影片" %}
{% embed url="https://youtu.be/GrTveTQNObY" %}
tundsdev ⟩ How To Present And Dismiss Views In SwiftUI
{% endembed %}
{% endtab %}
{% endtabs %}
