Last active
May 2, 2020 04:10
-
-
Save mukyasa/77d2c1d67259821d97d5bf710d716cf1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@propertyWrapper | |
struct Theme { | |
let light: UIColor | |
let dark: UIColor | |
var wrappedValue: UIColor { | |
if #available(iOS 13, *) { | |
return UIColor { (traitCollection: UITraitCollection) -> UIColor in | |
if traitCollection.userInterfaceStyle == .dark { | |
return self.dark | |
} else { | |
return self.light | |
} | |
} | |
} else { | |
return ThemeManager.isDarkModeEnabled ? self.dark : self.light | |
} | |
} | |
} | |
enum ThemeManager { | |
static var isDarkModeEnabled = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment