Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SecretTextInput.tsx

35 lines1.2 KB

1import { useState } from "react";
2import { View } from "react-native";
3​
4import { AppTextInput } from "./AppText";
5import { SecretRevealButton } from "./SecretRevealButton";
6import type { SecretTextInputProps } from "./SecretTextInput.types";
7​
8/** Masked field for a value that must stay out of password managers and suggestions. */
9export function SecretTextInput(props: SecretTextInputProps) {
10 const [revealed, setRevealed] = useState(false);
11 return (
12 <View className="justify-center">
13 <AppTextInput
14 className="pr-12"
15 accessibilityLabel={props.accessibilityLabel}
16 placeholder={props.placeholder}
17 value={props.value}
18 onChangeText={props.onChangeText}
19 editable={props.editable}
20 secureTextEntry={!revealed}
21 autoCorrect={false}
22 autoCapitalize="none"
23 autoComplete="off"
24 textContentType="none"
25 importantForAutofill="no"
26 spellCheck={false}
27 returnKeyType="done"
28 onSubmitEditing={(event) => props.onSubmitEditing(event.nativeEvent.text)}
29 />
30 <View className="absolute right-1.5">
31 <SecretRevealButton revealed={revealed} onPress={() => setRevealed(!revealed)} />
32 </View>
33 </View>
34 );