|
@@ -1,20 +1,26 @@
|
1
|
1
|
package com.reactnativenavigation.react;
|
2
|
2
|
|
|
3
|
+import android.view.View;
|
|
4
|
+
|
|
5
|
+import com.facebook.react.ReactInstanceManager;
|
3
|
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
4
|
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
5
|
8
|
import com.facebook.react.bridge.ReactMethod;
|
6
|
9
|
import com.facebook.react.bridge.ReadableMap;
|
7
|
10
|
import com.reactnativenavigation.NavigationActivity;
|
8
|
|
-import com.reactnativenavigation.controllers.CommandsHandler;
|
|
11
|
+import com.reactnativenavigation.layout.LayoutFactory;
|
|
12
|
+import com.reactnativenavigation.layout.LayoutNode;
|
|
13
|
+import com.reactnativenavigation.layout.StackLayout;
|
|
14
|
+import com.reactnativenavigation.layout.containers.Container;
|
9
|
15
|
import com.reactnativenavigation.utils.UiThread;
|
10
|
16
|
|
11
|
17
|
public class NavigationModule extends ReactContextBaseJavaModule {
|
12
|
18
|
private static final String NAME = "RNNBridgeModule";
|
13
|
|
- private CommandsHandler commandsHandler;
|
|
19
|
+ private ReactInstanceManager reactInstanceManager;
|
14
|
20
|
|
15
|
|
- public NavigationModule(final ReactApplicationContext reactContext, CommandsHandler commandsHandler) {
|
|
21
|
+ public NavigationModule(final ReactApplicationContext reactContext, final ReactInstanceManager reactInstanceManager) {
|
16
|
22
|
super(reactContext);
|
17
|
|
- this.commandsHandler = commandsHandler;
|
|
23
|
+ this.reactInstanceManager = reactInstanceManager;
|
18
|
24
|
}
|
19
|
25
|
|
20
|
26
|
@Override
|
|
@@ -27,7 +33,10 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
27
|
33
|
handle(new Runnable() {
|
28
|
34
|
@Override
|
29
|
35
|
public void run() {
|
30
|
|
- commandsHandler.setRoot(activity(), ArgsParser.parse(layoutTree));
|
|
36
|
+ final LayoutNode layoutTreeRoot = LayoutNode.parse(ArgsParser.parse(layoutTree));
|
|
37
|
+ LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager);
|
|
38
|
+ final View rootView = factory.create(layoutTreeRoot);
|
|
39
|
+ activity().setContentView(rootView);
|
31
|
40
|
}
|
32
|
41
|
});
|
33
|
42
|
}
|
|
@@ -37,7 +46,10 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
37
|
46
|
handle(new Runnable() {
|
38
|
47
|
@Override
|
39
|
48
|
public void run() {
|
40
|
|
- commandsHandler.push(activity(), onContainerId, ArgsParser.parse(layoutTree));
|
|
49
|
+ final LayoutNode layoutNode = LayoutNode.parse(ArgsParser.parse(layoutTree));
|
|
50
|
+ LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager);
|
|
51
|
+ final View rootView = factory.create(layoutNode);
|
|
52
|
+ ((StackLayout) activity().getContentView()).push((Container) rootView);
|
41
|
53
|
}
|
42
|
54
|
});
|
43
|
55
|
}
|
|
@@ -47,7 +59,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
47
|
59
|
handle(new Runnable() {
|
48
|
60
|
@Override
|
49
|
61
|
public void run() {
|
50
|
|
- commandsHandler.pop(activity(), onContainerId);
|
|
62
|
+ ((StackLayout) activity().getContentView()).pop();
|
51
|
63
|
}
|
52
|
64
|
});
|
53
|
65
|
}
|