Skip to content

Commit

Permalink
Default urlColor to AccentColor or .linkColor
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
jessesquires committed Nov 17, 2021
1 parent 15e9018 commit cbbd9c4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
20 changes: 20 additions & 0 deletions Example/Sources/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x1A",
"green" : "0x16",
"red" : "0xE0"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 3 additions & 3 deletions Example/Sources/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
3 changes: 1 addition & 2 deletions Example/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ final class ViewController: NSViewController {
@IBAction func didClickDisplay(_ sender: NSButton) {
let metadata = AppMetadata(versionText: Bundle.main.fullVersionString!,
altVersionText: "🎉 optional \"easter egg\" text 🎉",
url: URL(string: "https://hexedbits.com")!,
urlColor: .systemRed)
url: URL(string: "https://hexedbits.com")!)
let panel = AboutThisAppPanel(metadata: metadata)
panel.makeKeyAndOrderFront(nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Example/Tests/ExampleAppTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class ExampleAppTests: XCTestCase {
XCTAssertEqual(metadata.versionText, "Version 1.2.3")
XCTAssertEqual(metadata.altVersionText, "Version 1.2.3 (666)")
XCTAssertEqual(metadata.url, nil)
XCTAssertEqual(metadata.urlColor, .systemBlue)
XCTAssertEqual(metadata.urlColor, NSColor(named: "AccentColor"))
XCTAssertEqual(metadata.copyrightText, "Copyright © 2020 Hexed Bits. All rights reserved.")
}
}
6 changes: 4 additions & 2 deletions Sources/AppMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public struct AppMetadata {
/// The app website url. The default is `nil`.
public let url: URL?

/// The link color for the url. The default is `.systemBlue`.
/// The link color for the url.
/// The default is the app accent color ("AccentColor") if present in your asset catalog,
/// otherwise `.linkColor`.
public let urlColor: NSColor

/// The app copyright information.
Expand All @@ -64,7 +66,7 @@ public struct AppMetadata {
versionText: String = Bundle.main.shortVersionString!,
altVersionText: String = Bundle.main.fullVersionString!,
url: URL? = nil,
urlColor: NSColor = .systemBlue,
urlColor: NSColor = NSColor(named: "AccentColor") ?? .linkColor,
copyrightText: String = Bundle.main.copyright!) {
self.icon = icon
self.iconSize = iconSize
Expand Down

0 comments on commit cbbd9c4

Please sign in to comment.