2023-01-10 14:08:13 +02:00
|
|
|
const React = require('react');
|
|
|
|
import { useMemo } from 'react';
|
2024-04-11 09:35:20 +02:00
|
|
|
import { themeStyle } from './global-style';
|
2023-01-10 14:08:13 +02:00
|
|
|
import { TextInput, TextInputProps, StyleSheet } from 'react-native';
|
|
|
|
|
|
|
|
interface Props extends TextInputProps {
|
|
|
|
themeId: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (props: Props) => {
|
|
|
|
const theme = themeStyle(props.themeId);
|
2024-04-11 09:35:20 +02:00
|
|
|
const finalProps: Props = { ...props };
|
2023-01-10 14:08:13 +02:00
|
|
|
|
|
|
|
if (!('placeholderTextColor' in finalProps)) finalProps.placeholderTextColor = theme.colorFaded;
|
|
|
|
if (!('underlineColorAndroid' in finalProps)) finalProps.underlineColorAndroid = theme.dividerColor;
|
|
|
|
if (!('selectionColor' in finalProps)) finalProps.selectionColor = theme.textSelectionColor;
|
|
|
|
if (!('keyboardAppearance' in finalProps)) finalProps.keyboardAppearance = theme.keyboardAppearance;
|
|
|
|
if (!('style' in finalProps)) finalProps.style = {};
|
|
|
|
|
|
|
|
const defaultStyle = useMemo(() => {
|
|
|
|
const theme = themeStyle(finalProps.themeId);
|
|
|
|
|
|
|
|
return StyleSheet.create({
|
|
|
|
textInput: {
|
|
|
|
color: theme.color,
|
|
|
|
paddingLeft: 14,
|
|
|
|
paddingRight: 14,
|
|
|
|
paddingTop: 12,
|
|
|
|
paddingBottom: 12,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}, [finalProps.themeId]);
|
|
|
|
|
|
|
|
finalProps.style = [defaultStyle.textInput, finalProps.style];
|
|
|
|
|
|
|
|
return <TextInput {...finalProps} />;
|
|
|
|
};
|