Browse Source

Pass defaultOptions to Stack options presenter

Guy Carmeli 6 years ago
parent
commit
64ddd95e4e

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

167
                 .setId(node.id)
167
                 .setId(node.id)
168
                 .setInitialOptions(parse(typefaceManager, node.getOptions()))
168
                 .setInitialOptions(parse(typefaceManager, node.getOptions()))
169
                 .setStackPresenter(new StackOptionsPresenter(activity, new TitleBarReactViewCreator(reactInstanceManager), defaultOptions))
169
                 .setStackPresenter(new StackOptionsPresenter(activity, new TitleBarReactViewCreator(reactInstanceManager), defaultOptions))
170
+                .setPresenter(new OptionsPresenter(activity, defaultOptions))
170
                 .build();
171
                 .build();
171
 	}
172
 	}
172
 
173
 

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

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

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

33
 
33
 
34
     @Override
34
     @Override
35
     public void setDefaultOptions(Options defaultOptions) {
35
     public void setDefaultOptions(Options defaultOptions) {
36
+        super.setDefaultOptions(defaultOptions);
36
         this.defaultOptions = defaultOptions;
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
     public Options getDefaultOptions() {
41
     public Options getDefaultOptions() {

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

30
 
30
 
31
     @Override
31
     @Override
32
     public void setDefaultOptions(Options defaultOptions) {
32
     public void setDefaultOptions(Options defaultOptions) {
33
+	    super.setDefaultOptions(defaultOptions);
33
         Collection<? extends ViewController> children = getChildControllers();
34
         Collection<? extends ViewController> children = getChildControllers();
34
         if (!CollectionUtils.isNullOrEmpty(children)) {
35
         if (!CollectionUtils.isNullOrEmpty(children)) {
35
             for (ViewController child : children) {
36
             for (ViewController child : children) {

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

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

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

100
         uut.setRoot(spy, new CommandListenerAdapter());
100
         uut.setRoot(spy, new CommandListenerAdapter());
101
         Options defaultOptions = new Options();
101
         Options defaultOptions = new Options();
102
         uut.setDefaultOptions(defaultOptions);
102
         uut.setDefaultOptions(defaultOptions);
103
-        verify(spy, times(1)).setDefaultOptions(defaultOptions);
103
+
104
+        verify(spy).setDefaultOptions(defaultOptions);
104
         verify(modalStack).setDefaultOptions(defaultOptions);
105
         verify(modalStack).setDefaultOptions(defaultOptions);
105
     }
106
     }
106
 
107