-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add accent color preference and adoption across most elements
- Loading branch information
Showing
14 changed files
with
135 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import SwiftUI | ||
|
||
struct AccentColor: Identifiable { | ||
var id: String { name } | ||
var color: CodableColor | ||
var name: String | ||
} | ||
|
||
var accents: [AccentColor] = [ | ||
.init(color: CodableColor(.blue), name: "Blue"), | ||
.init(color: CodableColor(.purple), name: "Purple"), | ||
.init(color: CodableColor(.pink), name: "Pink"), | ||
.init(color: CodableColor(.red), name: "Red"), | ||
.init(color: CodableColor(.orange), name: "Orange"), | ||
.init(color: CodableColor(.yellow), name: "Yellow"), | ||
.init(color: CodableColor(.green), name: "Green"), | ||
.init(color: CodableColor(.gray), name: "Gray"), | ||
] | ||
|
||
struct CodableColor: RawRepresentable, Codable { | ||
let rawValue: String | ||
|
||
init(rawValue: String) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
init(_ color: Color) { | ||
let nsColor = NSColor(color).usingColorSpace(.deviceRGB)! | ||
let red = Int(nsColor.redComponent * 255) | ||
let green = Int(nsColor.greenComponent * 255) | ||
let blue = Int(nsColor.blueComponent * 255) | ||
let alpha = Int(nsColor.alphaComponent * 255) | ||
|
||
self.rawValue = String(format: "%02X%02X%02X%02X", red, green, blue, alpha) | ||
} | ||
|
||
func toColor() -> Color { | ||
let red = Double(Int(rawValue.prefix(2), radix: 16)!) / 255.0 | ||
let green = Double(Int(rawValue.dropFirst(2).prefix(2), radix: 16)!) / 255.0 | ||
let blue = Double(Int(rawValue.dropFirst(4).prefix(2), radix: 16)!) / 255.0 | ||
let alpha = Double(Int(rawValue.dropFirst(6).prefix(2), radix: 16)!) / 255.0 | ||
|
||
return Color(NSColor(calibratedRed: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters