Show progress in your app's Dock icon

Overview

DockProgress

Show progress in your app's Dock icon

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

Requirements

  • macOS 10.12+
  • Xcode 12+
  • Swift 5.3+

Install

Swift Package Manager

Add https://github.com/sindresorhus/DockProgress in the “Swift Package Manager” tab in Xcode.

Carthage

github "sindresorhus/DockProgress"

CocoaPods

pod 'DockProgress'

Usage

Manually set the progress

import Cocoa
import DockProgress

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

Specify a Progress instance

import Cocoa
import DockProgress

let 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 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.

Squircle

import DockProgress

DockProgress.style = .squircle(color: .white.withAlphaComponent(0.5))

By default, it should perfectly fit a macOS 11 icon, but there's a inset parameter if you need to make any adjustments.

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

  • Defaults - Swifty and modern UserDefaults
  • Preferences - Add a preferences window to your macOS app in minutes
  • KeyboardShortcuts - Add user-customizable global keyboard shortcuts to your macOS app
  • LaunchAtLogin - Add "Launch at Login" functionality to your macOS app
  • Regex - Swifty regular expressions
  • More…
Comments
  • Add `badge` circle style

    Add `badge` circle style

    Hi,

    I implemented #3 and updated the example to loop through it as well. Let me know if there are any things you'd like me to change or fix.

    The badgeLabel only allows for 3 characters though, after that it will truncate because text resizing in CATextLayer is very hard (I tried for several hours but couldn't find a solution) and not really useful anyways imo.

    Best regards, Joni

    edit: I'm sorry about the number of commits, I wasn't fully satisfied with how it looked. Feel free to squash if you feel like that looks cleaner.

    Fixes #3

    opened by JoniVR 20
  • Make the progress animation smoother

    Make the progress animation smoother

    Fixes #1

    When you change the progress variable it schedules evenly spaces calls to change the animatedProgress variable. The animatedProgress variable then changes the previous progress and calls updateDockIcon()

    public variables: stepDuration - Default Value: 0.05 (5ms) - How long to wait between every "render" totalSteps - Default Value: 30 - How many steps there should be between 0 to 1


    IssueHunt Summary

    Referenced issues

    This pull request has been submitted to:


    IssueHunt has been backed by the following sponsors. Become a sponsor

    opened by benkoska 8
  • Badge circle style

    Badge circle style

    Issuehunt badges

    Would be nice to have a badge circle style like what Chrome has for downloads:

    screen shot 2018-02-25 at 21 13 55

    jonivr earned $80.00 by resolving this issue!

    enhancement help wanted :gift: Rewarded on Issuehunt 
    opened by sindresorhus 5
  • MacOS 10.14 Icon transparency

    MacOS 10.14 Icon transparency

    Am testing first 10.14 beta and noticed that the dock icon for Gifski during gif conversion resulted in the icon being 100% transparent(Invisible) and did not reset until app restart.

    screenshot 2018-06-11 at 04 48 14 screenshot 2018-06-11 at 04 48 32

    I know not priority as still beta MacOS version, but still worth reporting.

    opened by NuroDev 1
  • Dock icon insertion

    Dock icon insertion

    Hi @sindresorhus , would it be possible to insert an icon that you want or that is part of the sf symbols, as you can see in the video below?

    https://user-images.githubusercontent.com/20476002/192090936-2bd7505e-fb47-486e-83e9-4cbdd3c8d0b5.mov

    enhancement help wanted 
    opened by Angelk90 1
  • Accept an `AsyncSequence`

    Accept an `AsyncSequence`

    Just like we do with Progress.

    When macOS 12 is out.

    https://github.com/apple/swift-evolution/blob/main/proposals/0314-async-stream.md

    I'm not yet sure what to call the API. I think we can just wait and see what kind of naming Apple decides to use for properties.

    opened by sindresorhus 0
  • SwiftUI support

    SwiftUI support

    https://developer.apple.com/tutorials/swiftui/

    • [ ] Make .custom() accept a SwiftUI View.
    • [ ] Example of using the .custom() in the Example app
    • [ ] Docs
    • [ ] Tests

    Anything other ideas?


    This issue requires you to have advanced Swift knowledge.

    enhancement help wanted 
    opened by sindresorhus 0
  • Draw directly in the Dock tile contentView

    Draw directly in the Dock tile contentView

    Issuehunt badges

    Instead of first drawing the image and then adding it as an image to the Dock tile contentView. I think that would be slightly more efficient.

    https://github.com/sindresorhus/DockProgress/blob/2fd7035c8c17e28b261efa04da91d3a6ad403cf2/Sources/DockProgress/DockProgress.swift#L46

    There is a $40.00 open bounty on this issue. Add more on Issuehunt.

    enhancement help wanted :dollar: Funded on Issuehunt 
    opened by sindresorhus 1
  • Make the progress animation smoother

    Make the progress animation smoother

    Issuehunt badges

    https://github.com/sindresorhus/DockProgress/blob/2fd7035c8c17e28b261efa04da91d3a6ad403cf2/Sources/DockProgress/DockProgress.swift#L40

    Right now it only updates each time progressValue is updated or the NSProgress instance in progress changes. Let say you use this to update on each processed frame of a video, so the longer the video is, the smoother the progress animation is. That also means it will be pretty choppy on short clips.

    Normally you would use a CALayer, which would animate between the progress events. This is however not possible for the Dock icon as we have to call .display() manually each time we want to update it. I tried to use CALayer and just capture an image of the layer 30 times a second, but it seems it's only possible to capture before or after the animation.

    I think the solution is to simply implement the animation ourselves with an interval timer. We already have the previous progress and the current progress, so we can animate between them. It's a bit more complicated though as if we receive a new progress change while we're animation, we now need to animate to the new progress.

    I'm also happy to consider other ideas.

    I think we should also fade-in and fade-out the progress animation so it doesn't just suddenly appear at 0% and disappear at 100%.


    IssueHunt Summary

    Backers (Total: $100.00)

    Submitted pull Requests


    Become a backer now!

    Or submit a pull request to get the deposits!

    Tips


    IssueHunt has been backed by the following sponsors. Become a sponsor

    enhancement help wanted :dollar: Funded on Issuehunt 
    opened by sindresorhus 2
Releases(v4.0.1)
  • v4.0.1(Jun 8, 2022)

    • Improve compatibility with Xcode 14 https://github.com/sindresorhus/DockProgress/commit/d185101d682a7487773b8453053eb5d61b66dc12

    https://github.com/sindresorhus/DockProgress/compare/v4.0.0...v4.0.1

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(May 30, 2022)

    Breaking

    • Require macOS 10.15 and later
    • Drop support for CocoaPods and Carthage
    • DockProgress is now annotated with @MainActor
    • The DockProgress.ProgressStyle type is renamed to DockProgress.Style

    https://github.com/sindresorhus/DockProgress/compare/v3.2.0...v4.0.0

    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Dec 1, 2020)

    • Squircle style https://github.com/sindresorhus/DockProgress/commit/4fd9ae951f65380465a830d9a3724fb3c1ec8a89

    https://github.com/sindresorhus/DockProgress/compare/v3.1.0...v3.2.0

    Source code(tar.gz)
    Source code(zip)
  • v3.1.0(Jul 25, 2020)

  • v3.0.0(Feb 9, 2020)

    Breaking

    • Store the Progress instance weakly https://github.com/sindresorhus/DockProgress/commit/3365c2be401b47bf4ab4fe7aa0ffbf7d1a9658fc
      • Previously, DockProgress retained it forever, unless you manually sat .progressInstance = nil. This is really a bug fix, but it's a major release as some projects might depend on the previous behavior. To upgrade, just make sure you retain the Progress instance yourself.

    https://github.com/sindresorhus/DockProgress/compare/v2.1.0...v3.0.0

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Dec 2, 2019)

  • v2.0.0(Mar 26, 2019)

    Breaking:

    • Upgrade to Swift 5 https://github.com/sindresorhus/DockProgress/commit/1eb3fbfdb9a3c98bc4c79d3cd2809bde408a81b9
    • Rename .progress to .progressInstance https://github.com/sindresorhus/DockProgress/commit/9918da972d318038e70946883ad79f5ec050d0d7
    • Rename .progressValue to .progress https://github.com/sindresorhus/DockProgress/commit/5f992fe389d9a9b0a5bb2086ff0cfe9a4ba81579
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 27, 2019)

    • Add badge style (#7) https://github.com/sindresorhus/DockProgress/commit/c4766cb4814526a0e527d364e6ef7cce5541603a
    • Add resetProgress() method https://github.com/sindresorhus/DockProgress/commit/cc5918267a430c647fab935efa5b3ccce0a4f5a4
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jan 2, 2019)

    • Upgrade to Swift 4.2 https://github.com/sindresorhus/DockProgress/commit/185e501d83b3349025fc20cb1922d703984f26e6
    • Fix a Gatekeeper issue https://github.com/sindresorhus/DockProgress/commit/bdd59f9ca0ac1aef59478b7ea2ffbafb260c208f
    Source code(tar.gz)
    Source code(zip)
Owner
Sindre Sorhus
Full-Time Open-Sourcerer. Wants more empathy & kindness in open source. Focuses on Swift & JavaScript. Makes macOS apps, CLI tools, npm packages. Likes unicorns
Sindre Sorhus
Work in progress gallery of controls available to Catalyst apps using Optimized for Mac

Catalyst Controls Gallery Very simple work-in-progress demonstration of many common controls available to Mac Catalyst as of macOS 11. Provided moreso

Steven Troughton-Smith 163 Sep 18, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Circular progress indicator for your macOS app

CircularProgress Circular progress indicator for your macOS app This package is used in production by apps like Gifski and HEIC Converter. Requirement

Sindre Sorhus 520 Jan 3, 2023
📊 A customizable gradient progress bar (UIProgressView).

GradientProgressBar A customizable gradient progress bar (UIProgressView). Inspired by iOS 7 Progress Bar from Codepen. Example To run the example pro

Felix M. 490 Dec 16, 2022
A custom reusable circular / progress slider control for iOS application.

HGCircularSlider Example To run the example project, clone the repo, and run pod install from the Example directory first. You also may like HGPlaceho

Hamza Ghazouani 2.4k Jan 6, 2023
💈 Retro looking progress bar straight from the 90s

Description Do you miss the 90s? We know you do. Dial-up internet, flickering screens, brightly colored websites and, of course, this annoyingly slow

HyperRedink 18 Nov 24, 2022
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Yonat Sharon 340 Dec 16, 2022
Snapchat / Instagram Stories like progress indicator

SegmentedProgressBar A simple little control that animates segments like Snapchat or Instagram Stories. Requirements iOS 8.0+ Xcode 8 Installation Dra

Dylan Marriott 442 Dec 25, 2022
Measuring the progress with annotations 🔱

Description Displaying the progress in a meter control. ProgressMeter lets you create your custom annotations that display either on top or bottom of

Khawaja Farooq 108 Oct 5, 2022
A dynamically flowing progress bar.

WWProgressView A dynamically flowing progress bar. 一個動態流動的進度條. Installation with Swift Package Manager dependencies: [ .package(url: "https://gith

William-Weng 5 Jan 25, 2022
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features ✨ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

Kingiol 154 Dec 3, 2022
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 6, 2023
Fetch the star wars api from all the planets and list and show details using Swift UI and Combine

Star Wars Planets Fetch the star wars planet data by using stat war api, list and show details using SwiftUI and Combine frameworks ?? Swift UI Framew

null 1 Aug 10, 2022
Show the weather effects onto view written in Swift4.2

URWeatherView What is this for? Showing some kinds of the weather effect, written in Swift4.2. This code style is the Protocol Oriented Programming. T

Urtaq 449 Dec 28, 2022
A beautiful radar view to show nearby items (users, restaurants, ...) with ripple animation, fully customizable

HGRippleRadarView Example To run the example project, clone the repo, and run pod install from the Example directory first. This project is inspired b

Hamza Ghazouani 352 Dec 4, 2022
ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

Kushal Shingote 2 May 25, 2022
Custom emojis are a fun way to bring more life and customizability to your apps.

Custom emojis are a fun way to bring more life and customizability to your apps. They're available in some of the most popular apps, such as Slack, Di

Stream 244 Dec 11, 2022
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
Beautiful flag icons for usage in apps and on the web.

FlagKit Beautiful flag icons for usage in apps and on the web. All flags are provided as stand-alone PNG and SVG files. FlagKit also provides an Asset

Bowtie 2.9k Dec 29, 2022