Search in sources :

Example 1 with LayoutNode

use of com.reactnativenavigation.options.LayoutNode in project react-native-navigation by wix.

the class NavigationModule method setRoot.

@ReactMethod
public void setRoot(String commandId, ReadableMap rawLayoutTree, Promise promise) {
    final LayoutNode layoutTree = LayoutNodeParser.parse(Objects.requireNonNull(jsonParser.parse(rawLayoutTree).optJSONObject("root")));
    handle(() -> {
        final ViewController<?> viewController = layoutFactory.create(layoutTree);
        navigator().setRoot(viewController, new NativeCommandListener("setRoot", commandId, promise, eventEmitter, now), reactInstanceManager);
    });
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 2 with LayoutNode

use of com.reactnativenavigation.options.LayoutNode in project react-native-navigation by wix.

the class NavigationModule method showModal.

@ReactMethod
public void showModal(String commandId, ReadableMap rawLayoutTree, Promise promise) {
    final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(rawLayoutTree));
    handle(() -> {
        final ViewController<?> viewController = layoutFactory.create(layoutTree);
        navigator().showModal(viewController, new NativeCommandListener("showModal", commandId, promise, eventEmitter, now));
    });
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 3 with LayoutNode

use of com.reactnativenavigation.options.LayoutNode in project react-native-navigation by wix.

the class NavigationModule method setStackRoot.

@ReactMethod
public void setStackRoot(String commandId, String onComponentId, ReadableArray children, Promise promise) {
    handle(() -> {
        ArrayList<ViewController<?>> _children = new ArrayList<>();
        for (int i = 0; i < children.size(); i++) {
            final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(children.getMap(i)));
            _children.add(layoutFactory.create(layoutTree));
        }
        navigator().setStackRoot(onComponentId, _children, new NativeCommandListener("setStackRoot", commandId, promise, eventEmitter, now));
    });
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) ArrayList(java.util.ArrayList) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 4 with LayoutNode

use of com.reactnativenavigation.options.LayoutNode in project react-native-navigation by wix.

the class NavigationModule method push.

@ReactMethod
public void push(String commandId, String onComponentId, ReadableMap rawLayoutTree, Promise promise) {
    final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(rawLayoutTree));
    handle(() -> {
        final ViewController<?> viewController = layoutFactory.create(layoutTree);
        navigator().push(onComponentId, viewController, new NativeCommandListener("push", commandId, promise, eventEmitter, now));
    });
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 5 with LayoutNode

use of com.reactnativenavigation.options.LayoutNode in project react-native-navigation by wix.

the class LayoutNodeParser method parse.

@SuppressWarnings("unchecked")
public static LayoutNode parse(JSONObject layoutTree) {
    String id = layoutTree.optString("id");
    LayoutNode.Type type = LayoutNode.Type.valueOf(layoutTree.optString("type"));
    JSONObject data = parseData(layoutTree);
    List<LayoutNode> children = parseChildren(layoutTree);
    return new LayoutNode(id, type, data, children);
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) JSONObject(org.json.JSONObject)

Aggregations

LayoutNode (com.reactnativenavigation.options.LayoutNode)7 ReactMethod (com.facebook.react.bridge.ReactMethod)5 JSONObject (org.json.JSONObject)2 ViewController (com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController)1 ArrayList (java.util.ArrayList)1