浏览代码

Android modal life cycle screen events added, Fixes #1144 (#1200)

Omer Karakose 7 年前
父节点
当前提交
82b349889b
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10
    0
      android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java

+ 10
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java 查看文件

@@ -35,6 +35,7 @@ import com.reactnativenavigation.params.SnackbarParams;
35 35
 import com.reactnativenavigation.params.TitleBarButtonParams;
36 36
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
37 37
 import com.reactnativenavigation.react.ReactGateway;
38
+import com.reactnativenavigation.screens.Screen;
38 39
 import com.reactnativenavigation.utils.OrientationHelper;
39 40
 import com.reactnativenavigation.views.SideMenu.Side;
40 41
 
@@ -235,15 +236,24 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
235 236
     }
236 237
 
237 238
     void showModal(ScreenParams screenParams) {
239
+        Screen previousScreen = layout.getCurrentScreen();
240
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("willDisappear", previousScreen.getNavigatorEventId());
241
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("didDisappear", previousScreen.getNavigatorEventId());
238 242
         modalController.showModal(screenParams);
239 243
     }
240 244
 
241 245
     void dismissTopModal() {
242 246
         modalController.dismissTopModal();
247
+        Screen previousScreen = layout.getCurrentScreen();
248
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("willAppear", previousScreen.getNavigatorEventId());
249
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("didAppear", previousScreen.getNavigatorEventId());
243 250
     }
244 251
 
245 252
     void dismissAllModals() {
246 253
         modalController.dismissAllModals();
254
+        Screen previousScreen = layout.getCurrentScreen();
255
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("willAppear", previousScreen.getNavigatorEventId());
256
+        NavigationApplication.instance.getEventEmitter().sendScreenChangedEvent("didAppear", previousScreen.getNavigatorEventId());
247 257
     }
248 258
 
249 259
     public void showLightBox(LightBoxParams params) {