input.tsx (e650bfb34226e2a09d15cbf7832c4805a87cd60e) input.tsx (ab5f994a52bee1ac7c89f2ccf9b6ca60d362890a)
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;
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;
9 hasHorizontalPadding?: boolean;
10}
11
12export default function Input(props: IInputProps) {
10}
11
12export default function Input(props: IInputProps) {
13 const {fontColor, hasHorizonalPadding = true} = props;
13 const {fontColor, hasHorizontalPadding = 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={[
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
27 hasHorizontalPadding
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});
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});