49

GitHub - sindresorhus/DockProgress: Show progress in your app's Dock ico...

 5 years ago
source link: https://github.com/sindresorhus/DockProgress
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

readme.md

DockProgress

Show progress in your app's Dock icon

screenshot.gif

This package is used in production by the Gifski app. You might also like some of my other apps.

Requirements

  • macOS 10.12+
  • Xcode 10+
  • Swift 4.2+

Install

SwiftPM

.package(url: "https://github.com/sindresorhus/DockProgress", from: "1.3.0")

Carthage

github "sindresorhus/DockProgress"

CocoaPods

pod 'DockProgress'
68747470733a2f2f63352e70617472656f6e2e636f6d2f65787465726e616c2f6c6f676f2f6265636f6d655f615f706174726f6e5f627574746f6e4032782e706e67

Usage

Manually set the progress

import Cocoa
import DockProgress

foo.onUpdate = { progressValue in
	DockProgress.progressValue = progressValue
}

Specify a Progress instance

import Cocoa
import DockProgress

let progress = Progress(totalUnitCount: 1)
progress?.becomeCurrent(withPendingUnitCount: 1)

DockProgress.progress = progress

Styles

It comes with three 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

import DockProgress

DockProgress.style = .bar

This is the default.

Circle

import DockProgress

DockProgress.style = .circle(radius: 55, color: .systemBlue)

Make sure to set a radius that matches your app icon.

Badge

import DockProgress

DockProgress.style = .badge(color: .systemBlue, badgeValue: { getDownloadCount() })

Large badgeValue numbers will be written in kilo short notation, for example, 10121k.

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.

Related

License

MIT © Sindre Sorhus


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK