What is a ProgressView
Like we had in UIKit, ProgressView is our new UIActitityIndicator and UIProgressView combined into a new SwiftUI component, ProgressView.
When building your iOS application, you’ll likely need to display a View that shows something is happening in the background, names like “Loading HUD” or “Loading Spinner” are likely familiar to you. In SwiftUI you can do this very simply by using the ProgressView.
This is how to create a very simple Progress Indicator that will run continuously until you remove or hide this view.
You can also pass through some text to display below the Progress Indicator.
Determinate & Indeterminate Loading
This is super useful when you’re unsure of how long the progress will be, and we call this an Indeterminate Progress Indicator.
UIActivityIndicator was the equivalent here within UIKit and was used for the same reason. However, if you know or have data on how long a process is taking or going to take this would be called a Determinate Progress Indicator and we would use a UIProgressView within UIKit, well now it’s included directly in ProgressView.
ProgressView(value: 10, total: 100)
We do this by using the
total: parameters. Here, you are setting the current value to 10, but in a real app, you would dynamically set this based on your data.