import React from 'react'; import { View, StyleProp, StyleSheet, TextInput as NativeTextInput, ViewStyle, } from 'react-native'; import type { Theme } from '../../types'; import { withTheme } from '../../core/theming'; import { blockSizes, builtTextStyles } from '../../styles/styles'; import { Border } from '../../styles/styleElements'; type Props = React.ComponentPropsWithRef & { defaultValue?: string; disabled?: boolean; style?: StyleProp; inputStyle?: StyleProp; theme: Theme; value?: string; variant?: 'default' | 'flat'; }; // TODO: implement scrollbars in TextInput const TextInput = ({ defaultValue, disabled, style = {}, inputStyle = {}, theme, value, variant = 'default', ...rest }: Props) => { const hasValue = !!(value || defaultValue); const isFlat = variant === 'flat'; const getBackgroundColor = () => { if (isFlat) { return disabled ? theme.flatLight : 'transparent'; } return disabled ? theme.material : theme.canvas; }; const textStyles = builtTextStyles(theme); return ( ); }; const styles = StyleSheet.create({ wrapper: { minHeight: blockSizes.md, justifyContent: 'center', }, input: { flex: 1, paddingHorizontal: 4, }, }); export default withTheme(TextInput);