ProgressUI
is a SwiftUI package that provides a highly customizable circular progress indicator. It supports dynamic coloring based on progress states, multiple size options, and smooth animations, making it perfect for showing progress, loading states, or status indicators in your iOS, macOS, watchOS, visionOS, and tvOS applications.
- π¨ Dynamic progress colors based on state
- π Spinner mode for loading states
- π Multiple size options (small/large/custom)
- β‘οΈ Smooth animations and transitions
- π― Customizable track and progress colors
- π Adjustable stroke widths
- π² Round or square line caps
Add the package by going to your Xcode project:
- Select your project in the file navigator
- Choose the project or target where you want to add the package
- Go to the Package Dependencies tab
- Click the
+
button - Search for
ProgressUI
using the repository URL:https://github.com/PierreJanineh-com/ProgressUI
Check out the full example in this here.
import SwiftUI
import ProgressUI
struct ContentView: View {
var body: some View {
ProgressUI(progress: 0.5)
}
}
enum StorageStatus: CaseIterable, Progressable {
case safe
case warning
case critical
case full
var color: Color { innerColor.opacity(0.4) }
// Optional: Add inner color for layered effect
var innerColor: Color? {
switch self {
case .safe: return .green
case .warning: return .yellow
case .critical: return .orange
case .full: return .red
}
}
static func calculate(from progress: CGFloat) -> Status {
let level: CGFloat = CGFloat(1) / CGFloat(Status.allCases.count)
return switch progress {
case 0...level: Excellent
case level...(level * 2): Normal
case (level * 2)...(level * 3): SemiNormal
case (level * 3)...(level * 4): Bad
case (level * 4)...(level * 5): Critical
default: Danger
}
}
}
struct ContentView: View {
@State private var progress: CGFloat = 0.0
var body: some View {
ProgressUI(
progress: $progress,
options: .init(isRounded: true),
statusType: StorageStatus.self
)
}
}
struct LoadingView: View {
var body: some View {
ProgressUI(
progress: .constant(1),
options: .init(
isSpinner: true,
growFrom: .center,
spinnerCycleDuration: 2,
progressColor: .blue
)
)
}
}
let options = Options(
size: .large, // Size preset
trackColor: .gray, // Color of the background track
trackWidth: 45, // Custom track width
animationMaxValue: 0.06, // Progress threshold for width animation
animation: .easeInOut, // Custom animation
innerProgressWidth: 5, // Width of inner progress line
innerProgressColor: .blue.opacity(0.3), // Optional inner progress color
progressColor: .blue, // Main progress color
isRounded: true, // Round or square line caps
isClockwise: true, // Rotation direction
growFrom: .end, // Growth direction
isSpinner: false, // Enable spinner mode
spinnerCycleDuration: 2 // Duration of spinner rotation
shape: .circular // Duration of spinner rotation
)
The ProgressUI package supports the following platforms:
- iOS 14.0+
- macOS 11.0+
- macCatalyst 14.0+
- watchOS 7.0+
- tvOS 15.0+
- visionOS 1.0+
Feel free to contribute by creating issues or submitting pull requests. Before submitting, make sure to:
- Fork the repository.
- Create your feature branch
(git checkout -b feature/my-feature)
. - Commit your changes
(git commit -m 'Add some feature')
. - Push to the branch
(git push origin feature/my-feature)
. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.