Navigation bar menu with a number of choice in iOS app with SwiftUI

[ad_1]

I need to obtain habits near native iOS reminders app on iPad.
There may be dropdown Menu in NavigationBar that exhibits tags in it. I believed that I can do it with Picker however as I see there’s now a number of choice assist in it.

enter image description here

I did it utilizing

...
.toolbar {
  ToolbarItemGroup(placement: .navigationBarTrailing) {
      Menu {
         MenuView()
      } label: {
          Picture(systemName: "quantity")
         }
            
      Button("Executed") {}
      }
    }

And MenuView’s code is

struct MenuView: View {

@State var tags = ["#tag1", "#tag2", "#tag3", "#tag4"]

var physique: some View {
    ForEach(tags, id:.self) { tag in
        Button {
        } label: {
            if selectedTags.accommodates(tag) {
                Label(tag, systemImage: "checkmark")
            } else {
                Textual content(tag)
            }
        }
    }
    
    Part {
        Button {
            
        } label: {
            Label("Configure", systemImage: "ellipsis")
        }

    }
}

}

The principle drawback proper now could be after I press any of this buttons, drop down is closed, whereas I would like this button to solely toggle chosen standing.

I attempted to make use of Textual content as a substitute of buttons however did not discover method to deal with faucet gestures from them, they seem like being disabled by some view modifier.

What’s the optimum method to deal with it?

[ad_2]

Leave a Reply