import React from 'react'; import { NativeSyntheticEvent, StyleSheet, Text, TextInputFocusEventData, TextInputProps, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import TextInput from '../presentation/TextInput'; import I18n from '../i18n'; import { CustomIcon } from '../lib/Icons'; import sharedStyles from '../views/Styles'; import { withTheme } from '../theme'; import { themes } from '../constants/colors'; import { isIOS } from '../utils/deviceInfo'; const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', flex: 1 }, searchBox: { alignItems: 'center', borderRadius: 10, flexDirection: 'row', fontSize: 17, height: 36, margin: 16, marginVertical: 10, paddingHorizontal: 10, flex: 1 }, input: { flex: 1, fontSize: 17, marginLeft: 8, paddingTop: 0, paddingBottom: 0, ...sharedStyles.textRegular }, cancel: { marginRight: 15 }, cancelText: { ...sharedStyles.textRegular, fontSize: 17 } }); interface ISearchBox { value?: string; onChangeText: TextInputProps['onChangeText']; onSubmitEditing?: () => void; hasCancel?: boolean; onCancelPress?: Function; theme?: string; inputRef?: React.Ref; testID?: string; onFocus?: (e: NativeSyntheticEvent) => void; } const CancelButton = (onCancelPress: Function, theme: string) => ( {I18n.t('Cancel')} ); const SearchBox = ({ onChangeText, onSubmitEditing, testID, hasCancel, onCancelPress, inputRef, theme, ...props }: ISearchBox) => ( {hasCancel ? CancelButton(onCancelPress!, theme!) : null} ); export default withTheme(SearchBox);