-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathindex.js
39 lines (33 loc) · 1.18 KB
/
index.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
import React from "react";
import { requireNativeComponent, View, Platform, StyleSheet, processColor } from "react-native";
const NativeContextMenu = requireNativeComponent("ContextMenu", null);
const ContextMenu = (props) => {
const defaultProps = {
borderRadius: -1,
borderTopLeftRadius: -1,
borderTopRightRadius: -1,
borderBottomRightRadius: -1,
borderBottomLeftRadius: -1
};
const colorConvertedActions = props?.actions?.map((action) => ({
...action,
iconColor: Platform.OS === 'ios' && action.iconColor ? processColor(action.iconColor) : action.iconColor,
titleColor: Platform.OS === 'ios' && action.titleColor ? processColor(action.titleColor) : action.titleColor,
}));
return (
<NativeContextMenu {...defaultProps} {...props} actions={colorConvertedActions}>
{props.children}
{props.preview != null && Platform.OS === 'ios' ? (
<View style={styles.preview} nativeID="ContextMenuPreview">{props.preview}</View>
) : null}
</NativeContextMenu>
);
};
const styles = StyleSheet.create({
preview: {
position: 'absolute',
overflow: 'visible',
backgroundColor: 'transparent'
}
});
export default ContextMenu;