Browse Source

Update toolbar with correct screen after modal dismiss

Guy Carmeli 8 years ago
parent
commit
13082dfe93

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

245
     protected abstract String getCurrentNavigatorId();
245
     protected abstract String getCurrentNavigatorId();
246
 
246
 
247
     @CallSuper
247
     @CallSuper
248
-    protected Screen getCurrentScreen() {
248
+    public Screen getCurrentScreen() {
249
         ModalController modalController = ModalController.getInstance();
249
         ModalController modalController = ModalController.getInstance();
250
         if (modalController.isModalDisplayed()) {
250
         if (modalController.isModalDisplayed()) {
251
             RnnModal modal = modalController.get();
251
             RnnModal modal = modalController.get();

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

147
     }
147
     }
148
 
148
 
149
     @Override
149
     @Override
150
-    protected Screen getCurrentScreen() {
150
+    public Screen getCurrentScreen() {
151
         Screen currentScreen = super.getCurrentScreen();
151
         Screen currentScreen = super.getCurrentScreen();
152
         if (currentScreen != null) {
152
         if (currentScreen != null) {
153
             return currentScreen;
153
             return currentScreen;

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java View File

28
      // No need to implement stack interface since this activity is only used to start other
28
      // No need to implement stack interface since this activity is only used to start other
29
     // activities such as TabActivity or SingleScreenActivity.
29
     // activities such as TabActivity or SingleScreenActivity.
30
     @Override
30
     @Override
31
-    protected Screen getCurrentScreen() {
31
+    public Screen getCurrentScreen() {
32
         return null;
32
         return null;
33
     }
33
     }
34
 
34
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java View File

78
     }
78
     }
79
 
79
 
80
     @Override
80
     @Override
81
-    protected Screen getCurrentScreen() {
81
+    public Screen getCurrentScreen() {
82
         Screen currentScreen = super.getCurrentScreen();
82
         Screen currentScreen = super.getCurrentScreen();
83
         if (currentScreen != null) {
83
         if (currentScreen != null) {
84
             return currentScreen;
84
             return currentScreen;

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

81
     }
81
     }
82
 
82
 
83
     @Override
83
     @Override
84
-    protected Screen getCurrentScreen() {
84
+    public Screen getCurrentScreen() {
85
         return mAdapter.peek(getCurrentNavigatorId());
85
         return mAdapter.peek(getCurrentNavigatorId());
86
     }
86
     }
87
 
87
 

+ 7
- 1
android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java View File

16
 import com.reactnativenavigation.activities.BaseReactActivity;
16
 import com.reactnativenavigation.activities.BaseReactActivity;
17
 import com.reactnativenavigation.controllers.ModalController;
17
 import com.reactnativenavigation.controllers.ModalController;
18
 import com.reactnativenavigation.core.objects.Screen;
18
 import com.reactnativenavigation.core.objects.Screen;
19
+import com.reactnativenavigation.utils.ContextProvider;
19
 import com.reactnativenavigation.utils.SdkSupports;
20
 import com.reactnativenavigation.utils.SdkSupports;
20
 import com.reactnativenavigation.utils.StyleHelper;
21
 import com.reactnativenavigation.utils.StyleHelper;
21
 import com.reactnativenavigation.views.RctView;
22
 import com.reactnativenavigation.views.RctView;
93
     @Override
94
     @Override
94
     public void onDismiss(DialogInterface dialog) {
95
     public void onDismiss(DialogInterface dialog) {
95
         ModalController.getInstance().remove();
96
         ModalController.getInstance().remove();
96
-        StyleHelper.updateStyles(mToolBar, getCurrentScreen());
97
+        // After modal is dismissed, update Toolbar with screen from parent activity or previously displayed modal
98
+        BaseReactActivity context = ContextProvider.getActivityContext();
99
+        if (context != null) {
100
+            Screen currentScreen = context.getCurrentScreen();
101
+            StyleHelper.updateStyles(mToolBar, currentScreen);
102
+        }
97
     }
103
     }
98
 }
104
 }