Explorar el Código

Update Toolbar with correct screen after pop from modal

Guy Carmeli hace 8 años
padre
commit
f819ebe32e

+ 4
- 1
android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java Ver fichero

@@ -73,7 +73,10 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene
73 73
         if (mScreenStack.isEmpty()) {
74 74
             dismiss();
75 75
         }
76
-        mToolBar.update(popped);
76
+        Screen currentScreen = getCurrentScreen();
77
+        if (currentScreen != null) {
78
+            mToolBar.update(currentScreen);
79
+        }
77 80
         return popped;
78 81
     }
79 82
 

+ 4
- 3
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java Ver fichero

@@ -7,6 +7,7 @@ import android.content.res.Resources;
7 7
 import android.graphics.drawable.Drawable;
8 8
 import android.os.AsyncTask;
9 9
 import android.support.annotation.ColorInt;
10
+import android.support.annotation.NonNull;
10 11
 import android.support.annotation.UiThread;
11 12
 import android.support.v4.content.ContextCompat;
12 13
 import android.support.v4.content.res.ResourcesCompat;
@@ -111,14 +112,14 @@ public class RnnToolBar extends Toolbar {
111 112
     }
112 113
 
113 114
     private void showToolbar() {
114
-        ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
115
+        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
115 116
         if (actionBar != null) {
116 117
             actionBar.show();
117 118
         }
118 119
     }
119 120
 
120 121
     private void hideToolbar() {
121
-        ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
122
+        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
122 123
         if (actionBar != null) {
123 124
             actionBar.hide();
124 125
         }
@@ -161,7 +162,7 @@ public class RnnToolBar extends Toolbar {
161 162
      * @param screen The currently displayed screen
162 163
      */
163 164
     @UiThread
164
-    public void update(Screen screen) {
165
+    public void update(@NonNull Screen screen) {
165 166
         ((AppCompatActivity) getContext()).setSupportActionBar(this);
166 167
         setTitle(screen.title);
167 168
         setStyle(screen);