2019-12-04 16:39:53 +00:00
|
|
|
import React from 'react';
|
2022-01-17 16:10:39 +00:00
|
|
|
import { I18nManager, StyleProp, StyleSheet, TextInput, TextStyle } from 'react-native';
|
2019-12-04 16:39:53 +00:00
|
|
|
|
2022-01-17 16:10:39 +00:00
|
|
|
import { IRCTextInputProps } from '../containers/TextInput';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
|
2020-11-30 21:47:05 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
input: {
|
2021-09-13 20:41:05 +00:00
|
|
|
...(I18nManager.isRTL ? { textAlign: 'right' } : { textAlign: 'auto' })
|
2020-11-30 21:47:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-01-17 16:10:39 +00:00
|
|
|
interface IThemedTextInput extends IRCTextInputProps {
|
2021-10-20 17:45:47 +00:00
|
|
|
style: StyleProp<TextStyle>;
|
2021-09-13 20:41:05 +00:00
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
2022-02-07 15:18:37 +00:00
|
|
|
const ThemedTextInput = React.forwardRef<TextInput, IThemedTextInput>(({ style, theme, ...props }, ref) => (
|
2019-12-04 16:39:53 +00:00
|
|
|
<TextInput
|
|
|
|
ref={ref}
|
2020-11-30 21:47:05 +00:00
|
|
|
style={[{ color: themes[theme].titleText }, style, styles.input]}
|
2019-12-04 16:39:53 +00:00
|
|
|
placeholderTextColor={themes[theme].auxiliaryText}
|
|
|
|
keyboardAppearance={theme === 'light' ? 'light' : 'dark'}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
export default ThemedTextInput;
|