Swiftpack.co - ChimeHQ/Dusk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ChimeHQ.
ChimeHQ/Dusk 1.1.4
Micro-framework to aid in supporting Dark Mode on macOS
⭐️ 21
🕓 45 weeks ago
macOS
.package(url: "https://github.com/ChimeHQ/Dusk.git", from: "1.1.4")

Build Status Platforms

Dusk

Dusk is a small framework to aid in supporting Dark Mode on macOS. It is particularly useful for applications that use full-window theming, or need to support earlier OSes.

This project was made much easier thanks to the hard work of two people.

Paulo Andrade's post about Adopting Dark Mode and Older Macs was great for understanding how to subclass NSColor.

Daniel Jalkut published a fantastic series about adopting Dark Mode on macOS. Many of the ideas, and even some of the code he presented, have found their way into this project.

Integration

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/Dusk", from: "1.1.4")
]

Classes

DynamicColor

A handy NSColor subclass that makes it easier to use dynamic colors when you aren't able to store colors in asset catalogs. It provides two APIs, one that mimics NSColor(name:dynamicProvider:), and another that let's you more easily define a light and dark variant of an NSColor instance.

DynamicColor(name: "uniqueColorName") { (appearance) in 
    ...
}

DynamicColor(name: "uniqueColorName", lightColor: NSColor.white, darkColor: NSColor.black)

AppearanceObserver

A very simple class that will observe effective appearance changes and post a notification when triggered. Useful when created within an NSApplication delegate for application-wide notifications.

NSAppearance Extensions

Querying:

appearance.isDark

appearance.oppositeAppearance

NSAppearance.withCurrent(.aqua) {
    ...
}

Contributing and Collaboration

I'd love to hear from you! Get in touch via an issue or pull request.

I prefer collaboration, and would love to find ways to work together if you have a similar project.

I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.

By participating in this project you agree to abide by the Contributor Code of Conduct.

GitHub

link
Stars: 21
Last commit: 24 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

v1.1.4
45 weeks ago
  • SPM only now

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics