Created
September 9, 2019 15:03
-
-
Save vince19972/70eee7d66735739aa31567efd7a0a475 to your computer and use it in GitHub Desktop.
Demo code of building color palette system in SwiftUI
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
struct BaseColor { | |
/// dynamic color sets (with dark and light mode) | |
let contrastPrimary = Color("contrastPrimary") | |
let themePrimary = Color("themePrimary") | |
/// staic color sets (not updating along with color mode) | |
let darkPrimary = Color("darkPrimary") | |
let lightPrimary = Color("lightPrimary") | |
} | |
struct TokenColor { | |
let baseColor = BaseColor() | |
let textDefault: Color! | |
let textTheme: Color! | |
let textLight: Color! | |
let buttonTheme: Color! | |
let buttonContrast: Color! | |
let backgroundDefault: Color! | |
let backgroundTheme: Color! | |
init() { | |
/// themePrimary | |
self.textTheme = baseColor.themePrimary | |
self.buttonTheme = baseColor.themePrimary | |
self.backgroundTheme = baseColor.themePrimary | |
/// contrastPrimary | |
self.buttonContrast = baseColor.contrastPrimary | |
self.textDefault = baseColor.contrastPrimary | |
self.backgroundDefault = baseColor.contrastPrimary | |
/// lightPrimary | |
self.textLight = baseColor.lightPrimary | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment