1 /// Here we implement the components exclusive for view managers.
2 
3 // MARK: View factory
4 
5 /**
6  Defines the factory creating a native view when the module is used as a view.
7  */
8 public func View<ViewType: UIView>(_ closure: @escaping () -> ViewType) -> ViewManagerDefinitionComponent {
9   return ViewFactory(closure)
10 }
11 
12 // MARK: Props
13 
14 /**
15  Creates a view prop that defines its name and setter.
16  */
17 public func Prop<ViewType: UIView, PropType: AnyArgument>(
18   _ name: String,
19   @_implicitSelfCapture _ setter: @escaping (ViewType, PropType) -> Void
20 ) -> ConcreteViewProp<ViewType, PropType> {
21   return ConcreteViewProp(
22     name: name,
23     propType: ~PropType.self,
24     setter: setter
25   )
26 }
27 
28 // MARK: - View lifecycle
29 
30 /**
31  Defines the view lifecycle method that is called when the view finished updating all props.
32  */
33 public func OnViewDidUpdateProps<ViewType: UIView>(
34   @_implicitSelfCapture _ closure: @escaping (_ view: ViewType) -> Void
35 ) -> ViewLifecycleMethod<ViewType> {
36   return ViewLifecycleMethod(type: .didUpdateProps, closure: closure)
37 }
38