Guy Carmeli преди 8 години
родител
ревизия
0b4f632c22

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/FabActionParams.java Целия файл

5
 public class FabActionParams {
5
 public class FabActionParams {
6
     public String id;
6
     public String id;
7
     public Drawable icon;
7
     public Drawable icon;
8
+    public StyleParams.Color backgroundColor;
8
 }
9
 }

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/FabActionParamsParser.java Целия файл

3
 import android.os.Bundle;
3
 import android.os.Bundle;
4
 
4
 
5
 import com.reactnativenavigation.params.FabActionParams;
5
 import com.reactnativenavigation.params.FabActionParams;
6
+import com.reactnativenavigation.params.StyleParams;
6
 import com.reactnativenavigation.react.ImageLoader;
7
 import com.reactnativenavigation.react.ImageLoader;
7
 
8
 
8
 public class FabActionParamsParser extends Parser {
9
 public class FabActionParamsParser extends Parser {
10
         FabActionParams fabActionParams = new FabActionParams();
11
         FabActionParams fabActionParams = new FabActionParams();
11
         fabActionParams.id = params.getString("id");
12
         fabActionParams.id = params.getString("id");
12
         fabActionParams.icon = ImageLoader.loadImage(params.getString("icon"));
13
         fabActionParams.icon = ImageLoader.loadImage(params.getString("icon"));
14
+        fabActionParams.backgroundColor = StyleParams.Color.parse(params.getString("backgroundColor"));
13
         return fabActionParams;
15
         return fabActionParams;
14
     }
16
     }
15
 }
17
 }

+ 11
- 5
android/app/src/main/java/com/reactnativenavigation/views/FloatingActionButtonCoordinator.java Целия файл

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