Skip to content

Instantly share code, notes, and snippets.

@Oni-zerone
Last active December 11, 2018 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oni-zerone/11360c57df2d33dbc89f932b88c278d7 to your computer and use it in GitHub Desktop.
Save Oni-zerone/11360c57df2d33dbc89f932b88c278d7 to your computer and use it in GitHub Desktop.
ItemViewModel BuilderContainer extension
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