|
@@ -10,6 +10,7 @@ import android.support.design.widget.AppBarLayout;
|
10
|
10
|
import android.support.v4.view.ViewPager;
|
11
|
11
|
import android.support.v7.widget.Toolbar;
|
12
|
12
|
import android.view.View;
|
|
13
|
+import android.widget.RelativeLayout;
|
13
|
14
|
import android.widget.TextView;
|
14
|
15
|
|
15
|
16
|
import com.reactnativenavigation.anim.AnimationListener;
|
|
@@ -17,12 +18,12 @@ import com.reactnativenavigation.anim.TopBarAnimator;
|
17
|
18
|
import com.reactnativenavigation.anim.TopBarCollapseBehavior;
|
18
|
19
|
import com.reactnativenavigation.interfaces.ScrollEventListener;
|
19
|
20
|
import com.reactnativenavigation.parse.AnimationOptions;
|
20
|
|
-import com.reactnativenavigation.parse.AnimationsOptions;
|
21
|
21
|
import com.reactnativenavigation.parse.TitleOptions;
|
22
|
22
|
import com.reactnativenavigation.parse.params.Button;
|
23
|
23
|
import com.reactnativenavigation.parse.params.Color;
|
24
|
24
|
import com.reactnativenavigation.parse.params.Fraction;
|
25
|
25
|
import com.reactnativenavigation.parse.params.Number;
|
|
26
|
+import com.reactnativenavigation.utils.CompatUtils;
|
26
|
27
|
import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
|
27
|
28
|
import com.reactnativenavigation.viewcontrollers.TitleBarReactViewController;
|
28
|
29
|
import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
|
|
@@ -36,20 +37,28 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
36
|
37
|
|
37
|
38
|
@SuppressLint("ViewConstructor")
|
38
|
39
|
public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAwareView {
|
39
|
|
- private final TitleBar titleBar;
|
|
40
|
+ private TitleBar titleBar;
|
40
|
41
|
private final TopBarCollapseBehavior collapsingBehavior;
|
41
|
42
|
private TopBarAnimator animator;
|
42
|
43
|
private TopTabs topTabs;
|
|
44
|
+ private RelativeLayout root;
|
43
|
45
|
private StackLayout parentView;
|
44
|
46
|
|
45
|
47
|
public TopBar(final Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarButtonController.OnClickListener onClickListener, StackLayout parentView) {
|
46
|
48
|
super(context);
|
47
|
49
|
collapsingBehavior = new TopBarCollapseBehavior(this);
|
48
|
|
- topTabs = new TopTabs(getContext());
|
49
|
50
|
animator = new TopBarAnimator(this);
|
50
|
51
|
this.parentView = parentView;
|
51
|
|
- titleBar = createTitleBar(context, buttonCreator, titleBarReactViewCreator, onClickListener);
|
52
|
|
- addView(titleBar);
|
|
52
|
+ createLayout(buttonCreator, titleBarReactViewCreator, onClickListener);
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
|
56
|
+ topTabs = new TopTabs(getContext());
|
|
57
|
+ titleBar = createTitleBar(getContext(), buttonCreator, titleBarReactViewCreator, onClickListener);
|
|
58
|
+ titleBar.setId(CompatUtils.generateViewId());
|
|
59
|
+ root = new RelativeLayout(getContext());
|
|
60
|
+ root.addView(titleBar, MATCH_PARENT, WRAP_CONTENT);
|
|
61
|
+ addView(root, MATCH_PARENT, WRAP_CONTENT);
|
53
|
62
|
setContentDescription("TopBar");
|
54
|
63
|
}
|
55
|
64
|
|
|
@@ -129,7 +138,9 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
129
|
138
|
public void initTopTabs(ViewPager viewPager) {
|
130
|
139
|
topTabs = new TopTabs(getContext());
|
131
|
140
|
topTabs.init(viewPager);
|
132
|
|
- addView(topTabs);
|
|
141
|
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
|
|
142
|
+ lp.addRule(RelativeLayout.BELOW, titleBar.getId());
|
|
143
|
+ root.addView(topTabs, lp);
|
133
|
144
|
}
|
134
|
145
|
|
135
|
146
|
public void enableCollapse(ScrollEventListener scrollEventListener) {
|