-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathFastShadowViewManager.java
More file actions
70 lines (57 loc) · 1.99 KB
/
FastShadowViewManager.java
File metadata and controls
70 lines (57 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.reactnativefastshadow;
import android.graphics.Color;
import androidx.annotation.NonNull;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager;
public class FastShadowViewManager extends ReactViewManager {
public static final String NAME = "FastShadowView";
@Override
@NonNull
public String getName() {
return FastShadowViewManager.NAME;
}
@Override
public FastShadowView createViewInstance(ThemedReactContext context) {
return new FastShadowView(context);
}
@Override
public void onDropViewInstance(@NonNull ReactViewGroup view) {
super.onDropViewInstance(view);
((FastShadowView) view).releaseShadow();
}
@ReactProp(name = "shadowColor", customType = "Color", defaultInt = Color.BLACK)
public void setShadowColor(FastShadowView view, int color) {
view.setColor(color);
}
@ReactProp(name = "shadowOpacity", defaultFloat = 0)
public void setShadowOpacity(FastShadowView view, float opacity) {
view.setOpacity(opacity);
}
@ReactProp(name = "shadowRadius", defaultFloat = 3)
public void setShadowRadius(FastShadowView view, float radius) {
view.setRadius(radius);
}
@ReactProp(name = "shadowOffset")
public void setShadowOffset(FastShadowView view, ReadableMap offset) {
if (offset == null) {
view.resetOffset();
} else {
view.setOffset(
(float) offset.getDouble("width"),
(float) offset.getDouble("height")
);
}
}
@ReactProp(name = "cornerRadii")
public void setCornerRadii(FastShadowView view, ReadableMap borderRadius) {
view.setCornerRadii(new float[]{
(float) borderRadius.getDouble("topLeft"),
(float) borderRadius.getDouble("topRight"),
(float) borderRadius.getDouble("bottomRight"),
(float) borderRadius.getDouble("bottomLeft")
});
}
}