3
3
package com .facebook .react .fabric ;
4
4
5
5
import com .facebook .react .bridge .ReactApplicationContext ;
6
- import com .facebook .react .bridge .ReactContextBaseJavaModule ;
7
- import com .facebook .react .bridge .ReactMethod ;
8
6
import com .facebook .react .bridge .ReadableMap ;
9
- import com .facebook .react .module .annotations .ReactModule ;
10
7
import com .facebook .react .uimanager .ReactShadowNode ;
8
+ import java .util .ArrayList ;
9
+ import java .util .List ;
10
+ import javax .annotation .Nullable ;
11
11
12
12
/**
13
- * <p>Native module to allow JS to create and update native Views using Fabric API.</p>
14
- *
13
+ * This class is responsible to create, clone and update {@link ReactShadowNode} using the
14
+ * Fabric API.
15
15
*/
16
- @ ReactModule (name = FabricUIManagerModule .NAME )
17
- public class FabricUIManagerModule extends ReactContextBaseJavaModule {
16
+ public class FabricUIManagerModule {
18
17
19
- static final String NAME = "FabricUIManager" ;
18
+ private final ReactApplicationContext mReactApplicationContext ;
20
19
21
20
public FabricUIManagerModule (ReactApplicationContext reactContext ) {
22
- super ( reactContext ) ;
21
+ mReactApplicationContext = reactContext ;
23
22
}
24
23
25
24
/**
26
25
* Creates a new {@link ReactShadowNode}
27
26
*/
28
- @ ReactMethod ( isBlockingSynchronousMethod = true )
29
- public int createNode (int reactTag ,
27
+ @ Nullable
28
+ public ReactShadowNode createNode (int reactTag ,
30
29
String viewName ,
31
30
int rootTag ,
32
31
ReadableMap props ,
33
32
int instanceHandle ) {
34
33
//TODO T25560658
35
- return - 1 ;
34
+ return null ;
36
35
}
37
36
38
37
/**
39
38
* @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
40
39
* ReactShadowNode will contain a copy of all the internal data of the original node, including
41
40
* its children set (note that the children nodes will not be cloned).
42
41
*/
43
- @ ReactMethod ( isBlockingSynchronousMethod = true )
44
- public int cloneNode (int node ) {
42
+ @ Nullable
43
+ public ReactShadowNode cloneNode (ReactShadowNode node ) {
45
44
//TODO T25560658
46
- return - 1 ;
45
+ return null ;
47
46
}
48
47
49
48
/**
50
49
* @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
51
50
* ReactShadowNode will contain a copy of all the internal data of the original node, but
52
51
* its children set will be empty.
53
52
*/
54
- @ ReactMethod ( isBlockingSynchronousMethod = true )
55
- public int cloneNodeWithNewChildren (int node ) {
53
+ @ Nullable
54
+ public ReactShadowNode cloneNodeWithNewChildren (ReactShadowNode node ) {
56
55
//TODO T25560658
57
- return - 1 ;
56
+ return null ;
58
57
}
59
58
60
59
/**
61
60
* @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
62
61
* ReactShadowNode will contain a copy of all the internal data of the original node, but its
63
62
* props will be overridden with the {@link ReadableMap} received by parameter.
64
63
*/
65
- @ ReactMethod ( isBlockingSynchronousMethod = true )
66
- public int cloneNodeWithNewProps (int node , ReadableMap newProps ) {
64
+ @ Nullable
65
+ public ReactShadowNode cloneNodeWithNewProps (ReactShadowNode node , ReadableMap newProps ) {
67
66
//TODO T25560658
68
- return - 1 ;
67
+ return null ;
69
68
}
70
69
71
70
/**
@@ -74,41 +73,40 @@ public int cloneNodeWithNewProps(int node, ReadableMap newProps) {
74
73
* props will be overridden with the {@link ReadableMap} received by parameter and its children
75
74
* set will be empty.
76
75
*/
77
- @ ReactMethod ( isBlockingSynchronousMethod = true )
78
- public int cloneNodeWithNewChildrenAndProps (
79
- int node ,
76
+ @ Nullable
77
+ public ReactShadowNode cloneNodeWithNewChildrenAndProps (
78
+ ReactShadowNode node ,
80
79
ReadableMap newProps ) {
81
80
//TODO T25560658
82
- return - 1 ;
81
+ return null ;
83
82
}
84
83
85
84
/**
86
85
* Appends the child {@link ReactShadowNode} to the children set of the parent
87
86
* {@link ReactShadowNode}.
88
87
*/
89
- @ ReactMethod
90
- public void appendChild (int parent , int child ) {
88
+ @ Nullable
89
+ public void appendChild (ReactShadowNode parent , ReactShadowNode child ) {
91
90
//TODO T25560658
92
91
}
93
92
94
- @ ReactMethod (isBlockingSynchronousMethod = true )
95
- public int createChildSet () {
96
- //TODO T25560658
97
- return -1 ;
93
+ /**
94
+ * @return an empty {@link List<ReactShadowNode>} that will be used to append the
95
+ * {@link ReactShadowNode} elements of the root. Typically this List will contain one element.
96
+ */
97
+ public List <ReactShadowNode > createChildSet () {
98
+ return new ArrayList <>(1 );
98
99
}
99
100
100
- @ ReactMethod
101
- public void appendChildToSet (int childSet , int child ) {
102
- //TODO T25560658
101
+ /**
102
+ * Adds the {@link ReactShadowNode} to the {@link List<ReactShadowNode>} received by parameter.
103
+ */
104
+ public void appendChildToSet (List <ReactShadowNode > childList , ReactShadowNode child ) {
105
+ childList .add (child );
103
106
}
104
107
105
- @ ReactMethod
106
- public void completeRoot (int rootTag , int childSet ) {
108
+ public void completeRoot (int rootTag , List <ReactShadowNode > childList ) {
107
109
//TODO T25560658
108
110
}
109
111
110
- @ Override
111
- public String getName () {
112
- return NAME ;
113
- }
114
112
}
0 commit comments