import React, { useState } from 'react'; import { FlatList, StyleSheet, TextInputProps, View } from 'react-native'; import { FormTextInput } from '../../../containers/TextInput'; import * as List from '../../../containers/List'; import { themes } from '../../../lib/constants'; import I18n from '../../../i18n'; import { TServerHistoryModel } from '../../../definitions'; import Item from './Item'; import { TSupportedThemes } from '../../../theme'; const styles = StyleSheet.create({ container: { zIndex: 1 }, inputContainer: { marginTop: 0, marginBottom: 0 }, serverHistory: { maxHeight: 180, width: '100%', top: '100%', zIndex: 1, position: 'absolute', borderWidth: StyleSheet.hairlineWidth, borderRadius: 2, borderTopWidth: 0 } }); interface IServerInput extends TextInputProps { text: string; theme: TSupportedThemes; serversHistory: any[]; onSubmit(): void; onDelete(item: TServerHistoryModel): void; onPressServerHistory(serverHistory: TServerHistoryModel): void; } const ServerInput = ({ text, theme, serversHistory, onChangeText, onSubmit, onDelete, onPressServerHistory }: IServerInput): JSX.Element => { const [focused, setFocused] = useState(false); return ( setFocused(true)} onBlur={() => setFocused(false)} /> {focused && serversHistory?.length ? ( ( onPressServerHistory(item)} onDelete={onDelete} /> )} ItemSeparatorComponent={List.Separator} keyExtractor={item => item.id} /> ) : null} ); }; export default ServerInput;