Skip to content

Instantly share code, notes, and snippets.

@elefantel
Last active September 22, 2021 22:06
Show Gist options
  • Save elefantel/d57498f8eb98ab5b1606f70cf9ec1f21 to your computer and use it in GitHub Desktop.
Save elefantel/d57498f8eb98ab5b1606f70cf9ec1f21 to your computer and use it in GitHub Desktop.
A theming protocol for abstracting Luno fonts and colour themes
protocol Theme {
static var isLunoV3Enabled: Bool { get }
}
/**
Theme type dynamically determined based on the `isLunoV3Enabled` flag
*/
extension Theme {
static var color: ThemeColor.Type {
isLunoV3Enabled ? LunoThemeColor.self : LegacyThemeColor.self
}
static var font: ThemeFont.Type {
isLunoV3Enabled ? LunoThemeFont.self : LegacyThemeFont.self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment