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,7 +245,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
245 245
     protected abstract String getCurrentNavigatorId();
246 246
 
247 247
     @CallSuper
248
-    protected Screen getCurrentScreen() {
248
+    public Screen getCurrentScreen() {
249 249
         ModalController modalController = ModalController.getInstance();
250 250
         if (modalController.isModalDisplayed()) {
251 251
             RnnModal modal = modalController.get();

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

@@ -147,7 +147,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
147 147
     }
148 148
 
149 149
     @Override
150
-    protected Screen getCurrentScreen() {
150
+    public Screen getCurrentScreen() {
151 151
         Screen currentScreen = super.getCurrentScreen();
152 152
         if (currentScreen != null) {
153 153
             return currentScreen;

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

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

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

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

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

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

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

@@ -16,6 +16,7 @@ import com.reactnativenavigation.R;
16 16
 import com.reactnativenavigation.activities.BaseReactActivity;
17 17
 import com.reactnativenavigation.controllers.ModalController;
18 18
 import com.reactnativenavigation.core.objects.Screen;
19
+import com.reactnativenavigation.utils.ContextProvider;
19 20
 import com.reactnativenavigation.utils.SdkSupports;
20 21
 import com.reactnativenavigation.utils.StyleHelper;
21 22
 import com.reactnativenavigation.views.RctView;
@@ -93,6 +94,11 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene
93 94
     @Override
94 95
     public void onDismiss(DialogInterface dialog) {
95 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
 }