forked from scribe-org/Scribe-iOS
-
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.
scribe-org#216: added all colors to Assets file, added enum, refactor…
…ed ColorVariables.swift
- Loading branch information
Showing
33 changed files
with
880 additions
and
223 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ScribeColor.swift | ||
// Scribe | ||
// | ||
// Created by Michael Steudter - @misteu on 04.10.22. | ||
// | ||
|
||
import UIKit | ||
|
||
/// All the colors defined in `Assets.xcassets/Colors` | ||
enum ScribeColor: String { | ||
case annotateBlue | ||
case annotateGreen | ||
case annotateOrange | ||
case annotatePurple | ||
case annotateRed | ||
case annotateTitle | ||
case commandBar | ||
case commandBarBorder | ||
case commandBarInfoButton | ||
case commandKey | ||
case key | ||
case keyChar | ||
case keyPressed | ||
case keyShadow | ||
case keySpecial | ||
case keyboardBackground | ||
case scribeBlue | ||
case scribeGray | ||
|
||
/// `UIColor` object for the given | ||
var color: UIColor { | ||
.init(self) | ||
} | ||
} |
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,36 @@ | ||
// | ||
// UIColor+ScribeColors.swift | ||
// Scribe | ||
// | ||
// Created by Michael Steudter - @misteu on 04.10.22. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIColor { | ||
|
||
// MARK: - Init from ScribeColor | ||
|
||
/// Creates `UIColor` from passed `ScribeColor` | ||
/// - Parameter color: The `UIColor`. | ||
/// | ||
/// Defaults to `UIColor.red` if passed color was not found in assets. | ||
convenience init(_ color: ScribeColor) { | ||
if UIColor(named: color.rawValue) != nil { | ||
self.init(named: color.rawValue)! | ||
} else { | ||
print("unable to find color named: \(color.rawValue)") | ||
self.init(red: 1, green: 0, blue: 0, alpha: 1) | ||
} | ||
} | ||
|
||
/// Convenience computed property for light mode variant of the color. | ||
var light: UIColor { | ||
resolvedColor(with: .init(userInterfaceStyle: .light)) | ||
} | ||
|
||
/// Convenience computed property for dark mode variant of the color. | ||
var dark: UIColor { | ||
resolvedColor(with: .init(userInterfaceStyle: .light)) | ||
} | ||
} |
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.