2022-06-27 18:46:59 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { I18nManager, StyleProp, StyleSheet, TextInput as RNTextInput, TextStyle } from 'react-native';
|
|
|
|
|
|
|
|
import { IRCTextInputProps } from './FormTextInput';
|
|
|
|
import { themes } from '../../lib/constants';
|
|
|
|
import { useTheme } from '../../theme';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
input: {
|
|
|
|
...(I18nManager.isRTL ? { textAlign: 'right' } : { textAlign: 'auto' })
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export interface IThemedTextInput extends IRCTextInputProps {
|
|
|
|
style: StyleProp<TextStyle>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const TextInput = React.forwardRef<RNTextInput, IThemedTextInput>(({ style, ...props }, ref) => {
|
|
|
|
const { theme } = useTheme();
|
|
|
|
return (
|
|
|
|
<RNTextInput
|
|
|
|
ref={ref}
|
2024-04-18 10:19:54 +00:00
|
|
|
style={[{ color: themes[theme].fontTitlesLabels }, style, styles.input]}
|
|
|
|
placeholderTextColor={themes[theme].fontSecondaryInfo}
|
2022-06-27 18:46:59 +00:00
|
|
|
keyboardAppearance={theme === 'light' ? 'light' : 'dark'}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|