Deskripsi: - vertical center icon list dan grid pada list project dan divisi - mb list lembaga desa dan search page No Issues
92 lines
3.5 KiB
TypeScript
92 lines
3.5 KiB
TypeScript
import Styles from "@/constants/Styles";
|
|
import { Dimensions, Platform, TextInput, View } from "react-native";
|
|
import Text from "./Text";
|
|
|
|
type Props = {
|
|
label?: string;
|
|
placeholder?: string;
|
|
onChange?: (val: string) => void;
|
|
info?: string;
|
|
itemLeft?: React.ReactNode;
|
|
itemRight?: React.ReactNode;
|
|
error?: boolean;
|
|
errorText?: string;
|
|
required?: boolean;
|
|
type: 'default' | 'visible-password' | 'numeric'
|
|
round?: boolean
|
|
width?: number
|
|
bg?: 'white' | 'transparent'
|
|
value?: string
|
|
disable?: boolean
|
|
multiline?: boolean
|
|
mb?: boolean
|
|
};
|
|
|
|
|
|
export function InputForm({ label, value, placeholder, onChange, info, disable, error, errorText, required, itemLeft, itemRight, type, round, width, bg, multiline, mb = true }: Props) {
|
|
const lebar = Dimensions.get("window").width;
|
|
|
|
if (itemLeft != undefined || itemRight != undefined) {
|
|
return (
|
|
<View style={[mb && Styles.mb10]}>
|
|
{
|
|
label != undefined && (
|
|
<Text style={[{ marginBottom: 5, textTransform: "capitalize" }, error && Styles.cError]}>
|
|
{label}
|
|
{required && (<Text style={Styles.cError}>*</Text>)}
|
|
</Text>
|
|
)
|
|
}
|
|
<View style={[
|
|
Styles.inputRoundForm,
|
|
itemRight != undefined ? Styles.inputRoundFormRight : Styles.inputRoundFormLeft,
|
|
round && Styles.round30,
|
|
{ backgroundColor: bg && bg == 'white' ? 'white' : 'transparent' },
|
|
error && { borderColor: "red" },
|
|
Platform.OS == 'ios' && { paddingVertical: 10 },
|
|
]}>
|
|
{itemRight != undefined ? itemRight : itemLeft}
|
|
<TextInput
|
|
editable={!disable}
|
|
value={value}
|
|
placeholder={placeholder}
|
|
keyboardType={type}
|
|
onChangeText={onChange}
|
|
placeholderTextColor={'gray'}
|
|
style={[Styles.mh05, { width: width ? lebar * width / 100 : lebar * 0.78, color: 'black' }]}
|
|
/>
|
|
</View>
|
|
{error && (<Text style={[Styles.textInformation, Styles.cError, Styles.mt05]}>{errorText}</Text>)}
|
|
{info != undefined && (<Text style={[Styles.textInformation, Styles.cGray, Styles.mt05]}>{info}</Text>)}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
<View style={[Styles.mb10]}>
|
|
{
|
|
label != undefined && (
|
|
<Text style={[Styles.mb05, error && Styles.cError]}>
|
|
{label}
|
|
{required && (<Text style={Styles.cError}>*</Text>)}
|
|
</Text>
|
|
)
|
|
}
|
|
<TextInput
|
|
value={value}
|
|
placeholder={placeholder}
|
|
keyboardType={type}
|
|
editable={!disable}
|
|
style={[Styles.inputRoundForm, error && { borderColor: "red" }, round && Styles.round30, { backgroundColor: bg && bg == 'white' ? 'white' : 'transparent' }, { color: 'black' }, multiline && { height: 150, textAlignVertical: 'top' }]}
|
|
onChangeText={onChange}
|
|
placeholderTextColor={'gray'}
|
|
multiline={multiline}
|
|
numberOfLines={multiline ? 5 : undefined}
|
|
/>
|
|
{error && (<Text style={[Styles.textInformation, Styles.cError, Styles.mt05]}>{errorText}</Text>)}
|
|
{info != undefined && (<Text style={[Styles.textInformation, Styles.mt05, Styles.cGray]}>{info}</Text>)}
|
|
</View>
|
|
)
|
|
} |