Created
May 4, 2017 14:03
-
-
Save RadianSmile/063c24ddd1401d844ad641a98ab1268a 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
import Foundation | |
import CoreData | |
import RxSwift | |
import RxCocoa | |
// ------------------------------ | |
class Widget<View: UIView>: UIView { | |
var widgetFrame: CGRect { | |
return CGRect(x: 0, y: 0, width: 100, height: 100) | |
} | |
func createView() -> View { | |
return View(frame: self.widgetFrame) | |
} | |
func create() { | |
let view = self.createView() | |
view.backgroundColor = UIColor.red | |
} | |
} | |
class ButtonWidget: Widget<UIButton> { | |
override func createView() -> UIButton { | |
return UIButton(type: .system) | |
} | |
} | |
class LabelWidget: Widget<UILabel> { | |
} | |
// ------------------------------ | |
enum RenderMode { | |
case loFi | |
case hiFi | |
} | |
protocol Widget { | |
func render(in mode: RenderMode) | |
} | |
extension Widget { | |
func render(in mode: RenderMode) { | |
print("render") | |
} | |
} | |
extension UIButton: Widget { | |
func render(in mode: RenderMode) { | |
print("render !!") | |
} | |
} | |
extension UILabel: Widget { | |
} | |
extension CGPath: Widget { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment