|
@@ -12,6 +12,7 @@ import android.support.design.widget.FloatingActionButton;
|
12
|
12
|
import android.view.Gravity;
|
13
|
13
|
import android.view.View;
|
14
|
14
|
|
|
15
|
+import com.reactnativenavigation.NavigationApplication;
|
15
|
16
|
import com.reactnativenavigation.params.FabActionParams;
|
16
|
17
|
import com.reactnativenavigation.params.FabParams;
|
17
|
18
|
import com.reactnativenavigation.utils.ViewUtils;
|
|
@@ -87,9 +88,13 @@ public class FloatingActionButtonCoordinator {
|
87
|
88
|
collapsedFab.setOnClickListener(new View.OnClickListener() {
|
88
|
89
|
@Override
|
89
|
90
|
public void onClick(View v) {
|
90
|
|
- fabAnimator.hideCollapsed();
|
91
|
|
- fabAnimator.showExpended();
|
92
|
|
- showActions();
|
|
91
|
+ if (params.hasExpendedState()) {
|
|
92
|
+ fabAnimator.hideCollapsed();
|
|
93
|
+ fabAnimator.showExpended();
|
|
94
|
+ showActions();
|
|
95
|
+ } else {
|
|
96
|
+ NavigationApplication.instance.sendNavigatorEvent(params.id, params.navigatorEventId);
|
|
97
|
+ }
|
93
|
98
|
}
|
94
|
99
|
});
|
95
|
100
|
}
|
|
@@ -102,8 +107,7 @@ public class FloatingActionButtonCoordinator {
|
102
|
107
|
expendedFab.setOnClickListener(new View.OnClickListener() {
|
103
|
108
|
@Override
|
104
|
109
|
public void onClick(View v) {
|
105
|
|
- fabAnimator.hideExpended();
|
106
|
|
- fabAnimator.showCollapsed();
|
|
110
|
+ fabAnimator.collapse();
|
107
|
111
|
}
|
108
|
112
|
});
|
109
|
113
|
}
|
|
@@ -142,9 +146,16 @@ public class FloatingActionButtonCoordinator {
|
142
|
146
|
}
|
143
|
147
|
|
144
|
148
|
private FloatingActionButton createAction(int index) {
|
145
|
|
- FabActionParams actionParams = params.actions.get(index);
|
|
149
|
+ final FabActionParams actionParams = params.actions.get(index);
|
146
|
150
|
FloatingActionButton action = createFab(actionParams.icon);
|
147
|
151
|
action.setLayoutParams(createActionLayoutParams(index));
|
|
152
|
+ action.setOnClickListener(new View.OnClickListener() {
|
|
153
|
+ @Override
|
|
154
|
+ public void onClick(View v) {
|
|
155
|
+ NavigationApplication.instance.sendNavigatorEvent(actionParams.id, actionParams.navigatorEventId);
|
|
156
|
+ fabAnimator.collapse();
|
|
157
|
+ }
|
|
158
|
+ });
|
148
|
159
|
if (actionParams.backgroundColor.hasColor()) {
|
149
|
160
|
action.setBackgroundTintList(ColorStateList.valueOf(actionParams.backgroundColor.getColor()));
|
150
|
161
|
}
|
|
@@ -182,9 +193,14 @@ public class FloatingActionButtonCoordinator {
|
182
|
193
|
float fraction = calculateTransitionFraction(dependentValue);
|
183
|
194
|
child.setY(calculateY(parent, fraction));
|
184
|
195
|
child.setAlpha(calculateAlpha(fraction));
|
|
196
|
+ setVisibility(child);
|
185
|
197
|
return true;
|
186
|
198
|
}
|
187
|
199
|
|
|
200
|
+ private void setVisibility(FloatingActionButton child) {
|
|
201
|
+ child.setVisibility(child.getAlpha() == 0 ? View.GONE : View.VISIBLE);
|
|
202
|
+ }
|
|
203
|
+
|
188
|
204
|
private float calculateAlpha(float fraction) {
|
189
|
205
|
return 1 * fraction;
|
190
|
206
|
}
|