I am applying a background modifier to a SwiftUI view that darkens and makes inactive the view until either: 1 the user selects options from the pop-up menu OR 2 taps on the dark-overlay to cancel modifying their profile-picture.
Currently this is working except the overlay does not darken the navigation tool-bar, only the main-view...
I tried placing the background before the tool-bar declaration - did not work, also tried applying it to each individual tool-bar item but it would only darken the individual button.
How can I apply this overlay ALSO to the toolbar?
Code and image below...
struct EditProfileMenu: View {
@State private var openProfilePictureAction: Bool = false
// ^ presents HalfActionSheet
var body: some View {
NavigationView {
ZStack {
VStack {
Text("CHANGE PROFILE PICTURE")
.onTapGesture { self.openProfilePictureAction = true }
}
.toolbar(content: {
// TOOL BAR BUTTONS SAVE AND CANCEL
})
VStack {
Spacer()
HalfActionSheet() .offset(y: self.openProfilePictureAction ? 0 : UIScreen.main.bounds.height)
}
// HOW CAN I APPLY THIS TO THE TOOLBAR?
.background(self.openProfilePictureAction ? Color.black.opacity(0.6) : Color.clear)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
self.openProfilePictureAction = false
}
.edgesIgnoringSafeArea(.bottom)
}
}
}
}