Daniel Zlotin 8 years ago
parent
commit
5cf4aca522

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java View File

@@ -76,6 +76,7 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
76 76
 
77 77
     @ReactMethod
78 78
     public void pop(final ReadableMap params) {
79
+        NavigationCommandsHandler.pop(BundleConverter.toBundle(params));
79 80
     }
80 81
 
81 82
     @ReactMethod

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

@@ -109,4 +109,8 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
109 109
     void push(ScreenParams params) {
110 110
         layout.push(params);
111 111
     }
112
+
113
+    void pop(ScreenParams params) {
114
+        layout.pop(params);
115
+    }
112 116
 }

+ 15
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

@@ -43,4 +43,19 @@ public class NavigationCommandsHandler {
43 43
     static ActivityParams getActivityParams(Intent intent) {
44 44
         return ActivityParamsParser.parse(intent.getBundleExtra(NavigationCommandsHandler.ACTIVITY_PARAMS_BUNDLE));
45 45
     }
46
+
47
+    public static void pop(Bundle screenParams) {
48
+        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
49
+        if (currentActivity == null) {
50
+            return;
51
+        }
52
+
53
+        final ScreenParams params = ScreenParamsParser.parse(screenParams);
54
+        NavigationApplication.instance.runOnMainThread(new Runnable() {
55
+            @Override
56
+            public void run() {
57
+                currentActivity.pop(params);
58
+            }
59
+        });
60
+    }
46 61
 }

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java View File

@@ -10,4 +10,6 @@ public interface Layout {
10 10
     void removeAllReactViews();
11 11
 
12 12
     void push(ScreenParams params);
13
+
14
+    void pop(ScreenParams params);
13 15
 }

+ 3
- 1
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenStack.java View File

@@ -28,7 +28,9 @@ public class ScreenStack extends FrameLayout {
28 28
     }
29 29
 
30 30
     public Screen pop() {
31
-        return stack.pop();
31
+        Screen popped = stack.pop();
32
+        removeView((View) popped);
33
+        return popped;
32 34
     }
33 35
 
34 36
     public void popToRoot() {

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/SingleScreenLayout.java View File

@@ -50,4 +50,9 @@ public class SingleScreenLayout extends FrameLayout implements Layout {
50 50
     public void push(ScreenParams params) {
51 51
         stack.push(params);
52 52
     }
53
+
54
+    @Override
55
+    public void pop(ScreenParams params) {
56
+        stack.pop();
57
+    }
53 58
 }

+ 11
- 6
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -39,11 +39,21 @@ function navigatorPush(navigator, params) {
39 39
 
40 40
   params.screenId = params.screen;
41 41
   let adapted = adaptNavigationStyleToScreenStyle(params);
42
-  adapted = adaptNavigationParams(params);
42
+  adapted = adaptNavigationParams(adapted);
43 43
 
44 44
   newPlatformSpecific.push(adapted);
45 45
 }
46 46
 
47
+function navigatorPop(navigator, params) {
48
+  addNavigatorParams(params, navigator);
49
+
50
+  params.screenId = params.screen;
51
+  let adapted = adaptNavigationStyleToScreenStyle(params);
52
+  adapted = adaptNavigationParams(adapted);
53
+
54
+  newPlatformSpecific.pop(adapted);
55
+}
56
+
47 57
 function adaptNavigationStyleToScreenStyle(screen) {
48 58
   const navigatorStyle = screen.navigatorStyle;
49 59
   if (!navigatorStyle) {
@@ -118,11 +128,6 @@ function navigatorSetButtons(navigator, navigatorEventID, params) {
118 128
   //RctActivity.setNavigatorButtons(params);
119 129
 }
120 130
 
121
-function navigatorPop(navigator, params) {
122
-  //addNavigatorParams(params, navigator);
123
-  //RctActivity.navigatorPop(params);
124
-}
125
-
126 131
 function navigatorPopToRoot(navigator, params) {
127 132
   //RctActivity.navigatorPopToRoot({
128 133
   //  navigatorID: navigator.navigatorID,

+ 6
- 1
src/platformSpecific.android.js View File

@@ -20,7 +20,12 @@ function push(screenParams) {
20 20
   NativeModules.NavigationReactModule.push(screenParams);
21 21
 }
22 22
 
23
+function pop(screenParams) {
24
+  NativeModules.NavigationReactModule.pop(screenParams);
25
+}
26
+
23 27
 module.exports = {
24 28
   startApp,
25
-  push
29
+  push,
30
+  pop
26 31
 };