import React, { useContext } from 'react'; import { TouchableOpacity, View } from 'react-native'; import { useComponentId } from '../Application'; import { ApplicationContext, ComponentContext, MiniAppContext, } from '../Context'; import { Icon } from '../Icon'; import { ErrorView, FloatingView, getBorderColor, getSizeStyle, } from './common'; import { InputDropDownProps } from './index'; import { Text, useScaleSize } from '../Text'; import styles from './styles'; import { Spacing } from '../Consts'; const InputDropDown = ({ value, floatingValue, floatingIcon, onPressFloatingIcon, size = 'small', placeholder, errorMessage, disabled = false, floatingIconColor, required = false, errorSpacing, leadingIcon, leadingIconColor, style, params, hintText, multiline, ...props }: InputDropDownProps) => { const { theme } = useContext(ApplicationContext); const context = useContext(MiniAppContext); const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1); const componentName = 'InputDropDown'; const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false; const { componentId } = useComponentId( `${componentName}/${placeholder}`, props.accessibilityLabel, ); /** * Render the input view */ const renderInputView = () => { const disabledColor = theme.colors.text.disable; let textColor = theme.colors.text.default; let placeholderColor = theme.colors.text.hint; if (disabled) { textColor = disabledColor; placeholderColor = disabledColor; } return ( {!!leadingIcon && ( )} {value || placeholder} ); }; return ( {renderInputView()} ); }; export default InputDropDown;