Sfoglia il codice sorgente

Pass defaultOptions to Stack options presenter

Guy Carmeli 6 anni fa
parent
commit
64ddd95e4e

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java Vedi File

@@ -167,6 +167,7 @@ public class LayoutFactory {
167 167
                 .setId(node.id)
168 168
                 .setInitialOptions(parse(typefaceManager, node.getOptions()))
169 169
                 .setStackPresenter(new StackOptionsPresenter(activity, new TitleBarReactViewCreator(reactInstanceManager), defaultOptions))
170
+                .setPresenter(new OptionsPresenter(activity, defaultOptions))
170 171
                 .build();
171 172
 	}
172 173
 

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ChildController.java Vedi File

@@ -1,6 +1,7 @@
1 1
 package com.reactnativenavigation.viewcontrollers;
2 2
 
3 3
 import android.app.Activity;
4
+import android.support.annotation.CallSuper;
4 5
 import android.view.ViewGroup;
5 6
 
6 7
 import com.reactnativenavigation.parse.Options;
@@ -21,6 +22,7 @@ public abstract class ChildController<T extends ViewGroup> extends ViewControlle
21 22
     }
22 23
 
23 24
     @Override
25
+    @CallSuper
24 26
     public void setDefaultOptions(Options defaultOptions) {
25 27
         presenter.setDefaultOptions(defaultOptions);
26 28
     }

+ 2
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java Vedi File

@@ -33,11 +33,9 @@ public class Navigator extends ParentController {
33 33
 
34 34
     @Override
35 35
     public void setDefaultOptions(Options defaultOptions) {
36
+        super.setDefaultOptions(defaultOptions);
36 37
         this.defaultOptions = defaultOptions;
37
-        if (root != null) {
38
-            root.setDefaultOptions(defaultOptions);
39
-            modalStack.setDefaultOptions(defaultOptions);
40
-        }
38
+        modalStack.setDefaultOptions(defaultOptions);
41 39
     }
42 40
 
43 41
     public Options getDefaultOptions() {

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ParentController.java Vedi File

@@ -30,6 +30,7 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
30 30
 
31 31
     @Override
32 32
     public void setDefaultOptions(Options defaultOptions) {
33
+	    super.setDefaultOptions(defaultOptions);
33 34
         Collection<? extends ViewController> children = getChildControllers();
34 35
         if (!CollectionUtils.isNullOrEmpty(children)) {
35 36
             for (ViewController child : children) {

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerBuilder.java Vedi File

@@ -46,6 +46,11 @@ public class StackControllerBuilder {
46 46
         return this;
47 47
     }
48 48
 
49
+    public StackControllerBuilder setPresenter(OptionsPresenter presenter) {
50
+        this.presenter = presenter;
51
+        return this;
52
+    }
53
+
49 54
     public StackControllerBuilder setChildRegistry(ChildControllersRegistry childRegistry) {
50 55
         this.childRegistry = childRegistry;
51 56
         return this;

+ 2
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java Vedi File

@@ -100,7 +100,8 @@ public class NavigatorTest extends BaseTest {
100 100
         uut.setRoot(spy, new CommandListenerAdapter());
101 101
         Options defaultOptions = new Options();
102 102
         uut.setDefaultOptions(defaultOptions);
103
-        verify(spy, times(1)).setDefaultOptions(defaultOptions);
103
+
104
+        verify(spy).setDefaultOptions(defaultOptions);
104 105
         verify(modalStack).setDefaultOptions(defaultOptions);
105 106
     }
106 107