import get from 'lodash.get' ; import omit from 'lodash.omit' ; import { useWindowDimensions , Platform } from 'react-native' ; import { useNativeBase } from './../useNativeBase' ; import { omitUndefined , extractInObject } from './../../theme/tools/' ; import { filterShadowProps } from './../../utils/filterShadowProps' ; import { calculateProps } from './utils' ; const filterAndCalculateProps = ( theme , colorModeProps , componentTheme , propsReceived , windowWidth ) => { let [ ignoredProps , props ] = extractInObject ( propsReceived , [ 'children' , 'style' , 'onPress' , 'icon' , 'onOpen' , 'onClose' , ] ) ; let newProps = calculateProps ( theme , colorModeProps , componentTheme , props , windowWidth ) ; let mergedProps = filterShadowProps ( newProps , ignoredProps , Platform . OS ) ; return omitUndefined ( mergedProps ) ; } ; export function useThemeProps ( component , propsReceived ) { const { theme , ... colorModeProps } = useNativeBase ( ) ; const componentTheme = get ( theme , `components.${ component }` ) ; const windowWidth = useWindowDimensions ( ) ?. width ; return filterAndCalculateProps ( omit ( theme , [ 'components' ] ) , colorModeProps , componentTheme , propsReceived , windowWidth ) ; }