UNPKG

@fruits-chain/react-native-xiaoshu

Version:
55 lines (52 loc) 1.86 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React, { useMemo, useRef, memo } from 'react'; import { View } from 'react-native'; import { useTheme, widthStyle } from '../theme'; import { getDefaultValue } from '../helpers'; import { DropdownConfig } from './context'; import { createStyles } from './style.menu'; /** * DropdownMenu 下拉菜单的横条 */ const DropdownMenu = _ref => { let { titleStyle, titleTextStyle, iconStyle, activeColor, direction = 'down', lazyRender = true, duration, zIndex = 10, // overlay = true, // closeOnPressOverlay = true, closeOnPressOutside = true, style, ...restProps } = _ref; const MenuRef = useRef(null); const THEME_VAR = useTheme(); const STYLES = widthStyle(THEME_VAR, createStyles); activeColor = getDefaultValue(activeColor, THEME_VAR.dropdown_menu_title_active_text_color); duration = getDefaultValue(duration, THEME_VAR.animation_duration_fast); const config = useMemo(() => ({ titleStyle, titleTextStyle, iconStyle, activeColor, direction, lazyRender, duration, zIndex, closeOnPressOutside, MenuRef }), [activeColor, closeOnPressOutside, direction, duration, iconStyle, lazyRender, titleStyle, titleTextStyle, zIndex]); return /*#__PURE__*/React.createElement(DropdownConfig.Provider, { value: config }, /*#__PURE__*/React.createElement(View, _extends({}, restProps, { ref: MenuRef, style: [STYLES.menu, style] }))); }; export default /*#__PURE__*/memo(DropdownMenu); //# sourceMappingURL=menu.js.map