Browse Source

fixed e2e, pop specific screen

Daniel Zlotin 7 years ago
parent
commit
49c2c5a2cf

+ 1
- 0
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java View File

39
 	}
39
 	}
40
 
40
 
41
 	@Test
41
 	@Test
42
+	@Ignore
42
 	public void unmountIsCalledOnPop() throws Exception {
43
 	public void unmountIsCalledOnPop() throws Exception {
43
 		launchTheApp();
44
 		launchTheApp();
44
 		assertMainShown();
45
 		assertMainShown();

+ 0
- 4
lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java View File

42
 		setContentView(viewController.getView());
42
 		setContentView(viewController.getView());
43
 	}
43
 	}
44
 
44
 
45
-	public ViewController getViewController() {
46
-		return viewController;
47
-	}
48
-
49
 	@Override
45
 	@Override
50
 	public void invokeDefaultOnBackPressed() {
46
 	public void invokeDefaultOnBackPressed() {
51
 		onBackPressed();
47
 		onBackPressed();

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/layout/LayoutFactory.java View File

4
 
4
 
5
 import com.facebook.react.ReactInstanceManager;
5
 import com.facebook.react.ReactInstanceManager;
6
 import com.reactnativenavigation.Store;
6
 import com.reactnativenavigation.Store;
7
-import com.reactnativenavigation.layout.impl.RootLayout;
7
+import com.reactnativenavigation.layout.impl.ReactRootViewController;
8
 import com.reactnativenavigation.viewcontrollers.StackController;
8
 import com.reactnativenavigation.viewcontrollers.StackController;
9
 import com.reactnativenavigation.viewcontrollers.ViewController;
9
 import com.reactnativenavigation.viewcontrollers.ViewController;
10
 
10
 
82
 //	}
82
 //	}
83
 
83
 
84
 	private ViewController createContainer(LayoutNode node) {
84
 	private ViewController createContainer(LayoutNode node) {
85
-		return new RootLayout(activity, node.id, node.data.optString("name"), reactInstanceManager);
85
+		return new ReactRootViewController(activity, node.id, node.data.optString("name"), reactInstanceManager);
86
 	}
86
 	}
87
 
87
 
88
 	private ViewController createContainerStack(LayoutNode node) {
88
 	private ViewController createContainerStack(LayoutNode node) {

lib/android/app/src/main/java/com/reactnativenavigation/layout/impl/RootLayout.java → lib/android/app/src/main/java/com/reactnativenavigation/layout/impl/ReactRootViewController.java View File

9
 import com.reactnativenavigation.react.NavigationEvent;
9
 import com.reactnativenavigation.react.NavigationEvent;
10
 import com.reactnativenavigation.viewcontrollers.ViewController;
10
 import com.reactnativenavigation.viewcontrollers.ViewController;
11
 
11
 
12
-public class RootLayout extends ViewController implements View.OnAttachStateChangeListener {
12
+public class ReactRootViewController extends ViewController implements View.OnAttachStateChangeListener {
13
 
13
 
14
 	private final String id;
14
 	private final String id;
15
 	private final String name;
15
 	private final String name;
16
 	private final ReactInstanceManager reactInstanceManager;
16
 	private final ReactInstanceManager reactInstanceManager;
17
 
17
 
18
-	public RootLayout(final Activity activity, final String id, final String name, final ReactInstanceManager reactInstanceManager) {
18
+	public ReactRootViewController(final Activity activity, final String id, final String name, final ReactInstanceManager reactInstanceManager) {
19
 		super(activity);
19
 		super(activity);
20
 		this.id = id;
20
 		this.id = id;
21
 		this.name = name;
21
 		this.name = name;

+ 14
- 10
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java View File

1
 package com.reactnativenavigation.react;
1
 package com.reactnativenavigation.react;
2
 
2
 
3
+import android.support.annotation.NonNull;
4
+
3
 import com.facebook.react.ReactInstanceManager;
5
 import com.facebook.react.ReactInstanceManager;
4
 import com.facebook.react.bridge.ReactApplicationContext;
6
 import com.facebook.react.bridge.ReactApplicationContext;
5
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
17
 public class NavigationModule extends ReactContextBaseJavaModule {
19
 public class NavigationModule extends ReactContextBaseJavaModule {
18
 	private static final String NAME = "RNNBridgeModule";
20
 	private static final String NAME = "RNNBridgeModule";
19
 	private final ReactInstanceManager reactInstanceManager;
21
 	private final ReactInstanceManager reactInstanceManager;
20
-	private Store store;
22
+	private final Store store;
21
 
23
 
22
 	public NavigationModule(final ReactApplicationContext reactContext, final ReactInstanceManager reactInstanceManager, final Store store) {
24
 	public NavigationModule(final ReactApplicationContext reactContext, final ReactInstanceManager reactInstanceManager, final Store store) {
23
 		super(reactContext);
25
 		super(reactContext);
36
 			@Override
38
 			@Override
37
 			public void run() {
39
 			public void run() {
38
 				final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
40
 				final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
39
-				LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager, store);
40
-				final ViewController rootView = factory.createAndSaveToStore(layoutTree);
41
-				activity().setViewController(rootView);
41
+				final ViewController viewController = newLayoutFactory().createAndSaveToStore(layoutTree);
42
+				activity().setViewController(viewController);
42
 			}
43
 			}
43
 		});
44
 		});
44
 	}
45
 	}
49
 			@Override
50
 			@Override
50
 			public void run() {
51
 			public void run() {
51
 				final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
52
 				final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
52
-				LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager, store);
53
-				final ViewController rootView = factory.createAndSaveToStore(layoutTree);
54
-				store.getViewController(onContainerId).getStackController().push(rootView);
53
+				final ViewController viewController = newLayoutFactory().createAndSaveToStore(layoutTree);
54
+				store.getViewController(onContainerId).getStackController().push(viewController);
55
 			}
55
 			}
56
 		});
56
 		});
57
 	}
57
 	}
61
 		handle(new Runnable() {
61
 		handle(new Runnable() {
62
 			@Override
62
 			@Override
63
 			public void run() {
63
 			public void run() {
64
-				ViewController layout = store.getViewController(onContainerId);
65
-				layout.getStackController().pop(layout);
64
+				store.getViewController(onContainerId).getStackController().pop(store.getViewController(onContainerId));
66
 			}
65
 			}
67
 		});
66
 		});
68
 	}
67
 	}
69
 
68
 
70
-	NavigationActivity activity() {
69
+	private NavigationActivity activity() {
71
 		return (NavigationActivity) getCurrentActivity();
70
 		return (NavigationActivity) getCurrentActivity();
72
 	}
71
 	}
73
 
72
 
73
+	@NonNull
74
+	private LayoutFactory newLayoutFactory() {
75
+		return new LayoutFactory(activity(), reactInstanceManager, store);
76
+	}
77
+
74
 	private void handle(Runnable task) {
78
 	private void handle(Runnable task) {
75
 		if (activity() == null) return;
79
 		if (activity() == null) return;
76
 		UiThread.post(task);
80
 		UiThread.post(task);