Selaa lähdekoodia

Unmount custom TitleBar buttons

Guy Carmeli 7 vuotta sitten
vanhempi
commit
db69a30a35

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/screens/CollapsingViewPagerScreen.java Näytä tiedosto

@@ -111,7 +111,6 @@ public class CollapsingViewPagerScreen extends ViewPagerScreen {
111 111
                 ((CollapsingContentView) contentView).destroy();
112 112
             }
113 113
         }
114
-        topBar.destroy();
115 114
     }
116 115
 
117 116
     protected ContentView getCurrentPage() {

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java Näytä tiedosto

@@ -367,5 +367,6 @@ public abstract class Screen extends RelativeLayout implements Subscriber {
367 367
         unmountReactView();
368 368
         EventBus.instance.unregister(this);
369 369
         sharedElements.destroy();
370
+        topBar.destroy();
370 371
     }
371 372
 }

+ 12
- 0
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Näytä tiedosto

@@ -324,4 +324,16 @@ public class TitleBar extends Toolbar {
324 324
             leftButton.updateNavigatorEventId(screenParams.getNavigatorEventId());
325 325
         }
326 326
     }
327
+
328
+    public void destroy() {
329
+        unmountCustomButtons();
330
+    }
331
+
332
+    private void unmountCustomButtons() {
333
+        for (int i = 0; i < actionMenuView.getChildCount(); i++) {
334
+            if (actionMenuView.getChildAt(i) instanceof TitleBarButtonComponent) {
335
+                ((ContentView) actionMenuView.getChildAt(i)).unmountReactView();
336
+            }
337
+        }
338
+    }
327 339
 }

+ 0
- 25
android/app/src/main/java/com/reactnativenavigation/views/TitleBarCustomComponentButton.java Näytä tiedosto

@@ -1,25 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.support.annotation.Nullable;
5
-import android.view.Menu;
6
-import android.view.MenuItem;
7
-import android.view.View;
8
-
9
-import com.reactnativenavigation.params.NavigationParams;
10
-import com.reactnativenavigation.params.TitleBarButtonParams;
11
-
12
-class TitleBarCustomComponentButton extends TitleBarButton {
13
-    TitleBarCustomComponentButton(Menu menu, View parent, TitleBarButtonParams buttonParams, @Nullable String navigatorEventId) {
14
-        super(menu, parent, buttonParams, navigatorEventId);
15
-    }
16
-
17
-    @Override
18
-    MenuItem addToMenu(int index) {
19
-        throw new RuntimeException("Can't add custom component to menu");
20
-    }
21
-
22
-    View createView(Context context) {
23
-        return new ContentView(context, buttonParams.componentName, NavigationParams.EMPTY, buttonParams.componentProps);
24
-    }
25
-}

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/views/TopBar.java Näytä tiedosto

@@ -219,6 +219,7 @@ public class TopBar extends AppBarLayout {
219 219
         if (reactView != null) {
220 220
             reactView.unmountReactView();
221 221
         }
222
+        titleBar.destroy();
222 223
     }
223 224
 
224 225
     public void onViewPagerScreenChanged(BaseScreenParams screenParams) {