xref: /MusicFree/src/components/base/input.tsx (revision 8e47be56b0121ae1a9c00382d70902276ffca225)
1import useColors from '@/hooks/useColors';
2import rpx from '@/utils/rpx';
3import Color from 'color';
4import React from 'react';
5import {StyleSheet, TextInput, TextInputProps} from 'react-native';
6
7interface IInputProps extends TextInputProps {
8    fontColor?: string;
9    hasHorizonalPadding?: boolean;
10}
11
12export default function Input(props: IInputProps) {
13    const {fontColor, hasHorizonalPadding = true} = props;
14    const colors = useColors();
15
16    const currentColor = fontColor ?? colors.text;
17
18    const defaultStyle = {
19        color: currentColor,
20    };
21
22    return (
23        <TextInput
24            placeholderTextColor={Color(currentColor).alpha(0.7).toString()}
25            {...props}
26            style={[
27                hasHorizonalPadding
28                    ? styles.container
29                    : styles.containerWithoutPadding,
30                defaultStyle,
31                props?.style,
32            ]}
33        />
34    );
35}
36
37const styles = StyleSheet.create({
38    container: {
39        paddingVertical: 0,
40        paddingHorizontal: rpx(24),
41    },
42    containerWithoutPadding: {
43        padding: 0,
44    },
45});
46