|
@@ -1,26 +1,32 @@
|
1
|
1
|
package com.reactnativenavigation.params.parsers;
|
2
|
2
|
|
|
3
|
+import android.graphics.drawable.Drawable;
|
3
|
4
|
import android.os.Bundle;
|
4
|
5
|
|
5
|
6
|
import com.reactnativenavigation.params.FabActionParams;
|
6
|
7
|
import com.reactnativenavigation.params.FabParams;
|
7
|
8
|
import com.reactnativenavigation.params.StyleParams;
|
8
|
9
|
import com.reactnativenavigation.react.ImageLoader;
|
|
10
|
+import com.reactnativenavigation.utils.ViewUtils;
|
9
|
11
|
|
10
|
12
|
public class FabParamsParser extends Parser {
|
11
|
13
|
public FabParams parse(Bundle params, final String navigatorEventId, String screenInstanceId) {
|
12
|
14
|
FabParams fabParams = new FabParams();
|
13
|
15
|
fabParams.collapsedId = params.getString("collapsedId");
|
14
|
16
|
fabParams.expendedId = params.getString("expendedId");
|
|
17
|
+ fabParams.collapsedIconColor = getColor(params, "collapsedIconColor", new StyleParams.Color());
|
|
18
|
+ fabParams.expendedIconColor = getColor(params, "expendedIconColor", new StyleParams.Color());
|
15
|
19
|
fabParams.navigatorEventId = navigatorEventId;
|
16
|
20
|
fabParams.screenInstanceId = screenInstanceId;
|
17
|
21
|
fabParams.backgroundColor = getColor(params, "backgroundColor", new StyleParams.Color());
|
18
|
22
|
|
19
|
23
|
if (hasKey(params, "collapsedIcon")) {
|
20
|
24
|
fabParams.collapsedIcon = ImageLoader.loadImage(params.getString("collapsedIcon"));
|
|
25
|
+ tintIcon(fabParams.collapsedIcon, fabParams.collapsedIconColor);
|
21
|
26
|
}
|
22
|
27
|
if (hasKey(params, "expendedIcon")) {
|
23
|
28
|
fabParams.expendedIcon = ImageLoader.loadImage(params.getString("expendedIcon"));
|
|
29
|
+ tintIcon(fabParams.expendedIcon, fabParams.expendedIconColor);
|
24
|
30
|
}
|
25
|
31
|
if (hasKey(params, "actions")) {
|
26
|
32
|
fabParams.actions = parseBundle(params.getBundle("actions"), new ParseStrategy<FabActionParams>() {
|
|
@@ -32,4 +38,10 @@ public class FabParamsParser extends Parser {
|
32
|
38
|
}
|
33
|
39
|
return fabParams;
|
34
|
40
|
}
|
|
41
|
+
|
|
42
|
+ private void tintIcon(Drawable icon, StyleParams.Color color) {
|
|
43
|
+ if (color.hasColor()) {
|
|
44
|
+ ViewUtils.tintDrawable(icon, color.getColor(), true);
|
|
45
|
+ }
|
|
46
|
+ }
|
35
|
47
|
}
|