import { ViewPropTypes } from 'deprecated-react-native-prop-types' import PropTypes from 'prop-types' import React from 'react' import { Platform, StyleSheet, Text, TouchableHighlight, View } from 'react-native' import { initialWindowMetrics } from 'react-native-safe-area-context' import { Popup } from '../Popup' import V from '../variable' const styles = StyleSheet.create({ actionsheet: { backgroundColor: V.weuiBgColorDefault }, androidActionsheetWrapper: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }, actionsheetMenu: { backgroundColor: '#fff' }, actionsheetAction: { marginTop: 6, backgroundColor: '#fff' }, actionsheetCell: { borderTopWidth: StyleSheet.hairlineWidth, borderColor: V.weuiCellBorderColor, borderStyle: 'solid', paddingTop: 10, paddingBottom: 10, paddingLeft: 24, paddingRight: 24 }, firstActionsheetCell: { borderTopWidth: 0 }, actionSheetCellText: { textAlign: 'center', fontSize: 18, marginTop: ((18 * V.baseLineHeight) - 18) / 2, marginBottom: ((18 * V.baseLineHeight) - 18) / 2 }, androidActionsheetCellText: { fontSize: 16, marginTop: ((16 * 1.4) - 16) / 2, marginBottom: ((16 * 1.4) - 16) / 2 }, defaultActionsheetCellText: { color: '#000' }, primaryActionsheetCellText: { color: '#0BB20C' }, warnActionsheetCellText: { color: V.weuiColorWarn }, Modal: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, backgroundColor: 'transparent' } }) const underlayColor = V.weuiBgColorActive const Index: React.FC = ({ visible, style, maskStyle, onShow, onClose, menus = [], actions = [], autoDectect = true, type = 'ios' }) => { let _type = type if (autoDectect) _type = Platform.OS const _renderMenuItems = () => menus.map(({ type: btnType, label, style: btnStyle, textStyle, ...others }: any, idx) => {label} ) const _renderActions = () => actions.map(({ type: btnType, label, style: btnStyle, textStyle, ...others }: any, idx) => {label} ) return {menus.length ? {_renderMenuItems()} : false} {actions.length ? {_renderActions()} : false} } Index.propTypes = { autoDectect: PropTypes.bool, type: PropTypes.oneOf(['ios', 'android', 'harmony']), menus: PropTypes.any, actions: PropTypes.any, visible: PropTypes.bool, onShow: PropTypes.func, onClose: PropTypes.func, style: ViewPropTypes.style, maskStyle: ViewPropTypes.style } export default Index