I have a view with structure like this:
struct ContentView: View {
@ObservedObject private var viewModel = MyViewModel()
var body: some View {
ZStack {
VStack {
// Several buttons and input forms
}
// the viewModel has published states.
switch viewModel.state {
case .loading:
ProgressView()
case .finish:
// ...
case .error:
// ...
}
}
}
}
What I want to achieve is to simply avoid user interacting with any other components if the ProgressView
appeared, but couldn't find a good way...
You can use the .disabled<\/code> modifier on your controls.
Button("Button") { //action }.disabled(isLoading)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.