I have a pretty usual app with a TabView
. However, when a particular process is happening in one of the content views, I would like to prevent the user from switching tabs until that process is complete.
If I use the disabled
property on the TabView
itself (using a @State
binding to drive it), then the entire content view seems disabled - taps don't appear to be getting through to buttons on the main view.
Example:
struct FooView: View {
var body: some View {
TabView {
View1().tabItem(...)
View2().tabItem(...)
}
.disabled(someStateVal)
}
}
Obviously, I want the View1
to still allow the user to, you know, do things. When someStateVal
is true, the entire View1
doesn't respond.
Is there a way to prevent changing tabs based on someStateVal
?
Thanks!