1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/app-mobile/components/TextInput.tsx

38 lines
1.2 KiB
TypeScript
Raw Normal View History

const React = require('react');
import { useMemo } from 'react';
import { themeStyle } from '@joplin/lib/theme';
import { TextInput, TextInputProps, StyleSheet } from 'react-native';
interface Props extends TextInputProps {
themeId: number;
}
export default (props: Props) => {
const theme = themeStyle(props.themeId);
const finalProps = { ...props };
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} />;
};