|
@@ -1,43 +1,40 @@
|
1
|
1
|
package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
|
-import android.annotation.SuppressLint;
|
4
|
|
-import android.content.Context;
|
5
|
|
-import android.graphics.Typeface;
|
6
|
|
-import android.support.annotation.ColorInt;
|
7
|
|
-import android.support.annotation.Nullable;
|
8
|
|
-import android.support.design.widget.AppBarLayout;
|
|
3
|
+import android.annotation.*;
|
|
4
|
+import android.content.*;
|
|
5
|
+import android.graphics.*;
|
|
6
|
+import android.support.annotation.*;
|
|
7
|
+import android.support.design.widget.*;
|
9
|
8
|
import android.support.v7.widget.Toolbar;
|
10
|
|
-import android.util.Log;
|
11
|
|
-import android.view.Menu;
|
12
|
|
-import android.view.View;
|
13
|
|
-import android.view.ViewGroup;
|
14
|
|
-import android.widget.TextView;
|
15
|
|
-
|
16
|
|
-import com.facebook.react.uimanager.events.EventDispatcher;
|
17
|
|
-import com.reactnativenavigation.anim.TopBarAnimator;
|
18
|
|
-import com.reactnativenavigation.anim.TopBarCollapseBehavior;
|
|
9
|
+import android.util.*;
|
|
10
|
+import android.view.*;
|
|
11
|
+import android.widget.*;
|
|
12
|
+
|
|
13
|
+import com.facebook.react.uimanager.events.*;
|
|
14
|
+import com.reactnativenavigation.anim.*;
|
19
|
15
|
import com.reactnativenavigation.parse.Button;
|
20
|
16
|
import com.reactnativenavigation.parse.Color;
|
21
|
|
-import com.reactnativenavigation.parse.NavigationOptions;
|
|
17
|
+import com.reactnativenavigation.parse.*;
|
22
|
18
|
import com.reactnativenavigation.parse.Number;
|
23
|
|
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsViewPager;
|
24
|
|
-import com.reactnativenavigation.parse.Color;
|
|
19
|
+import com.reactnativenavigation.viewcontrollers.toptabs.*;
|
25
|
20
|
|
26
|
|
-import java.util.ArrayList;
|
|
21
|
+import java.util.*;
|
27
|
22
|
|
28
|
23
|
@SuppressLint("ViewConstructor")
|
29
|
24
|
public class TopBar extends AppBarLayout {
|
30
|
|
- private final Toolbar titleBar;
|
|
25
|
+ private final Toolbar titleBar;
|
|
26
|
+ private final TopBarCollapseBehavior collapsingBehavior;
|
|
27
|
+ private final TopBarAnimator animator;
|
31
|
28
|
private Component component;
|
32
|
29
|
private TopTabs topTabs;
|
33
|
30
|
|
34
|
|
- public TopBar(final Context context, Component component) {
|
|
31
|
+ public TopBar(final Context context, Component component, EventDispatcher eventDispatcher) {
|
35
|
32
|
super(context);
|
36
|
33
|
collapsingBehavior = new TopBarCollapseBehavior(eventDispatcher, this);
|
37
|
34
|
this.component = component;
|
38
|
35
|
titleBar = new Toolbar(context);
|
39
|
36
|
topTabs = new TopTabs(getContext());
|
40
|
|
- animator = new TopBarAnimator(this, component != null ? component.getContentView() : null);
|
|
37
|
+ this.animator = new TopBarAnimator(this, component != null ? component.getContentView() : null);
|
41
|
38
|
addView(titleBar);
|
42
|
39
|
}
|
43
|
40
|
|
|
@@ -121,10 +118,10 @@ public class TopBar extends AppBarLayout {
|
121
|
118
|
setLeftButton(leftButton);
|
122
|
119
|
}
|
123
|
120
|
|
124
|
|
- private void setLeftButton(final Button button) {
|
125
|
|
- TitleBarButton leftBarButton = new TitleBarButton(component, this.titleBar, button);
|
126
|
|
- leftBarButton.applyNavigationIcon(getContext());
|
127
|
|
- }
|
|
121
|
+ private void setLeftButton(final Button button) {
|
|
122
|
+ TitleBarButton leftBarButton = new TitleBarButton(component, this.titleBar, button);
|
|
123
|
+ leftBarButton.applyNavigationIcon(getContext());
|
|
124
|
+ }
|
128
|
125
|
|
129
|
126
|
private void setRightButtons(ArrayList<Button> rightButtons) {
|
130
|
127
|
if (rightButtons == null || rightButtons.size() == 0) {
|
|
@@ -134,11 +131,11 @@ public class TopBar extends AppBarLayout {
|
134
|
131
|
Menu menu = getTitleBar().getMenu();
|
135
|
132
|
menu.clear();
|
136
|
133
|
|
137
|
|
- for (int i = 0; i < rightButtons.size(); i++){
|
138
|
|
- Button button = rightButtons.get(i);
|
139
|
|
- TitleBarButton titleBarButton = new TitleBarButton(component, this.titleBar, button);
|
140
|
|
- titleBarButton.addToMenu(getContext(), menu);
|
141
|
|
- }
|
|
134
|
+ for (int i = 0; i < rightButtons.size(); i++) {
|
|
135
|
+ Button button = rightButtons.get(i);
|
|
136
|
+ TitleBarButton titleBarButton = new TitleBarButton(component, this.titleBar, button);
|
|
137
|
+ titleBarButton.addToMenu(getContext(), menu);
|
|
138
|
+ }
|
142
|
139
|
}
|
143
|
140
|
|
144
|
141
|
public Toolbar getTitleBar() {
|