2019-12-04 16:39:53 +00:00
|
|
|
import React from 'react';
|
2020-11-30 21:47:05 +00:00
|
|
|
import { TextInput, StyleSheet, I18nManager } from 'react-native';
|
2019-12-04 16:39:53 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
|
2020-11-30 21:47:05 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
input: {
|
|
|
|
...I18nManager.isRTL
|
|
|
|
? { textAlign: 'right' }
|
2021-08-27 20:03:59 +00:00
|
|
|
: { textAlign: 'auto' }
|
2020-11-30 21:47:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
const ThemedTextInput = React.forwardRef(({ style, theme, ...props }, ref) => (
|
|
|
|
<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}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
ThemedTextInput.propTypes = {
|
|
|
|
style: PropTypes.object,
|
|
|
|
theme: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ThemedTextInput;
|