Browse Source

TopBar background component lifecycle methods

Guy Carmeli 6 years ago
parent
commit
18b5e63756
20 changed files with 150 additions and 67 deletions
  1. 2
    1
      lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java
  2. 6
    6
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java
  3. 46
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarBackgroundViewController.java
  4. 4
    5
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarController.java
  5. 5
    5
      lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java
  6. 13
    18
      lib/android/app/src/main/java/com/reactnativenavigation/views/topbar/TopBar.java
  7. 9
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java
  8. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ComponentViewControllerTest.java
  9. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java
  10. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java
  11. 3
    2
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java
  12. 10
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java
  13. 5
    4
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java
  14. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopBarButtonControllerTest.java
  15. 6
    4
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopBarControllerTest.java
  16. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java
  17. 2
    1
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java
  18. 7
    12
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarBackgroundComponentTest.java
  19. 6
    2
      lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java
  20. 16
    0
      playground/src/screens/TopBarBackground.js

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

13
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
13
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
14
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
14
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
15
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController;
15
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
16
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
18
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
18
 import com.reactnativenavigation.views.ComponentViewCreator;
19
 import com.reactnativenavigation.views.ComponentViewCreator;
124
         StackController stackController = new StackController(activity,
125
         StackController stackController = new StackController(activity,
125
                 new TitleBarButtonCreator(reactInstanceManager),
126
                 new TitleBarButtonCreator(reactInstanceManager),
126
                 new TitleBarReactViewCreator(reactInstanceManager),
127
                 new TitleBarReactViewCreator(reactInstanceManager),
127
-                new TopBarBackgroundViewCreator(reactInstanceManager),
128
+                new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreator(reactInstanceManager)),
128
                 new TopBarController(),
129
                 new TopBarController(),
129
                 node.id,
130
                 node.id,
130
                 getOptions(node)
131
                 getOptions(node)

+ 6
- 6
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java View File

10
 import com.reactnativenavigation.anim.NavigationAnimator;
10
 import com.reactnativenavigation.anim.NavigationAnimator;
11
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.Options;
12
 import com.reactnativenavigation.utils.NoOpPromise;
12
 import com.reactnativenavigation.utils.NoOpPromise;
13
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
13
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
14
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
14
 import com.reactnativenavigation.views.Component;
15
 import com.reactnativenavigation.views.Component;
15
 import com.reactnativenavigation.views.ReactComponent;
16
 import com.reactnativenavigation.views.ReactComponent;
16
 import com.reactnativenavigation.views.StackLayout;
17
 import com.reactnativenavigation.views.StackLayout;
17
-import com.reactnativenavigation.views.topbar.TopBar;
18
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
18
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
19
-import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
19
+import com.reactnativenavigation.views.topbar.TopBar;
20
 
20
 
21
 import java.util.Collection;
21
 import java.util.Collection;
22
 import java.util.Iterator;
22
 import java.util.Iterator;
30
     private final NavigationAnimator animator;
30
     private final NavigationAnimator animator;
31
     private final ReactViewCreator topBarButtonCreator;
31
     private final ReactViewCreator topBarButtonCreator;
32
     private final TitleBarReactViewCreator titleBarReactViewCreator;
32
     private final TitleBarReactViewCreator titleBarReactViewCreator;
33
-    private TopBarBackgroundViewCreator topBarBackgroundViewCreator;
33
+    private TopBarBackgroundViewController topBarBackgroundViewController;
34
     private TopBarController topBarController;
34
     private TopBarController topBarController;
35
 
35
 
36
-    public StackController(final Activity activity, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarController topBarController, String id, Options initialOptions) {
36
+    public StackController(final Activity activity, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, String id, Options initialOptions) {
37
         super(activity, id, initialOptions);
37
         super(activity, id, initialOptions);
38
         this.topBarController = topBarController;
38
         this.topBarController = topBarController;
39
         animator = createAnimator();
39
         animator = createAnimator();
40
         this.topBarButtonCreator = topBarButtonCreator;
40
         this.topBarButtonCreator = topBarButtonCreator;
41
         this.titleBarReactViewCreator = titleBarReactViewCreator;
41
         this.titleBarReactViewCreator = titleBarReactViewCreator;
42
-        this.topBarBackgroundViewCreator = topBarBackgroundViewCreator;
42
+        this.topBarBackgroundViewController = topBarBackgroundViewController;
43
     }
43
     }
44
 
44
 
45
     public void applyOptions(Options options) {
45
     public void applyOptions(Options options) {
238
     @NonNull
238
     @NonNull
239
     @Override
239
     @Override
240
     protected StackLayout createView() {
240
     protected StackLayout createView() {
241
-        return new StackLayout(getActivity(), topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, topBarController, this::sendOnNavigationButtonPressed, getId());
241
+        return new StackLayout(getActivity(), topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarController, this::sendOnNavigationButtonPressed, getId());
242
     }
242
     }
243
 
243
 
244
     @NonNull
244
     @NonNull

+ 46
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarBackgroundViewController.java View File

1
+package com.reactnativenavigation.viewcontrollers.topbar;
2
+
3
+import android.app.Activity;
4
+
5
+import com.reactnativenavigation.parse.Options;
6
+import com.reactnativenavigation.utils.CompatUtils;
7
+import com.reactnativenavigation.viewcontrollers.ViewController;
8
+import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
9
+import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
10
+
11
+public class TopBarBackgroundViewController extends ViewController<TopBarBackgroundView> {
12
+
13
+    private TopBarBackgroundViewCreator viewCreator;
14
+    private String component;
15
+
16
+    public TopBarBackgroundViewController(Activity activity, TopBarBackgroundViewCreator viewCreator) {
17
+        super(activity, CompatUtils.generateViewId() + "", new Options());
18
+        this.viewCreator = viewCreator;
19
+    }
20
+
21
+    @Override
22
+    protected TopBarBackgroundView createView() {
23
+        return viewCreator.create(getActivity(), getId(), component);
24
+    }
25
+
26
+    @Override
27
+    public void onViewAppeared() {
28
+        super.onViewAppeared();
29
+        view.sendComponentStart();
30
+    }
31
+
32
+    @Override
33
+    public void onViewDisappear() {
34
+        view.sendComponentStop();
35
+        super.onViewDisappear();
36
+    }
37
+
38
+    @Override
39
+    public void sendOnNavigationButtonPressed(String buttonId) {
40
+
41
+    }
42
+
43
+    public void setComponent(String component) {
44
+        this.component = component;
45
+    }
46
+}

+ 4
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/topbar/TopBarController.java View File

10
 import com.reactnativenavigation.views.StackLayout;
10
 import com.reactnativenavigation.views.StackLayout;
11
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
11
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
12
 import com.reactnativenavigation.views.topbar.TopBar;
12
 import com.reactnativenavigation.views.topbar.TopBar;
13
-import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
14
 
13
 
15
 
14
 
16
 public class TopBarController {
15
 public class TopBarController {
17
     private TopBar topBar;
16
     private TopBar topBar;
18
 
17
 
19
-    public View createView(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator backgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
18
+    public View createView(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
20
         if (topBar == null) {
19
         if (topBar == null) {
21
-            topBar = createTopBar(context, buttonCreator, titleBarReactViewCreator, backgroundViewCreator, topBarButtonClickListener, stackLayout);
20
+            topBar = createTopBar(context, buttonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarButtonClickListener, stackLayout);
22
             topBar.setId(CompatUtils.generateViewId());
21
             topBar.setId(CompatUtils.generateViewId());
23
         }
22
         }
24
         return topBar;
23
         return topBar;
25
     }
24
     }
26
 
25
 
27
-    protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator backgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
28
-        return new TopBar(context, buttonCreator, titleBarReactViewCreator, backgroundViewCreator, topBarButtonClickListener, stackLayout);
26
+    protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
27
+        return new TopBar(context, buttonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarButtonClickListener, stackLayout);
29
     }
28
     }
30
 
29
 
31
     public void clear() {
30
     public void clear() {

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java View File

9
 import com.reactnativenavigation.presentation.OptionsPresenter;
9
 import com.reactnativenavigation.presentation.OptionsPresenter;
10
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
10
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
11
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
11
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
12
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
12
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
14
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
14
-import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
15
 
15
 
16
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
16
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
17
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
17
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
21
     private String stackId;
21
     private String stackId;
22
     private final OptionsPresenter optionsPresenter;
22
     private final OptionsPresenter optionsPresenter;
23
 
23
 
24
-    public StackLayout(Context context, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarController topBarController, TopBarButtonController.OnClickListener topBarButtonClickListener, String stackId) {
24
+    public StackLayout(Context context, ReactViewCreator topBarButtonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, TopBarButtonController.OnClickListener topBarButtonClickListener, String stackId) {
25
         super(context);
25
         super(context);
26
         this.stackId = stackId;
26
         this.stackId = stackId;
27
-        createLayout(topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewCreator, topBarController, topBarButtonClickListener);
27
+        createLayout(topBarButtonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarController, topBarButtonClickListener);
28
         optionsPresenter = new OptionsPresenter(topBarController.getView());
28
         optionsPresenter = new OptionsPresenter(topBarController.getView());
29
         setContentDescription("StackLayout");
29
         setContentDescription("StackLayout");
30
     }
30
     }
31
 
31
 
32
-    private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator BackgroundViewCreator, TopBarController topBarController, TopBarButtonController.OnClickListener topBarButtonClickListener) {
33
-        addView(topBarController.createView(getContext(), buttonCreator, titleBarReactViewCreator, BackgroundViewCreator, topBarButtonClickListener, this), MATCH_PARENT, WRAP_CONTENT);
32
+    private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, TopBarButtonController.OnClickListener topBarButtonClickListener) {
33
+        addView(topBarController.createView(getContext(), buttonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarButtonClickListener, this), MATCH_PARENT, WRAP_CONTENT);
34
     }
34
     }
35
 
35
 
36
     public void applyChildOptions(Options options) {
36
     public void applyChildOptions(Options options) {

+ 13
- 18
lib/android/app/src/main/java/com/reactnativenavigation/views/topbar/TopBar.java View File

1
 package com.reactnativenavigation.views.topbar;
1
 package com.reactnativenavigation.views.topbar;
2
 
2
 
3
 import android.annotation.SuppressLint;
3
 import android.annotation.SuppressLint;
4
-import android.app.Activity;
5
 import android.content.Context;
4
 import android.content.Context;
6
 import android.graphics.Typeface;
5
 import android.graphics.Typeface;
7
 import android.support.annotation.RestrictTo;
6
 import android.support.annotation.RestrictTo;
27
 import com.reactnativenavigation.utils.CompatUtils;
26
 import com.reactnativenavigation.utils.CompatUtils;
28
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
27
 import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
29
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
28
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
29
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
30
 import com.reactnativenavigation.views.StackLayout;
30
 import com.reactnativenavigation.views.StackLayout;
31
-import com.reactnativenavigation.views.toptabs.TopTabs;
32
 import com.reactnativenavigation.views.titlebar.TitleBar;
31
 import com.reactnativenavigation.views.titlebar.TitleBar;
33
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
32
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
33
+import com.reactnativenavigation.views.toptabs.TopTabs;
34
 
34
 
35
 import java.util.List;
35
 import java.util.List;
36
 
36
 
45
     private TopTabs topTabs;
45
     private TopTabs topTabs;
46
     private RelativeLayout root;
46
     private RelativeLayout root;
47
     private StackLayout parentView;
47
     private StackLayout parentView;
48
-    private TopBarBackgroundViewCreator topBarBackgroundViewCreator;
49
-    private TopBarBackgroundView backgroundView;
48
+    private TopBarBackgroundViewController topBarBackgroundViewController;
50
 
49
 
51
-    public TopBar(final Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator topBarBackgroundViewCreator, TopBarButtonController.OnClickListener onClickListener, StackLayout parentView) {
50
+    public TopBar(final Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener onClickListener, StackLayout parentView) {
52
         super(context);
51
         super(context);
53
         collapsingBehavior = new TopBarCollapseBehavior(this);
52
         collapsingBehavior = new TopBarCollapseBehavior(this);
54
-        this.topBarBackgroundViewCreator = topBarBackgroundViewCreator;
53
+        this.topBarBackgroundViewController = topBarBackgroundViewController;
55
         this.parentView = parentView;
54
         this.parentView = parentView;
56
         topTabs = new TopTabs(getContext());
55
         topTabs = new TopTabs(getContext());
57
         animator = new TopBarAnimator(this, parentView.getStackId());
56
         animator = new TopBarAnimator(this, parentView.getStackId());
102
 
101
 
103
     public void setBackgroundComponent(Text component) {
102
     public void setBackgroundComponent(Text component) {
104
         if (component.hasValue()) {
103
         if (component.hasValue()) {
105
-            backgroundView = topBarBackgroundViewCreator.create((Activity) getContext(), String.valueOf(CompatUtils.generateViewId()), component.get());
104
+            topBarBackgroundViewController.setComponent(component.get());
106
             RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, getHeight());
105
             RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, getHeight());
107
-            root.addView(backgroundView, 0, lp);
106
+            root.addView(topBarBackgroundViewController.getView(), 0, lp);
108
         }
107
         }
109
     }
108
     }
110
 
109
 
132
         titleBar.setRightButtons(rightButtons);
131
         titleBar.setRightButtons(rightButtons);
133
     }
132
     }
134
 
133
 
135
-    @RestrictTo(RestrictTo.Scope.TESTS)
136
-    public TextView getTitleTextView() {
137
-        return titleBar.getTitleTextView();
138
-    }
139
-
140
     public void setBackgroundColor(Color color) {
134
     public void setBackgroundColor(Color color) {
141
         titleBar.setBackgroundColor(color);
135
         titleBar.setBackgroundColor(color);
142
     }
136
     }
198
     }
192
     }
199
 
193
 
200
     public void clear() {
194
     public void clear() {
201
-        if (backgroundView != null) {
202
-            backgroundView.destroy();
203
-            root.removeView(backgroundView);
204
-            backgroundView = null;
205
-        }
195
+        topBarBackgroundViewController.destroy();
206
         titleBar.clear();
196
         titleBar.clear();
207
     }
197
     }
208
 
198
 
219
     public void setAnimator(TopBarAnimator animator) {
209
     public void setAnimator(TopBarAnimator animator) {
220
         this.animator = animator;
210
         this.animator = animator;
221
     }
211
     }
212
+
213
+    @RestrictTo(RestrictTo.Scope.TESTS)
214
+    public TextView getTitleTextView() {
215
+        return titleBar.getTitleTextView();
216
+    }
222
 }
217
 }

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

17
 import com.reactnativenavigation.utils.ImageLoader;
17
 import com.reactnativenavigation.utils.ImageLoader;
18
 import com.reactnativenavigation.utils.OptionHelper;
18
 import com.reactnativenavigation.utils.OptionHelper;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
20
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
20
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
21
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
21
 import com.reactnativenavigation.views.BottomTabs;
22
 import com.reactnativenavigation.views.BottomTabs;
22
 import com.reactnativenavigation.views.ReactComponent;
23
 import com.reactnativenavigation.views.ReactComponent;
174
     }
175
     }
175
 
176
 
176
     private StackController createStack(String id) {
177
     private StackController createStack(String id) {
177
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), id, tabOptions);
178
+        return new StackController(activity,
179
+                new TopBarButtonCreatorMock(),
180
+                new TitleBarReactViewCreatorMock(),
181
+                new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()),
182
+                new TopBarController(),
183
+                id,
184
+                tabOptions
185
+        );
178
     }
186
     }
179
 }
187
 }

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

9
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
9
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
10
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
10
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
11
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.Options;
12
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
12
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
13
 import com.reactnativenavigation.views.StackLayout;
14
 import com.reactnativenavigation.views.StackLayout;
14
 
15
 
29
         super.beforeEach();
30
         super.beforeEach();
30
         Activity activity = newActivity();
31
         Activity activity = newActivity();
31
         view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
32
         view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
32
-        ParentController<StackLayout> parentController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
33
+        ParentController<StackLayout> parentController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options());
33
         uut = new ComponentViewController(activity, "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options());
34
         uut = new ComponentViewController(activity, "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options());
34
         uut.setParentController(parentController);
35
         uut.setParentController(parentController);
35
         parentController.ensureViewIsCreated();
36
         parentController.ensureViewIsCreated();

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

14
 import com.reactnativenavigation.parse.FabOptions;
14
 import com.reactnativenavigation.parse.FabOptions;
15
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.Options;
16
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.parse.params.Text;
17
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
17
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
18
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
18
 import com.reactnativenavigation.views.Fab;
19
 import com.reactnativenavigation.views.Fab;
19
 import com.reactnativenavigation.views.FabMenu;
20
 import com.reactnativenavigation.views.FabMenu;
36
     public void beforeEach() {
37
     public void beforeEach() {
37
         super.beforeEach();
38
         super.beforeEach();
38
         activity = newActivity();
39
         activity = newActivity();
39
-        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stackController", new Options());
40
+        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stackController", new Options());
40
         Options options = getOptionsWithFab();
41
         Options options = getOptionsWithFab();
41
         childFab = new SimpleViewController(activity, "child1", options);
42
         childFab = new SimpleViewController(activity, "child1", options);
42
         childNoFab = new SimpleViewController(activity, "child2", new Options());
43
         childNoFab = new SimpleViewController(activity, "child2", new Options());

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

17
 import com.reactnativenavigation.utils.ImageLoader;
17
 import com.reactnativenavigation.utils.ImageLoader;
18
 import com.reactnativenavigation.utils.OptionHelper;
18
 import com.reactnativenavigation.utils.OptionHelper;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
19
 import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
20
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
20
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
21
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
21
 
22
 
22
 import org.junit.Test;
23
 import org.junit.Test;
251
 
252
 
252
     @NonNull
253
     @NonNull
253
     private StackController newStack() {
254
     private StackController newStack() {
254
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(),
255
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(),
255
                 "stack" + CompatUtils.generateViewId(), tabOptions);
256
                 "stack" + CompatUtils.generateViewId(), tabOptions);
256
     }
257
     }
257
 
258
 

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

19
 import com.reactnativenavigation.parse.params.Fraction;
19
 import com.reactnativenavigation.parse.params.Fraction;
20
 import com.reactnativenavigation.parse.params.Text;
20
 import com.reactnativenavigation.parse.params.Text;
21
 import com.reactnativenavigation.utils.ViewUtils;
21
 import com.reactnativenavigation.utils.ViewUtils;
22
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
22
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
23
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
23
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
24
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
24
 
25
 
52
                 (activity1, componentId, componentName) -> view,
53
                 (activity1, componentId, componentName) -> view,
53
                 initialNavigationOptions
54
                 initialNavigationOptions
54
         );
55
         );
55
-        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
56
+        stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options());
56
         stackController.ensureViewIsCreated();
57
         stackController.ensureViewIsCreated();
57
         uut.setParentController(stackController);
58
         uut.setParentController(stackController);
58
     }
59
     }
69
     @Test
70
     @Test
70
     public void initialOptionsAppliedOnAppear() {
71
     public void initialOptionsAppliedOnAppear() {
71
         uut.options.topBarOptions.title.text = new Text("the title");
72
         uut.options.topBarOptions.title.text = new Text("the title");
72
-        StackController stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stackId", new Options());
73
+        StackController stackController = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stackId", new Options());
73
         stackController.animatePush(uut, new MockPromise() {});
74
         stackController.animatePush(uut, new MockPromise() {});
74
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
75
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
75
 
76
 

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

13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14
 import com.reactnativenavigation.parse.Options;
14
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.params.Text;
15
 import com.reactnativenavigation.parse.params.Text;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
16
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.views.ReactComponent;
18
 import com.reactnativenavigation.views.ReactComponent;
18
 
19
 
154
     }
155
     }
155
 
156
 
156
     private StackController createStack() {
157
     private StackController createStack() {
157
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
158
+        return new StackController(
159
+                activity,
160
+                new TopBarButtonCreatorMock(),
161
+                new TitleBarReactViewCreatorMock(),
162
+                new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()),
163
+                new TopBarController(),
164
+                "stack",
165
+                new Options()
166
+        );
158
     }
167
     }
159
 }
168
 }

+ 5
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java View File

16
 import com.reactnativenavigation.parse.params.Bool;
16
 import com.reactnativenavigation.parse.params.Bool;
17
 import com.reactnativenavigation.parse.params.Text;
17
 import com.reactnativenavigation.parse.params.Text;
18
 import com.reactnativenavigation.utils.ViewHelper;
18
 import com.reactnativenavigation.utils.ViewHelper;
19
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
19
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
20
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
20
 import com.reactnativenavigation.views.Component;
21
 import com.reactnativenavigation.views.Component;
21
 import com.reactnativenavigation.views.ReactComponent;
22
 import com.reactnativenavigation.views.ReactComponent;
106
     @Test
107
     @Test
107
     public void pop_layoutHandlesChildWillDisappear() {
108
     public void pop_layoutHandlesChildWillDisappear() {
108
         final StackLayout[] stackLayout = new StackLayout[1];
109
         final StackLayout[] stackLayout = new StackLayout[1];
109
-        uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "uut", new Options()) {
110
+        uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "uut", new Options()) {
110
             @NonNull
111
             @NonNull
111
             @Override
112
             @Override
112
             protected StackLayout createView() {
113
             protected StackLayout createView() {
466
     @Test
467
     @Test
467
     public void mergeChildOptions_updatesViewWithNewOptions() {
468
     public void mergeChildOptions_updatesViewWithNewOptions() {
468
         final StackLayout[] stackLayout = new StackLayout[1];
469
         final StackLayout[] stackLayout = new StackLayout[1];
469
-        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()) {
470
+        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
470
             @NonNull
471
             @NonNull
471
             @Override
472
             @Override
472
             protected StackLayout createView() {
473
             protected StackLayout createView() {
483
     @Test
484
     @Test
484
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
485
     public void mergeChildOptions_updatesParentControllerWithNewOptions() {
485
         final StackLayout[] stackLayout = new StackLayout[1];
486
         final StackLayout[] stackLayout = new StackLayout[1];
486
-        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()) {
487
+        StackController uut = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()) {
487
             @NonNull
488
             @NonNull
488
             @Override
489
             @Override
489
             protected StackLayout createView() {
490
             protected StackLayout createView() {
553
     private StackController createStackController(String id) {
554
     private StackController createStackController(String id) {
554
         topBarController = spy(new TopBarController());
555
         topBarController = spy(new TopBarController());
555
         return new StackController(activity,
556
         return new StackController(activity,
556
-                new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(),
557
+                new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()),
557
                 topBarController, id, new Options()) {
558
                 topBarController, id, new Options()) {
558
             @Override
559
             @Override
559
             NavigationAnimator createAnimator() {
560
             NavigationAnimator createAnimator() {

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

10
 import com.reactnativenavigation.parse.Options;
10
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.parse.params.Button;
11
 import com.reactnativenavigation.parse.params.Button;
12
 import com.reactnativenavigation.parse.params.Text;
12
 import com.reactnativenavigation.parse.params.Text;
13
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
13
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
14
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
14
 
15
 
15
 import org.junit.Ignore;
16
 import org.junit.Ignore;
31
 
32
 
32
         TopBarButtonCreatorMock buttonCreatorMock = new TopBarButtonCreatorMock();
33
         TopBarButtonCreatorMock buttonCreatorMock = new TopBarButtonCreatorMock();
33
         uut = spy(new TopBarButtonController(activity, button, buttonCreatorMock, (buttonId) -> {}));
34
         uut = spy(new TopBarButtonController(activity, button, buttonCreatorMock, (buttonId) -> {}));
34
-        stackController = spy(new StackController(activity, buttonCreatorMock, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options()));
35
+        stackController = spy(new StackController(activity, buttonCreatorMock, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options()));
35
 
36
 
36
     }
37
     }
37
 
38
 

+ 6
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopBarControllerTest.java View File

1
 package com.reactnativenavigation.viewcontrollers;
1
 package com.reactnativenavigation.viewcontrollers;
2
 
2
 
3
+import android.app.Activity;
3
 import android.content.Context;
4
 import android.content.Context;
4
 import android.support.annotation.NonNull;
5
 import android.support.annotation.NonNull;
5
 
6
 
7
 import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
8
 import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
8
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
9
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
9
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
10
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
11
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
10
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
12
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
11
 import com.reactnativenavigation.views.StackLayout;
13
 import com.reactnativenavigation.views.StackLayout;
12
 import com.reactnativenavigation.views.titlebar.TitleBar;
14
 import com.reactnativenavigation.views.titlebar.TitleBar;
13
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
15
 import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
14
 import com.reactnativenavigation.views.topbar.TopBar;
16
 import com.reactnativenavigation.views.topbar.TopBar;
15
-import com.reactnativenavigation.views.topbar.TopBarBackgroundViewCreator;
16
 
17
 
17
 import org.junit.Test;
18
 import org.junit.Test;
18
 import org.mockito.Mockito;
19
 import org.mockito.Mockito;
36
         uut = new TopBarController() {
37
         uut = new TopBarController() {
37
             @NonNull
38
             @NonNull
38
             @Override
39
             @Override
39
-            protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewCreator backgroundViewCreator, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
40
-                return new TopBar(context, buttonCreator, titleBarReactViewCreator, backgroundViewCreator, topBarButtonClickListener, stackLayout) {
40
+            protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout) {
41
+                return new TopBar(context, buttonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarButtonClickListener, stackLayout) {
41
                     @Override
42
                     @Override
42
                     protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
43
                     protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
43
                         titleBar[0] = spy(super.createTitleBar(context, buttonCreator, reactViewCreator, onClickListener));
44
                         titleBar[0] = spy(super.createTitleBar(context, buttonCreator, reactViewCreator, onClickListener));
46
                 };
47
                 };
47
             }
48
             }
48
         };
49
         };
49
-        uut.createView(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), buttonId -> { }, Mockito.mock(StackLayout.class));
50
+        Activity activity = newActivity();
51
+        uut.createView(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), buttonId -> { }, Mockito.mock(StackLayout.class));
50
         uut.clear();
52
         uut.clear();
51
         verify(titleBar[0], times(1)).clear();
53
         verify(titleBar[0], times(1)).clear();
52
     }
54
     }

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

14
 import com.reactnativenavigation.parse.Options;
14
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.params.Text;
15
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.utils.ViewHelper;
16
 import com.reactnativenavigation.utils.ViewHelper;
17
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
17
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
18
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
18
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
19
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsAdapter;
19
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
20
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
70
 
71
 
71
     @NonNull
72
     @NonNull
72
     private StackController createStackController(String id) {
73
     private StackController createStackController(String id) {
73
-        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), id, new Options());
74
+        return new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), id, new Options());
74
     }
75
     }
75
 
76
 
76
     @NonNull
77
     @NonNull

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

13
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
14
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
15
 import com.reactnativenavigation.parse.Options;
15
 import com.reactnativenavigation.parse.Options;
16
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
16
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 
18
 
18
 import org.assertj.android.api.Assertions;
19
 import org.assertj.android.api.Assertions;
69
     @Test
70
     @Test
70
     public void holdsAReferenceToStackControllerOrNull() {
71
     public void holdsAReferenceToStackControllerOrNull() {
71
         assertThat(uut.getParentController()).isNull();
72
         assertThat(uut.getParentController()).isNull();
72
-        StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), "stack", new Options());
73
+        StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options());
73
         nav.animatePush(uut, new MockPromise());
74
         nav.animatePush(uut, new MockPromise());
74
         assertThat(uut.getParentController()).isEqualTo(nav);
75
         assertThat(uut.getParentController()).isEqualTo(nav);
75
     }
76
     }

+ 7
- 12
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarBackgroundComponentTest.java View File

12
 import com.reactnativenavigation.parse.params.Text;
12
 import com.reactnativenavigation.parse.params.Text;
13
 import com.reactnativenavigation.utils.ViewUtils;
13
 import com.reactnativenavigation.utils.ViewUtils;
14
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
14
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
15
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
15
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
16
 import com.reactnativenavigation.views.topbar.TopBar;
17
 import com.reactnativenavigation.views.topbar.TopBar;
17
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
18
 import com.reactnativenavigation.views.topbar.TopBarBackgroundView;
25
 
26
 
26
 public class TopBarBackgroundComponentTest extends BaseTest {
27
 public class TopBarBackgroundComponentTest extends BaseTest {
27
     private TopBar uut;
28
     private TopBar uut;
28
-    private TopBarBackgroundView backgroundView;
29
+    private TopBarBackgroundViewController topBarBackgroundViewController;
29
 
30
 
30
     @SuppressWarnings("Convert2Lambda")
31
     @SuppressWarnings("Convert2Lambda")
31
     @Override
32
     @Override
36
                 Log.i("TopBarTest", "onPress: " + buttonId);
37
                 Log.i("TopBarTest", "onPress: " + buttonId);
37
             }
38
             }
38
         });
39
         });
39
-        TopBarBackgroundViewCreatorMock backgroundViewCreator = new TopBarBackgroundViewCreatorMock() {
40
-            @Override
41
-            public TopBarBackgroundView create(Activity activity, String componentId, String componentName) {
42
-                backgroundView = spy(super.create(activity, componentId, componentName));
43
-                return backgroundView;
44
-            }
45
-        };
46
-        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, new TopBarController(), onClickListener, null);
47
-        uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), backgroundViewCreator, onClickListener, parent);
40
+        Activity activity = newActivity();
41
+        topBarBackgroundViewController = spy(new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()));
42
+        StackLayout parent = new StackLayout(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), topBarBackgroundViewController, new TopBarController(), onClickListener, null);
43
+        uut = new TopBar(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), topBarBackgroundViewController, onClickListener, parent);
48
         parent.addView(uut);
44
         parent.addView(uut);
49
     }
45
     }
50
 
46
 
68
     public void clear_componentIsDestroyed() {
64
     public void clear_componentIsDestroyed() {
69
         uut.setBackgroundComponent(new Text("someComponent"));
65
         uut.setBackgroundComponent(new Text("someComponent"));
70
         uut.clear();
66
         uut.clear();
71
-        verify(backgroundView, times(1)).destroy();
72
-        assertThat(backgroundView.getParent()).isNull();
67
+        verify(topBarBackgroundViewController, times(1)).destroy();
73
     }
68
     }
74
 }
69
 }

+ 6
- 2
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java View File

1
 package com.reactnativenavigation.views;
1
 package com.reactnativenavigation.views;
2
 
2
 
3
+import android.app.Activity;
3
 import android.util.Log;
4
 import android.util.Log;
4
 import android.view.MenuItem;
5
 import android.view.MenuItem;
5
 
6
 
13
 import com.reactnativenavigation.parse.params.Text;
14
 import com.reactnativenavigation.parse.params.Text;
14
 import com.reactnativenavigation.utils.TitleBarHelper;
15
 import com.reactnativenavigation.utils.TitleBarHelper;
15
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
16
 import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
17
+import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
16
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
18
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
17
 import com.reactnativenavigation.views.topbar.TopBar;
19
 import com.reactnativenavigation.views.topbar.TopBar;
18
 
20
 
42
                 Log.i("TopBarTest", "onPress: " + buttonId);
44
                 Log.i("TopBarTest", "onPress: " + buttonId);
43
             }
45
             }
44
         });
46
         });
45
-        StackLayout parent = new StackLayout(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TopBarController(), this.onClickListener, null);
46
-        uut = new TopBar(newActivity(), new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), this.onClickListener, parent);
47
+        Activity activity = newActivity();
48
+        TopBarBackgroundViewController topBarBackgroundViewController = new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock());
49
+        StackLayout parent = new StackLayout(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), topBarBackgroundViewController, new TopBarController(), this.onClickListener, null);
50
+        uut = new TopBar(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), topBarBackgroundViewController, this.onClickListener, parent);
47
         animator = spy(new TopBarAnimator(uut));
51
         animator = spy(new TopBarAnimator(uut));
48
         uut.setAnimator(animator);
52
         uut.setAnimator(animator);
49
         leftButton = createLeftButton();
53
         leftButton = createLeftButton();

+ 16
- 0
playground/src/screens/TopBarBackground.js View File

13
     this.dots = new Array(55).fill('').map((ignored, i) => <View key={'dot' + i} style={styles.dot}/>);
13
     this.dots = new Array(55).fill('').map((ignored, i) => <View key={'dot' + i} style={styles.dot}/>);
14
   }
14
   }
15
 
15
 
16
+  componentDidAppear() {
17
+    console.log('RNN', 'TBB.componentDidAppear');
18
+  }
19
+
20
+  componentDidDisappear() {
21
+    console.log('RNN', `TBB.componentDidDisappear`);
22
+  }
23
+
24
+  componentDidMount() {
25
+    console.log('RNN', `TBB.componentDidMount`);
26
+  }
27
+
28
+  componentWillUnmount() {
29
+    console.log('RNN', `TBB.componentWillUnmount`);
30
+  }
31
+
16
   render() {
32
   render() {
17
     return (
33
     return (
18
       <View style={styles.container}>
34
       <View style={styles.container}>