Browse Source

Push and Pop to current stack

Guy Carmeli 8 years ago
parent
commit
e4edd6d195

+ 13
- 11
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java View File

@@ -24,8 +24,8 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
24 24
 
25 25
     private ActivityParams params;
26 26
     private BottomTabs bottomTabs;
27
-    private List<ScreenStack> screenStacks;
28
-    private int currentStack = 0;
27
+    private ArrayList<ScreenStack> screenStacks;
28
+    private int currentStackIndex = 0;
29 29
 
30 30
     public BottomTabsLayout(Context context, ActivityParams params) {
31 31
         super(context);
@@ -116,26 +116,28 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
116 116
 
117 117
     @Override
118 118
     public void push(ScreenParams screenParams) {
119
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
120
-//            screenStacks.get(i).push(screenParams);
121
-        }
119
+        getCurrentScreenStack().push(screenParams);
122 120
     }
123 121
 
124 122
     @Override
125 123
     public void pop(ScreenParams screenParams) {
126
-//        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
127
-//            screenStacks.get(i).pop();
128
-//        }
124
+        getCurrentScreenStack().pop();
129 125
     }
130 126
 
131 127
     @Override
132 128
     public void popToRoot(ScreenParams params) {
133
-
129
+        getCurrentScreenStack().popToRoot();
134 130
     }
135 131
 
136 132
     @Override
137 133
     public void newStack(ScreenParams params) {
134
+        ScreenStack currentScreenStack = getCurrentScreenStack();
135
+        currentScreenStack.destroy();
136
+        removeView(currentScreenStack);
138 137
 
138
+        ScreenStack newStack = new ScreenStack(getContext(), params);
139
+        screenStacks.set(currentStackIndex, newStack);
140
+        addView(newStack, 0, new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
139 141
     }
140 142
 
141 143
     @Override
@@ -147,11 +149,11 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
147 149
     public void onTabSelected(int position, boolean wasSelected) {
148 150
         removeView(getCurrentScreenStack());
149 151
         addView(screenStacks.get(position), 0, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
150
-        currentStack = position;
152
+        currentStackIndex = position;
151 153
     }
152 154
 
153 155
     private ScreenStack getCurrentScreenStack() {
154
-        return screenStacks.get(currentStack);
156
+        return screenStacks.get(currentStackIndex);
155 157
     }
156 158
 
157 159
     private ScreenStack getFirstScreenStack() {