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';
|
2023-03-20 18:14:25 +00:00
|
|
|
import Touchable, { PlatformTouchableProps } from 'react-native-platform-touchable';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
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;
|
2023-03-20 18:14:25 +00:00
|
|
|
onPress: PlatformTouchableProps['onPress'];
|
2021-11-17 20:09:20 +00:00
|
|
|
inputStyle?: object;
|
2023-03-20 18:14:25 +00:00
|
|
|
disabled?: PlatformTouchableProps['disabled'];
|
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}
|
2022-11-10 16:35:59 +00:00
|
|
|
style={[{ backgroundColor: colors.backgroundColor }, styles.inputBorder, inputStyle]}
|
2022-07-13 19:31:58 +00:00
|
|
|
background={Touchable.Ripple(colors.bannerBackground)}
|
2022-08-08 21:02:08 +00:00
|
|
|
disabled={disabled}
|
|
|
|
>
|
2022-11-10 16:35:59 +00:00
|
|
|
<View style={[styles.input, styles.inputBorder, { borderColor: colors.separatorColor }, innerInputStyle]}>
|
2022-07-13 19:31:58 +00:00
|
|
|
{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;
|