Open History to see the last commit
1import { useGT } from "gt-react-native";
2import { useState } from "react";
3import { Keyboard, View } from "react-native";
4
5import { AppText as Text } from "../../components/ui/AppText";
6import { Button } from "../../components/ui/Button";
7import { SecretTextInput } from "../../components/ui/SecretTextInput";
8
9export function FilePasswordPrompt(props: {
10 readonly incorrect: boolean;
11 readonly onSubmit: (password: string) => void;
12}) {
13 const gt = useGT();
14 const [password, setPassword] = useState("");
15 const submit = (value: string) => {
16 if (value.length === 0) return;
17 setPassword("");
18 Keyboard.dismiss();
19 props.onSubmit(value);
20 };
21 return (
22 <View className="flex-1 items-center justify-center px-6">
23 <View className="w-full max-w-sm gap-3">
24 <Text accessibilityLiveRegion="polite" className="text-center text-foreground">
25 {props.incorrect
26 ? gt`Incorrect password. Try again.`
27 : gt`This file requires a password.`}
28 </Text>
29 <SecretTextInput
30 accessibilityLabel={gt`File password`}
31 placeholder={gt`File password`}
32 value={password}
33 editable
34 onChangeText={setPassword}
35 onSubmitEditing={submit}
36 />
37 <Button
38 label={gt`Unlock`}
39 disabled={password.length === 0}
40 onPress={() => submit(password)}
41 />
42 </View>
43 </View>
44 );
45}