forked from mastermoo/react-native-action-button
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shared.js
47 lines (41 loc) · 963 Bytes
/
shared.js
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
import {
Platform,
TouchableOpacity,
TouchableNativeFeedback
} from "react-native";
export const DEFAULT_ACTIVE_OPACITY = 0.85;
export const shadowStyle = {
shadowOpacity: 0.35,
shadowOffset: {
width: 0,
height: 5
},
shadowColor: "#000",
shadowRadius: 3,
elevation: 5
};
export const alignItemsMap = {
center: "center",
left: "flex-start",
right: "flex-end"
};
export const isAndroid = Platform.OS === "android";
export function getTouchableComponent(useNativeFeedback) {
if (useNativeFeedback === true && isAndroid === true) {
return TouchableNativeFeedback;
}
return TouchableOpacity;
}
export function touchableBackground(color, fixRadius) {
if (isAndroid) {
if (Platform["Version"] >= 21) {
return TouchableNativeFeedback.Ripple(
color || "rgba(255,255,255,0.75)",
fixRadius
);
} else {
TouchableNativeFeedback.SelectableBackground();
}
}
return undefined;
}