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-05-18 19:17:42 +00:00
|
|
|
import { IRCTextInputProps } from './FormTextInput';
|
|
|
|
import { themes } from '../../lib/constants';
|
|
|
|
import { TSupportedThemes } from '../../theme';
|
2019-12-04 16:39:53 +00:00
|
|
|
|
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-03-22 18:01:54 +00:00
|
|
|
export interface IThemedTextInput extends IRCTextInputProps {
|
2021-10-20 17:45:47 +00:00
|
|
|
style: StyleProp<TextStyle>;
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
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;
|