|
@@ -1,26 +1,9 @@
|
1
|
1
|
package com.reactnativenavigation.bridge;
|
2
|
2
|
|
3
|
|
-import android.app.Activity;
|
4
|
|
-import android.content.Intent;
|
5
|
|
-import android.os.Bundle;
|
6
|
|
-
|
7
|
3
|
import com.facebook.react.bridge.ReactApplicationContext;
|
8
|
4
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
9
|
5
|
import com.facebook.react.bridge.ReactMethod;
|
10
|
|
-import com.facebook.react.bridge.ReadableArray;
|
11
|
6
|
import com.facebook.react.bridge.ReadableMap;
|
12
|
|
-import com.facebook.react.bridge.ReadableNativeMap;
|
13
|
|
-import com.reactnativenavigation.activities.BaseReactActivity;
|
14
|
|
-import com.reactnativenavigation.activities.BottomTabActivity;
|
15
|
|
-import com.reactnativenavigation.activities.RootActivity;
|
16
|
|
-import com.reactnativenavigation.activities.SingleScreenActivity;
|
17
|
|
-import com.reactnativenavigation.controllers.ModalController;
|
18
|
|
-import com.reactnativenavigation.core.objects.Drawer;
|
19
|
|
-import com.reactnativenavigation.core.objects.Screen;
|
20
|
|
-import com.reactnativenavigation.utils.BridgeUtils;
|
21
|
|
-import com.reactnativenavigation.utils.ContextProvider;
|
22
|
|
-
|
23
|
|
-import java.util.ArrayList;
|
24
|
7
|
|
25
|
8
|
/**
|
26
|
9
|
* The basic abstract components we will expose:
|
|
@@ -45,63 +28,7 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
|
45
|
28
|
}
|
46
|
29
|
|
47
|
30
|
@ReactMethod
|
48
|
|
- public void startTabBasedApp(ReadableArray screens, ReadableMap style, ReadableMap drawerParams) {
|
49
|
|
- Activity context = ContextProvider.getActivityContext();
|
50
|
|
- if (context != null && !context.isFinishing()) {
|
51
|
|
- Intent intent = new Intent(context, BottomTabActivity.class);
|
52
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
53
|
|
-
|
54
|
|
- Bundle extras = new Bundle();
|
55
|
|
- extras.putSerializable(BottomTabActivity.EXTRA_SCREENS, createScreens(screens));
|
56
|
|
- if (drawerParams != null) {
|
57
|
|
- extras.putSerializable(BottomTabActivity.DRAWER_PARAMS, new Drawer(drawerParams));
|
58
|
|
- }
|
59
|
|
- if (style != null) {
|
60
|
|
- BridgeUtils.addMapToBundle(((ReadableNativeMap) style).toHashMap(), extras);
|
61
|
|
- }
|
62
|
|
- intent.putExtras(extras);
|
63
|
|
-
|
64
|
|
- context.startActivity(intent);
|
65
|
|
- //TODO add abstract isRoot() instead of instanceof?
|
66
|
|
- if (ContextProvider.getActivityContext() instanceof RootActivity) {
|
67
|
|
- context.overridePendingTransition(0, 0);
|
68
|
|
- }
|
69
|
|
-
|
70
|
|
- // Dismiss modals associated with previous activity
|
71
|
|
- ModalController.getInstance().dismissAllModals();
|
72
|
|
- }
|
73
|
|
- }
|
74
|
|
-
|
75
|
|
- private ArrayList<Screen> createScreens(ReadableArray screens) {
|
76
|
|
- ArrayList<Screen> ret = new ArrayList<>();
|
77
|
|
- for (int i = 0; i < screens.size(); i++) {
|
78
|
|
- ret.add(new Screen(screens.getMap(i)));
|
79
|
|
- }
|
80
|
|
- return ret;
|
81
|
|
- }
|
82
|
|
-
|
83
|
|
- @ReactMethod
|
84
|
|
- public void startSingleScreenApp(ReadableMap screen, ReadableMap drawerParams) {
|
85
|
|
- BaseReactActivity context = ContextProvider.getActivityContext();
|
86
|
|
- if (context != null && !context.isFinishing()) {
|
87
|
|
- Intent intent = new Intent(context, SingleScreenActivity.class);
|
88
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
89
|
|
-
|
90
|
|
- Bundle extras = new Bundle();
|
91
|
|
- extras.putSerializable(SingleScreenActivity.EXTRA_SCREEN, new Screen(screen));
|
92
|
|
- if (drawerParams != null) {
|
93
|
|
- extras.putSerializable(SingleScreenActivity.DRAWER_PARAMS, new Drawer(drawerParams));
|
94
|
|
- }
|
95
|
|
- intent.putExtras(extras);
|
96
|
|
-
|
97
|
|
- context.startActivity(intent);
|
98
|
|
- if (ContextProvider.getActivityContext() instanceof RootActivity) {
|
99
|
|
- context.overridePendingTransition(0, 0);
|
100
|
|
- }
|
101
|
|
-
|
102
|
|
- // Dismiss modals associated with previous activity
|
103
|
|
- ModalController.getInstance().dismissAllModals();
|
104
|
|
- }
|
|
31
|
+ public void startApp(final ReadableMap params) {
|
105
|
32
|
}
|
106
|
33
|
|
107
|
34
|
@ReactMethod
|