PoweredTouchBar interfering with navigation split view

33 Views Asked by At

I have been trying to create a notes app using SwiftUI on XCode for macOS, and am trying to add Touch Bar support for MacBook pro users. I downloaded the PoweredTouchBar package, but when I use it, it always creates a bar on the top of the screen, which looks weird with NavigationSplitView.[the thing at the top](https://i.stack.imgur.com/j03CH.png)

Touchbar

PS in the code below, the ... means that i folded code.

import SwiftUI
import SwiftData
import PoweredTouchBar

struct Home: View {
    
    @State var text: String = ""
    //List selection - filter notes in each category
    @State private var selectedTag: String? = "All Notes"
    //query
    @Query(animation: .snappy) private var categories: [NoteCategory]
    //model context
    @Environment(\.modelContext) private var context
    //view properties
    @State private var addCategory: Bool = false
    @State private var categoryTitle: String = ""
    @State private var requestedCategory: NoteCategory?
    @State private var deleteRequest: Bool = false
    @State private var renameRequest: Bool = false
    //dark mode toggle
    @State private var isDark: Bool = false

    var body: some View {
        
        
        NavigationSplitView {...} detail: {...}
        .poweredTouchBar {
            PoweredTouchBarButton(identifier: "AddCategory.text", title: "Add Category", image: NSImage(systemSymbolName: "plus.bubble", accessibilityDescription: nil)!, action: {
                 addCategory.toggle()
             })
             PoweredTouchBarButton(identifier: "AddNote.text", title: "Add Note", image: NSImage(systemSymbolName: "plus", accessibilityDescription: nil)!, action: {
                 let note = Note(content: "")
                 context.insert(note)
             })
             
        }
        .navigationTitle(selectedTag ?? "Notes")
        //adding alert(confirmation)
        .alert("Add Category", isPresented: $addCategory) {
            TextField("eg. Work", text: $categoryTitle)
            
            Button("Cancel", role: .cancel) {
                categoryTitle = ""
            }
            
            Button("Add") {
                //adding a new category
                let category = NoteCategory(categoryTitle: categoryTitle)
                context.insert(category)
                categoryTitle = ""
            }
        }
        //alert for rename
        .alert("Rename Category", isPresented: $renameRequest) {...}
        //delete alert
        .alert("Are you sure you want to delete '\(categoryTitle)'?", isPresented: $deleteRequest) {...}
        }
        //Tool Bar Items
        .toolbar {...}
        .preferredColorScheme(isDark ? .dark : .light)
        
    }
}

#Preview {
    Home() // or ContentView()
}
0

There are 0 best solutions below