-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dynamic color extension * Add a basic theme * Add DocC theme * Fix block spacing logic * Update theme initializer * Add DocC theme tests * Add GitHub theme
- Loading branch information
1 parent
0838208
commit c91729d
Showing
52 changed files
with
976 additions
and
310 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import SwiftUI | ||
|
||
extension Color { | ||
public init(rgba: UInt32) { | ||
self.init( | ||
red: CGFloat((rgba & 0xff00_0000) >> 24) / 255.0, | ||
green: CGFloat((rgba & 0x00ff_0000) >> 16) / 255.0, | ||
blue: CGFloat((rgba & 0x0000_ff00) >> 8) / 255.0, | ||
opacity: CGFloat(rgba & 0x0000_00ff) / 255.0 | ||
) | ||
} | ||
|
||
public init(light: @escaping @autoclosure () -> Color, dark: @escaping @autoclosure () -> Color) { | ||
#if os(macOS) | ||
self.init( | ||
nsColor: .init(name: nil) { appearance in | ||
if appearance.bestMatch(from: [.aqua, .darkAqua]) == .aqua { | ||
return NSColor(light()) | ||
} else { | ||
return NSColor(dark()) | ||
} | ||
} | ||
) | ||
#elseif os(iOS) || os(tvOS) | ||
self.init( | ||
uiColor: .init { traitCollection in | ||
switch traitCollection.userInterfaceStyle { | ||
case .unspecified, .light: | ||
return UIColor(light()) | ||
case .dark: | ||
return UIColor(dark()) | ||
@unknown default: | ||
return UIColor(light()) | ||
} | ||
} | ||
) | ||
#elseif os(watchOS) | ||
self.init(uiColor: dark()) | ||
#endif | ||
} | ||
} |
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
Oops, something went wrong.