Last active
September 27, 2018 19:10
-
-
Save tadija/25bad580b3228e5255b0e67c440e3d3b to your computer and use it in GitHub Desktop.
AEStyle
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
/** | |
* https://gist.github.com/tadija/25bad580b3228e5255b0e67c440e3d3b | |
* Copyright (c) Marko Tadić 2018 | |
* Licensed under the MIT license. See LICENSE file. | |
*/ | |
import UIKit | |
protocol AEStyle { | |
associatedtype FontKey: Hashable | |
associatedtype ColorKey: Hashable | |
var fonts: [FontKey: UIFont] { get } | |
var colors: [ColorKey: UIColor] { get } | |
var bar: UIBarStyle { get } | |
var statusBar: UIStatusBarStyle { get } | |
var blurEffect: UIBlurEffect.Style { get } | |
} | |
extension AEStyle { | |
func font(_ key: FontKey) -> UIFont? { | |
return fonts[key] | |
} | |
func color(_ key: ColorKey) -> UIColor? { | |
return colors[key] | |
} | |
} | |
protocol AEStylable { | |
associatedtype Style: AEStyle | |
func updateStyle(_ style: Style) | |
} | |
class BasicStyle<FontKey: Hashable, ColorKey: Hashable>: AEStyle { | |
let fonts: [FontKey: UIFont] | |
let colors: [ColorKey: UIColor] | |
var bar: UIBarStyle { | |
return .default | |
} | |
var statusBar: UIStatusBarStyle { | |
return .default | |
} | |
var blurEffect: UIBlurEffect.Style { | |
return .regular | |
} | |
init(fonts: [FontKey: UIFont], colors: [ColorKey: UIColor]) { | |
self.fonts = fonts | |
self.colors = colors | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment