173a652feSTomasz Sapeta /// Here we implement the components exclusive for view managers. 273a652feSTomasz Sapeta 373a652feSTomasz Sapeta // MARK: View factory 473a652feSTomasz Sapeta 573a652feSTomasz Sapeta /** 673a652feSTomasz Sapeta Defines the factory creating a native view when the module is used as a view. 773a652feSTomasz Sapeta */ 897075668STomasz Sapeta public func View<ViewType: UIView>(_ closure: @escaping () -> ViewType) -> ViewManagerDefinitionComponent { 9edc6188cSTomasz Sapeta return ViewFactory(closure) 10edc6188cSTomasz Sapeta } 11edc6188cSTomasz Sapeta 1273a652feSTomasz Sapeta // MARK: Props 1373a652feSTomasz Sapeta 1473a652feSTomasz Sapeta /** 1573a652feSTomasz Sapeta Creates a view prop that defines its name and setter. 1673a652feSTomasz Sapeta */ 17edc6188cSTomasz Sapeta public func Prop<ViewType: UIView, PropType: AnyArgument>( 18edc6188cSTomasz Sapeta _ name: String, 19ce28e27fSTomasz Sapeta @_implicitSelfCapture _ setter: @escaping (ViewType, PropType) -> Void 20e5ee837aSTomasz Sapeta ) -> ConcreteViewProp<ViewType, PropType> { 21edc6188cSTomasz Sapeta return ConcreteViewProp( 22edc6188cSTomasz Sapeta name: name, 234cafe471STomasz Sapeta propType: ~PropType.self, 24edc6188cSTomasz Sapeta setter: setter 25edc6188cSTomasz Sapeta ) 26edc6188cSTomasz Sapeta } 27*acc1a190STomasz Sapeta 28*acc1a190STomasz Sapeta // MARK: - View lifecycle 29*acc1a190STomasz Sapeta 30*acc1a190STomasz Sapeta /** 31*acc1a190STomasz Sapeta Defines the view lifecycle method that is called when the view finished updating all props. 32*acc1a190STomasz Sapeta */ 33*acc1a190STomasz Sapeta public func OnViewDidUpdateProps<ViewType: UIView>( 34*acc1a190STomasz Sapeta @_implicitSelfCapture _ closure: @escaping (_ view: ViewType) -> Void 35*acc1a190STomasz Sapeta ) -> ViewLifecycleMethod<ViewType> { 36*acc1a190STomasz Sapeta return ViewLifecycleMethod(type: .didUpdateProps, closure: closure) 37*acc1a190STomasz Sapeta } 38