2020-02-11 14:01:35 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2020-02-11 14:01:35 +00:00
|
|
|
import Touchable from 'react-native-platform-touchable';
|
|
|
|
|
2022-05-02 19:21:15 +00:00
|
|
|
import { CustomIcon } from '../../CustomIcon';
|
2020-02-11 14:01:35 +00:00
|
|
|
import ActivityIndicator from '../../ActivityIndicator';
|
|
|
|
import styles from './styles';
|
2022-07-13 19:31:58 +00:00
|
|
|
import { useTheme } from '../../../theme';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
interface IInput {
|
2021-11-17 20:09:20 +00:00
|
|
|
children?: JSX.Element;
|
2022-03-29 20:06:50 +00:00
|
|
|
onPress: () => void;
|
2021-11-17 20:09:20 +00:00
|
|
|
inputStyle?: object;
|
2022-03-29 20:06:50 +00:00
|
|
|
disabled?: boolean | null;
|
2021-09-22 17:29:26 +00:00
|
|
|
placeholder?: string;
|
|
|
|
loading?: boolean;
|
|
|
|
innerInputStyle?: object;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2022-07-13 19:31:58 +00:00
|
|
|
const Input = ({ children, onPress, loading, inputStyle, placeholder, disabled, innerInputStyle }: IInput) => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
|
|
|
<Touchable
|
|
|
|
onPress={onPress}
|
|
|
|
style={[{ backgroundColor: colors.backgroundColor }, inputStyle]}
|
|
|
|
background={Touchable.Ripple(colors.bannerBackground)}
|
|
|
|
disabled={disabled}>
|
|
|
|
<View style={[styles.input, { borderColor: colors.separatorColor }, innerInputStyle]}>
|
|
|
|
{placeholder ? <Text style={[styles.pickerText, { color: colors.auxiliaryText }]}>{placeholder}</Text> : children}
|
|
|
|
{loading ? (
|
|
|
|
<ActivityIndicator style={styles.icon} />
|
|
|
|
) : (
|
|
|
|
<CustomIcon name='chevron-down' size={22} color={colors.auxiliaryText} style={styles.icon} />
|
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
</Touchable>
|
|
|
|
);
|
|
|
|
};
|
2020-02-11 14:01:35 +00:00
|
|
|
export default Input;
|