Minor tweaks

This commit is contained in:
Sindre Sorhus 2019-01-27 17:22:30 +07:00
parent 7c5f842b26
commit c140f1112e
3 changed files with 10 additions and 6 deletions

View File

@ -12,8 +12,8 @@ public final class DockProgress {
public static var progress: Progress? {
didSet {
if let progress = progress {
progressObserver = progress.observe(\.fractionCompleted) { object, _ in
progressValue = object.fractionCompleted
progressObserver = progress.observe(\.fractionCompleted) { sender, _ in
progressValue = sender.fractionCompleted
}
}
}

View File

@ -59,16 +59,19 @@ final class ProgressCircleShapeLayer: CAShapeLayer {
}
}
extension NSColor {
func with(alpha: Double) -> NSColor {
return withAlphaComponent(CGFloat(alpha))
}
}
extension NSFont {
static let helveticaNeueBold = NSFont(name: "HelveticaNeue-Bold", size: 0)
}
extension CGRect {
var center: CGPoint {
get {
@ -113,6 +116,7 @@ extension NSBezierPath {
}
}
/// Fixes the vertical alignment issue of the `CATextLayer` class.
final class VerticallyCenteredTextLayer: CATextLayer {
convenience init(frame rect: CGRect, center: CGPoint) {

View File

@ -47,8 +47,8 @@ pod 'DockProgress'
import Cocoa
import DockProgress
foo.onUpdate = { progress in
DockProgress.progressValue = progress
foo.onUpdate = { progressValue in
DockProgress.progressValue = progressValue
}
```
@ -67,7 +67,7 @@ DockProgress.progress = progress
## Styles
It comes with two styles. PR welcome for more.
It comes with three styles. PR welcome for more.
Check out the example app in the Xcode project.
@ -107,7 +107,7 @@ import DockProgress
DockProgress.style = .badge(color: .systemBlue, badgeValue: { getDownloadCount() })
```
Large `badgeValue` numbers will be written in kilo short notation, for example, `1000` → `1k`.
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.