19e287264STomasz Sapeta import UIKit
29e287264STomasz Sapeta 
3edc6188cSTomasz Sapeta // MARK: - Module name
4edc6188cSTomasz Sapeta 
5d4c4ca83STomasz Sapeta /**
6edc6188cSTomasz Sapeta  Sets the name of the module that is exported to the JavaScript world.
7d4c4ca83STomasz Sapeta  */
Namenull8edc6188cSTomasz Sapeta public func Name(_ name: String) -> AnyDefinition {
9edc6188cSTomasz Sapeta   return ModuleNameDefinition(name: name)
10edc6188cSTomasz Sapeta }
11edc6188cSTomasz Sapeta 
12edc6188cSTomasz Sapeta // MARK: - Module's lifecycle
13edc6188cSTomasz Sapeta 
14edc6188cSTomasz Sapeta /**
15edc6188cSTomasz Sapeta  Creates module's lifecycle listener that is called right after module initialization.
16edc6188cSTomasz Sapeta  */
17*ce28e27fSTomasz Sapeta public func OnCreate(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
18edc6188cSTomasz Sapeta   return EventListener(.moduleCreate, closure)
19d4c4ca83STomasz Sapeta }
20d4c4ca83STomasz Sapeta 
21d4c4ca83STomasz Sapeta /**
22edc6188cSTomasz Sapeta  Creates module's lifecycle listener that is called when the module is about to be deallocated.
23d4c4ca83STomasz Sapeta  */
24*ce28e27fSTomasz Sapeta public func OnDestroy(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
25edc6188cSTomasz Sapeta   return EventListener(.moduleDestroy, closure)
26d4c4ca83STomasz Sapeta }
27d4c4ca83STomasz Sapeta 
28d4c4ca83STomasz Sapeta /**
29edc6188cSTomasz Sapeta  Creates module's lifecycle listener that is called when the app context owning the module is about to be deallocated.
30d4c4ca83STomasz Sapeta  */
31*ce28e27fSTomasz Sapeta public func OnAppContextDestroys(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
32edc6188cSTomasz Sapeta   return EventListener(.appContextDestroys, closure)
33d4c4ca83STomasz Sapeta }
34edc6188cSTomasz Sapeta 
35edc6188cSTomasz Sapeta /**
36edc6188cSTomasz Sapeta  Creates a listener that is called when the app is about to enter the foreground mode.
37edc6188cSTomasz Sapeta  */
38*ce28e27fSTomasz Sapeta public func OnAppEntersForeground(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
39edc6188cSTomasz Sapeta   return EventListener(.appEntersForeground, closure)
40edc6188cSTomasz Sapeta }
41edc6188cSTomasz Sapeta 
42edc6188cSTomasz Sapeta /**
43edc6188cSTomasz Sapeta  Creates a listener that is called when the app becomes active again.
44edc6188cSTomasz Sapeta  */
45*ce28e27fSTomasz Sapeta public func OnAppBecomesActive(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
46edc6188cSTomasz Sapeta   return EventListener(.appBecomesActive, closure)
47edc6188cSTomasz Sapeta }
48edc6188cSTomasz Sapeta 
49edc6188cSTomasz Sapeta /**
50edc6188cSTomasz Sapeta  Creates a listener that is called when the app enters the background mode.
51edc6188cSTomasz Sapeta  */
52*ce28e27fSTomasz Sapeta public func OnAppEntersBackground(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
53edc6188cSTomasz Sapeta   return EventListener(.appEntersBackground, closure)
54edc6188cSTomasz Sapeta }
55edc6188cSTomasz Sapeta 
56edc6188cSTomasz Sapeta // MARK: - View Manager
57edc6188cSTomasz Sapeta 
58edc6188cSTomasz Sapeta /**
59edc6188cSTomasz Sapeta  Creates the view manager definition that scopes other view-related definitions.
60edc6188cSTomasz Sapeta  */
61edc6188cSTomasz Sapeta public func ViewManager(@ViewManagerDefinitionBuilder _ closure: @escaping () -> ViewManagerDefinition) -> AnyDefinition {
62edc6188cSTomasz Sapeta   return closure()
63d4c4ca83STomasz Sapeta }
64