Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/dockprogress
Show progress in your app's Dock icon
https://github.com/sindresorhus/dockprogress
dock icon macos progress-bar progress-circle swift swift-package
Last synced: about 9 hours ago
JSON representation
Show progress in your app's Dock icon
- Host: GitHub
- URL: https://github.com/sindresorhus/dockprogress
- Owner: sindresorhus
- License: mit
- Created: 2018-03-01T20:22:12.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-03-30T15:35:52.000Z (9 months ago)
- Last Synced: 2024-12-20T16:23:26.328Z (1 day ago)
- Topics: dock, icon, macos, progress-bar, progress-circle, swift, swift-package
- Language: Swift
- Homepage: https://swiftpackageindex.com/sindresorhus/DockProgress/documentation/dockprogress/dockprogress
- Size: 3.31 MB
- Stars: 1,286
- Watchers: 13
- Forks: 59
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# DockProgress
> Show progress in your app's Dock icon
## Requirements
macOS 10.15+
## Install
Add `https://github.com/sindresorhus/DockProgress` in the [“Swift Package Manager” tab in Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).
*Latest version: 4.3.1*
## API
[See the API docs.](https://swiftpackageindex.com/sindresorhus/DockProgress/documentation/dockprogress/dockprogress)
## Usage
### Manually set the progress
```swift
import DockProgressfoo.onUpdate = { progress in
DockProgress.progress = progress
}
```### Specify a [`Progress` instance](https://developer.apple.com/documentation/foundation/progress)
```swift
import Foundation
import DockProgresslet progress = Progress(totalUnitCount: 1)
progress?.becomeCurrent(withPendingUnitCount: 1)DockProgress.progressInstance = progress
```The given `Progress` instance is weakly stored. It's up to you to retain it.
## Styles
It comes with five styles. PR welcome for more.
Check out the example app in the Xcode project.
You can also draw a custom progress with `.custom(drawHandler: (_ rect: CGRect) -> Void)`.
### Bar
![](screenshot-bar.gif)
```swift
import DockProgressDockProgress.style = .bar
```This is the default.
### Squircle
```swift
import DockProgressDockProgress.style = .squircle(color: .white.withAlphaComponent(0.5))
```By default, it should perfectly fit a macOS 11 and later icon, but there is an `inset` parameter if you need to make any adjustments.
### Circle
![](screenshot-circle.gif)
```swift
import DockProgressDockProgress.style = .circle(radius: 55, color: .systemBlue)
```### Badge
![](screenshot-badge.gif)
```swift
import DockProgressDockProgress.style = .badge(color: .systemBlue, badgeValue: { getDownloadCount() })
```Large `badgeValue` numbers will be written in kilo short notation, for example, `1012` → `1k`.
**Note:** The `badgeValue` is not meant to be used as a numeric percentage. It's for things like count of downloads, number of files being converted, etc.
### Pie
```swift
import DockProgressDockProgress.style = .pie(color: .systemBlue)
```## Related
- [Defaults](https://github.com/sindresorhus/Defaults) - Swifty and modern UserDefaults
- [KeyboardShortcuts](https://github.com/sindresorhus/KeyboardShortcuts) - Add user-customizable global keyboard shortcuts to your macOS app
- [LaunchAtLogin](https://github.com/sindresorhus/LaunchAtLogin) - Add "Launch at Login" functionality to your macOS app
- [More…](https://github.com/search?q=user%3Asindresorhus+language%3Aswift+archived%3Afalse&type=repositories)