Skip to content

Commit a33b75a

Browse files
committed
add password
1 parent c041b56 commit a33b75a

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed
98.1 KB
Loading

challenges/foundation/password.gif

305 KB
Loading

hackathon/spacecraft/src/components/FromInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const FormInput = ({
1212
<View style={{ paddingVertical: 8 }}>
1313
<TextInput
1414
{...rest}
15+
mode="outlined"
1516
label={label}
1617
value={value}
1718
onChangeText={onChangeText}

hackathon/spacecraft/src/screens/LoginScreen.tsx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import React, { useState } from "react";
2-
import { StyleSheet, TouchableOpacity, Text, View } from "react-native";
3-
import { Button, TextInput, useTheme } from "react-native-paper";
2+
import { StyleSheet, TouchableOpacity, View, Pressable } from "react-native";
3+
import {
4+
Button,
5+
Checkbox,
6+
Text,
7+
List,
8+
MD3Colors,
9+
TextInput,
10+
useTheme,
11+
} from "react-native-paper";
412
import { useNavigation } from "@react-navigation/native";
513

614
import { FormInput } from "../components/FromInput";
@@ -12,7 +20,7 @@ import { Header } from "~/components/Header";
1220
export const LoginScreen = () => {
1321
const [email, setEmail] = useState("");
1422
const [password, setPassword] = useState("");
15-
const [isVisible, setIsVisible] = useState(true);
23+
const [checked, setChecked] = React.useState(false);
1624

1725
const navigation = useNavigation<any>();
1826
const { setUser } = useAuthentication();
@@ -25,7 +33,7 @@ export const LoginScreen = () => {
2533
}
2634

2735
function toggleSecureIcon() {
28-
setIsVisible(!isVisible);
36+
setChecked(!checked);
2937
}
3038

3139
const theme = useTheme();
@@ -41,19 +49,27 @@ export const LoginScreen = () => {
4149
returnKeyType="next"
4250
keyboardType="email-address"
4351
autoComplete="email"
52+
textContentType="emailAddress"
53+
autoCapitalize="none"
4454
/>
4555
<FormInput
4656
label="Password"
4757
value={password}
48-
secureTextEntry={isVisible}
58+
secureTextEntry={!checked}
4959
onChangeText={(value) => setPassword(value)}
5060
autoComplete="password"
51-
right={
52-
<TextInput.Icon
53-
onPress={toggleSecureIcon}
54-
icon={isVisible ? "eye-off" : "eye"}
55-
/>
56-
}
61+
/>
62+
<Checkbox.Item
63+
label="Show Password"
64+
onPress={toggleSecureIcon}
65+
status={checked ? "checked" : "unchecked"}
66+
labelStyle={{ textAlign: "left" }}
67+
style={{
68+
paddingVertical: 0,
69+
paddingHorizontal: 0,
70+
}}
71+
position="leading"
72+
mode="android"
5773
/>
5874
<Button
5975
onPress={handleLogin}

0 commit comments

Comments
 (0)