Last active
December 11, 2018 09:54
-
-
Save Oni-zerone/11360c57df2d33dbc89f932b88c278d7 to your computer and use it in GitHub Desktop.
ItemViewModel BuilderContainer extension
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 ColorItemViewModel: ItemViewModel { | |
var reuseIdentifier: String | |
var color: UIColor | |
} | |
extension ColorItemViewModel: BuilderContainer { | |
func getBuilder<Context>(_ contextType: Context.Type) -> Builder<Context>? { | |
return ColorBuilder(color: self.color) as? Builder<contextType> | |
} | |
} | |
class ColorBuilder<ApplicationContext>: Builder<Context> { | |
var color: UIColor | |
open override func build(_ context: ApplicationContext) -> UIViewController? { | |
let controller = UIViewController() | |
controller.view.backgroundColor = self.color | |
return controller | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment