vn-verdnaturachat/app/presentation/TextInput.tsx

30 lines
883 B
TypeScript
Raw Normal View History

2019-12-04 16:39:53 +00:00
import React from 'react';
import { I18nManager, StyleProp, StyleSheet, TextInput, TextStyle } from 'react-native';
2019-12-04 16:39:53 +00:00
import { IRCTextInputProps } from '../containers/TextInput';
import { themes } from '../lib/constants';
import { TSupportedThemes } from '../theme';
2019-12-04 16:39:53 +00:00
const styles = StyleSheet.create({
input: {
...(I18nManager.isRTL ? { textAlign: 'right' } : { textAlign: 'auto' })
}
});
export interface IThemedTextInput extends IRCTextInputProps {
style: StyleProp<TextStyle>;
theme: TSupportedThemes;
}
const ThemedTextInput = React.forwardRef<TextInput, IThemedTextInput>(({ style, theme, ...props }, ref) => (
2019-12-04 16:39:53 +00:00
<TextInput
ref={ref}
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;