8000 GitHub - PierreJanineh-com/ProgressUI: A highly customizable and animated circular/linear progress indicator for SwiftUI. Supports dynamic coloring, spinner mode, multiple sizes, and easy appearance customization.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A highly customizable and animated circular/linear progress indicator for SwiftUI. Supports dynamic coloring, spinner mode, multiple sizes, and easy appearance customization.

License

Notifications You must be signed in to change notification settings

PierreJanineh-com/ProgressUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ProgressUI

SPM

Example ProgressUI

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.

Features

  • 🎨 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

Installation

Swift Package Manager

Add the package by going to your Xcode project:

  1. Select your project in the file navigator
  2. Choose the project or target where you want to add the package
  3. Go to the Package Dependencies tab
  4. Click the + button
  5. Search for ProgressUI using the repository URL:
    https://github.com/PierreJanineh-com/ProgressUI

Usage

Check out the full example in this here.

Basic Usage

import SwiftUI
import ProgressUI

struct ContentView: View {
    var body: some View {
        ProgressUI(progress: 0.5)
    }
}

Progress with Dynamic Colors

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
        )
    }
}

Loading Spinner

struct LoadingView: View {
    var body: some View {
        ProgressUI(
            progress: .constant(1),
            options: .init(
                isSpinner: true,
                growFrom: .center,
                spinnerCycleDuration: 2,
                progressColor: .blue
            )
        )
    }
}

Customization Options

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
)

Platforms

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+

Contribution

Feel free to contribute by creating issues or submitting pull requests. Before submitting, make sure to:

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/my-feature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/my-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

A highly customizable and animated circular/linear progress indicator for SwiftUI. Supports dynamic coloring, spinner mode, multiple sizes, and easy appearance customization.

Topics

Resources

License

Stars

Watchers

Forks

Languages

0