|
@@ -2,6 +2,7 @@ package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
3
|
import android.animation.Animator;
|
4
|
4
|
import android.animation.AnimatorListenerAdapter;
|
|
5
|
+import android.content.res.ColorStateList;
|
5
|
6
|
import android.graphics.drawable.Drawable;
|
6
|
7
|
import android.support.annotation.FloatRange;
|
7
|
8
|
import android.support.annotation.NonNull;
|
|
@@ -9,7 +10,6 @@ import android.support.design.widget.CoordinatorLayout;
|
9
|
10
|
import android.support.design.widget.FloatingActionButton;
|
10
|
11
|
import android.view.Gravity;
|
11
|
12
|
import android.view.View;
|
12
|
|
-import android.view.ViewGroup;
|
13
|
13
|
|
14
|
14
|
import com.reactnativenavigation.params.FabActionParams;
|
15
|
15
|
import com.reactnativenavigation.params.FabParams;
|
|
@@ -17,6 +17,8 @@ import com.reactnativenavigation.utils.ViewUtils;
|
17
|
17
|
|
18
|
18
|
import java.util.ArrayList;
|
19
|
19
|
|
|
20
|
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
21
|
+
|
20
|
22
|
public class FloatingActionButtonCoordinator {
|
21
|
23
|
|
22
|
24
|
private static final int INITIAL_EXPENDED_FAB_ROTATION = -90;
|
|
@@ -112,7 +114,7 @@ public class FloatingActionButtonCoordinator {
|
112
|
114
|
}
|
113
|
115
|
|
114
|
116
|
private CoordinatorLayout.LayoutParams createFabLayoutParams() {
|
115
|
|
- final CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
117
|
+ final CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
116
|
118
|
lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;
|
117
|
119
|
lp.bottomMargin = margin;
|
118
|
120
|
lp.rightMargin = margin;
|
|
@@ -121,7 +123,8 @@ public class FloatingActionButtonCoordinator {
|
121
|
123
|
}
|
122
|
124
|
|
123
|
125
|
private void setStyle() {
|
124
|
|
-
|
|
126
|
+ collapsedFab.setBackgroundTintList(ColorStateList.valueOf(params.backgroundColor.getColor()));
|
|
127
|
+ expendedFab.setBackgroundTintList(ColorStateList.valueOf(params.backgroundColor.getColor()));
|
125
|
128
|
}
|
126
|
129
|
|
127
|
130
|
public void show() {
|
|
@@ -144,13 +147,16 @@ public class FloatingActionButtonCoordinator {
|
144
|
147
|
FabActionParams actionParams = params.actions.get(index);
|
145
|
148
|
FloatingActionButton action = createFab(actionParams.icon);
|
146
|
149
|
action.setLayoutParams(createActionLayoutParams(index));
|
147
|
|
- // action.setAlpha(0);
|
|
150
|
+ if (actionParams.backgroundColor.hasColor()) {
|
|
151
|
+ action.setBackgroundTintList(ColorStateList.valueOf(actionParams.backgroundColor.getColor()));
|
|
152
|
+ }
|
|
153
|
+ action.setSize(FloatingActionButton.SIZE_MINI);
|
148
|
154
|
return action;
|
149
|
155
|
}
|
150
|
156
|
|
151
|
157
|
@NonNull
|
152
|
158
|
private CoordinatorLayout.LayoutParams createActionLayoutParams(int actionIndex) {
|
153
|
|
- CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(actionSize, actionSize);
|
|
159
|
+ CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
154
|
160
|
lp.setAnchorId(expendedFab.getId());
|
155
|
161
|
lp.anchorGravity = Gravity.CENTER_HORIZONTAL;
|
156
|
162
|
lp.setBehavior(new ActionBehaviour(expendedFab, (actionIndex + 1) * (actionSize + margin / 2)));
|