You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mobile/components/form/SecretTextInput.tsx

30 lines
805 B

import React, { useState } from "react";
import FormInput, { FormInputProps } from "./FormInput";
export default React.forwardRef<any, FormInputProps>(
(props, ref): React.ReactElement => {
const { onBlur, onChangeText, value, label, ...rest } = props;
const [showPassword, setShowPassword] = useState(false);
const toggleShowPassword = () => {
setShowPassword(!showPassword);
};
return (
<FormInput
label={label}
beforeIcon="lock"
afterIcon={showPassword ? "eye" : "eyeo"}
placeholder="⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆"
onBlur={onBlur}
onChangeText={onChangeText}
value={value}
onPress={toggleShowPassword}
secureTextEntry={!showPassword}
{...ref}
{...rest}
/>
);
}
);