|
@@ -13,6 +13,7 @@ import com.reactnativenavigation.NavigationApplication;
|
13
|
13
|
import com.reactnativenavigation.parse.LayoutFactory;
|
14
|
14
|
import com.reactnativenavigation.parse.LayoutNode;
|
15
|
15
|
import com.reactnativenavigation.parse.Options;
|
|
16
|
+import com.reactnativenavigation.parse.parsers.JSONParser;
|
16
|
17
|
import com.reactnativenavigation.parse.parsers.LayoutNodeParser;
|
17
|
18
|
import com.reactnativenavigation.utils.NativeCommandListener;
|
18
|
19
|
import com.reactnativenavigation.utils.Now;
|
|
@@ -23,8 +24,6 @@ import com.reactnativenavigation.viewcontrollers.Navigator;
|
23
|
24
|
import com.reactnativenavigation.viewcontrollers.ViewController;
|
24
|
25
|
import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
|
25
|
26
|
|
26
|
|
-import org.json.JSONObject;
|
27
|
|
-
|
28
|
27
|
import java.util.HashMap;
|
29
|
28
|
import java.util.Map;
|
30
|
29
|
|
|
@@ -57,7 +56,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
57
|
56
|
|
58
|
57
|
@ReactMethod
|
59
|
58
|
public void setRoot(String commandId, ReadableMap rawLayoutTree, Promise promise) {
|
60
|
|
- final LayoutNode layoutTree = LayoutNodeParser.parse(new JSONObject(rawLayoutTree.getMap("root").toHashMap()));
|
|
59
|
+ final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree).optJSONObject("root"));
|
61
|
60
|
handle(() -> {
|
62
|
61
|
final ViewController viewController = newLayoutFactory().create(layoutTree);
|
63
|
62
|
navigator().setRoot(viewController, new NativeCommandListener(commandId, promise, eventEmitter, now));
|
|
@@ -66,19 +65,19 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
66
|
65
|
|
67
|
66
|
@ReactMethod
|
68
|
67
|
public void setDefaultOptions(ReadableMap options) {
|
69
|
|
- final Options defaultOptions = Options.parse(new TypefaceLoader(activity()), new JSONObject(options.toHashMap()));
|
|
68
|
+ final Options defaultOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
|
70
|
69
|
handle(() -> navigator().setDefaultOptions(defaultOptions));
|
71
|
70
|
}
|
72
|
71
|
|
73
|
72
|
@ReactMethod
|
74
|
73
|
public void mergeOptions(String onComponentId, ReadableMap options) {
|
75
|
|
- final Options navOptions = Options.parse(new TypefaceLoader(activity()), new JSONObject(options.toHashMap()));
|
|
74
|
+ final Options navOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
|
76
|
75
|
handle(() -> navigator().mergeOptions(onComponentId, navOptions));
|
77
|
76
|
}
|
78
|
77
|
|
79
|
78
|
@ReactMethod
|
80
|
79
|
public void push(String commandId, String onComponentId, ReadableMap rawLayoutTree, Promise promise) {
|
81
|
|
- final LayoutNode layoutTree = LayoutNodeParser.parse(new JSONObject(rawLayoutTree.toHashMap()));
|
|
80
|
+ final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
82
|
81
|
handle(() -> {
|
83
|
82
|
final ViewController viewController = newLayoutFactory().create(layoutTree);
|
84
|
83
|
navigator().push(onComponentId, viewController, new NativeCommandListener(commandId, promise, eventEmitter, now));
|
|
@@ -87,7 +86,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
87
|
86
|
|
88
|
87
|
@ReactMethod
|
89
|
88
|
public void setStackRoot(String commandId, String onComponentId, ReadableMap rawLayoutTree, Promise promise) {
|
90
|
|
- final LayoutNode layoutTree = LayoutNodeParser.parse(new JSONObject(rawLayoutTree.toHashMap()));
|
|
89
|
+ final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
91
|
90
|
handle(() -> {
|
92
|
91
|
final ViewController viewController = newLayoutFactory().create(layoutTree);
|
93
|
92
|
navigator().setStackRoot(onComponentId, viewController, new NativeCommandListener(commandId, promise, eventEmitter, now));
|
|
@@ -111,7 +110,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
111
|
110
|
|
112
|
111
|
@ReactMethod
|
113
|
112
|
public void showModal(String commandId, ReadableMap rawLayoutTree, Promise promise) {
|
114
|
|
- final LayoutNode layoutTree = LayoutNodeParser.parse(new JSONObject(rawLayoutTree.toHashMap()));
|
|
113
|
+ final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
115
|
114
|
handle(() -> {
|
116
|
115
|
final ViewController viewController = newLayoutFactory().create(layoutTree);
|
117
|
116
|
navigator().showModal(viewController, new NativeCommandListener(commandId, promise, eventEmitter, now));
|
|
@@ -130,7 +129,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
130
|
129
|
|
131
|
130
|
@ReactMethod
|
132
|
131
|
public void showOverlay(String commandId, ReadableMap rawLayoutTree, Promise promise) {
|
133
|
|
- final LayoutNode layoutTree = LayoutNodeParser.parse(new JSONObject(rawLayoutTree.toHashMap()));
|
|
132
|
+ final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
134
|
133
|
handle(() -> {
|
135
|
134
|
final ViewController viewController = newLayoutFactory().create(layoutTree);
|
136
|
135
|
navigator().showOverlay(viewController, new NativeCommandListener(commandId, promise, eventEmitter, now));
|