Explorar el Código

Fix edge case where screens were missing back button

When a root containing a stack with multiple children was displayed, initial stack children were
missing back button.
Guy Carmeli hace 6 años
padre
commit
da1e7c6fed

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java Ver fichero

@@ -53,6 +53,7 @@ public class StackController extends ParentController<StackLayout> {
53 53
         for (ViewController child : children) {
54 54
             stack.push(child.getId(), child);
55 55
             child.setParentController(this);
56
+            if (size() > 1) backButtonHelper.addToPushedChild(child);
56 57
         }
57 58
     }
58 59
 

+ 7
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java Ver fichero

@@ -98,6 +98,13 @@ public class StackControllerTest extends BaseTest {
98 98
         }
99 99
     }
100 100
 
101
+    @Test
102
+    public void constructor_backButtonIsAddedToChild() {
103
+        createStack(Arrays.asList(child1, child2, child3));
104
+        assertThat(child2.options.topBar.buttons.back.visible.get(false)).isTrue();
105
+        assertThat(child3.options.topBar.buttons.back.visible.get(false)).isTrue();
106
+    }
107
+
101 108
     @Test
102 109
     public void createView_currentChildIsAdded() {
103 110
         StackController uut = createStack(Arrays.asList(child1, child2, child3, child4));