@towsila/expo-ui-library 4.11.4 → 4.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/reusable/templateSubPage.tsx +46 -31
- package/src/components/screens/AddReportScreen.tsx +55 -61
- package/src/components/screens/LegalScreen.tsx +27 -30
- package/src/components/screens/VerificationCodeScreen.tsx +4 -2
- package/src/components/screens/confirmDeleteScreen.tsx +81 -27
- package/src/components/screens/forgotPasswordScreen.tsx +15 -12
- package/src/components/screens/loginScreen.tsx +183 -79
- package/src/components/screens/onBoarding.tsx +98 -69
- package/src/components/screens/profileScreen.tsx +84 -32
- package/src/components/screens/resetPassword.tsx +3 -0
- package/src/components/screens/signUpScreen.tsx +98 -93
- package/src/components/screens/sucessScreen.tsx +75 -28
- package/src/components/ui/AnimatedSuccessIcon.tsx +15 -8
- package/src/components/ui/OTPInput.tsx +59 -17
- package/src/components/ui/PageTopBar.tsx +45 -33
- package/src/components/ui/customPopup.tsx +78 -86
- package/src/components/ui/dynamicForm.tsx +49 -18
- package/src/components/ui/input.tsx +102 -65
- package/src/components/ui/navigationCard.tsx +60 -47
- package/src/components/ui/pageIndicator.tsx +42 -18
- package/src/components/ui/requestCard.tsx +161 -105
- package/src/components/ui/select.tsx +49 -33
- package/src/components/ui/sharpButton.tsx +37 -20
- package/src/components/ui/termsPopup.tsx +74 -45
- package/src/components/ui/textArea.tsx +37 -40
- package/src/components/ui/toast.tsx +49 -52
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { View, ScrollView } from "react-native";
|
|
1
|
+
import { View, ScrollView, KeyboardAvoidingView, Platform } from "react-native";
|
|
2
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
2
3
|
import PageTopBar from "../ui/PageTopBar";
|
|
3
4
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
5
|
import ErrorMessage from "../ui/error";
|
|
@@ -13,7 +14,7 @@ interface Props {
|
|
|
13
14
|
handleFunction?: () => void;
|
|
14
15
|
error?: string;
|
|
15
16
|
onBack: () => void;
|
|
16
|
-
loading?:boolean;
|
|
17
|
+
loading?: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export default function TemplateSubPage({
|
|
@@ -29,38 +30,52 @@ export default function TemplateSubPage({
|
|
|
29
30
|
const { colors } = useAppTheme();
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
paddingTop: 80,
|
|
35
|
-
paddingHorizontal: 20,
|
|
36
|
-
paddingBottom: 43,
|
|
37
|
-
}}>
|
|
38
|
-
<PageTopBar title={title} description={text} onBack={onBack} />
|
|
39
|
-
<ScrollView
|
|
33
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background.main }}>
|
|
34
|
+
<KeyboardAvoidingView
|
|
40
35
|
style={{ flex: 1 }}
|
|
41
|
-
|
|
42
|
-
contentContainerStyle={{ flexGrow: 1 }}
|
|
43
|
-
keyboardShouldPersistTaps="handled"
|
|
36
|
+
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
44
37
|
>
|
|
45
|
-
<View
|
|
46
|
-
{
|
|
47
|
-
|
|
38
|
+
<View
|
|
39
|
+
style={{
|
|
40
|
+
flex: 1,
|
|
41
|
+
paddingHorizontal: 20,
|
|
42
|
+
paddingTop: 16,
|
|
43
|
+
paddingBottom: 16,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<PageTopBar title={title} description={text} onBack={onBack} />
|
|
47
|
+
|
|
48
|
+
<ScrollView
|
|
49
|
+
style={{ flex: 1 }}
|
|
50
|
+
showsVerticalScrollIndicator={false}
|
|
51
|
+
contentContainerStyle={{ flexGrow: 1, paddingBottom: 16 }}
|
|
52
|
+
keyboardShouldPersistTaps="handled"
|
|
53
|
+
>
|
|
54
|
+
<View style={{ gap: 20, marginTop: 0 }}>
|
|
55
|
+
{error && (
|
|
56
|
+
<ErrorMessage
|
|
57
|
+
message={error}
|
|
58
|
+
position="center"
|
|
59
|
+
fontSize={textSize.md}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
{children}
|
|
63
|
+
</View>
|
|
64
|
+
</ScrollView>
|
|
65
|
+
|
|
66
|
+
{buttonText && (
|
|
67
|
+
<View style={{ marginTop: 16 }}>
|
|
68
|
+
<SharpButton
|
|
69
|
+
text={buttonText}
|
|
70
|
+
bgColor={colors.primary}
|
|
71
|
+
onPress={handleFunction}
|
|
72
|
+
height={50}
|
|
73
|
+
loading={loading}
|
|
74
|
+
/>
|
|
75
|
+
</View>
|
|
48
76
|
)}
|
|
49
|
-
{children}
|
|
50
77
|
</View>
|
|
51
|
-
</
|
|
52
|
-
|
|
53
|
-
<View style={{ marginTop: 32 }}>
|
|
54
|
-
<SharpButton
|
|
55
|
-
text={buttonText}
|
|
56
|
-
bgColor={colors.primary}
|
|
57
|
-
onPress={handleFunction}
|
|
58
|
-
height={50}
|
|
59
|
-
loading={loading}
|
|
60
|
-
/>
|
|
61
|
-
</View>
|
|
62
|
-
)}
|
|
63
|
-
|
|
64
|
-
</View>
|
|
78
|
+
</KeyboardAvoidingView>
|
|
79
|
+
</SafeAreaView>
|
|
65
80
|
);
|
|
66
81
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { View } from "react-native";
|
|
3
3
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
4
4
|
import { useSubmitReport } from "../../hooks/useSubmitReport";
|
|
5
|
-
import SharpInput from "../ui/sharpInput";
|
|
6
|
-
import { useAppTheme } from "../../context/ThemeContext";
|
|
7
5
|
import SharpButton from "../ui/sharpButton";
|
|
6
|
+
import { useAppTheme } from "../../context/ThemeContext";
|
|
8
7
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
9
|
-
import ErrorMessage from "../ui/error";
|
|
10
8
|
import TextArea from "../ui/textArea";
|
|
11
9
|
import Select from "../ui/select";
|
|
12
10
|
|
|
@@ -20,11 +18,11 @@ interface ReportProps {
|
|
|
20
18
|
onSubmit: (target: string, reason: string) => Promise<void>;
|
|
21
19
|
error?: string;
|
|
22
20
|
textLabel?: string;
|
|
23
|
-
selectLabel?:string;
|
|
24
|
-
selectPlaceholder:string;
|
|
21
|
+
selectLabel?: string;
|
|
22
|
+
selectPlaceholder: string;
|
|
25
23
|
t?: (key: string) => string;
|
|
26
|
-
onCancel?:()=>void;
|
|
27
|
-
cancel?:string
|
|
24
|
+
onCancel?: () => void;
|
|
25
|
+
cancel?: string;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
export default function AddReport({
|
|
@@ -41,12 +39,10 @@ export default function AddReport({
|
|
|
41
39
|
selectPlaceholder,
|
|
42
40
|
t,
|
|
43
41
|
onCancel,
|
|
44
|
-
cancel
|
|
42
|
+
cancel,
|
|
45
43
|
}: ReportProps) {
|
|
46
44
|
const form = useSubmitReport({ onSubmit });
|
|
47
45
|
const { colors } = useAppTheme();
|
|
48
|
-
const [charCount, setCharCount] = useState(0);
|
|
49
|
-
const MAX_CHARS = 500;
|
|
50
46
|
|
|
51
47
|
return (
|
|
52
48
|
<TemplateSubPage
|
|
@@ -54,60 +50,58 @@ export default function AddReport({
|
|
|
54
50
|
text={subtitle}
|
|
55
51
|
error={error}
|
|
56
52
|
onBack={onBack}
|
|
53
|
+
buttonText={submitLabel}
|
|
54
|
+
handleFunction={form.handleSubmit}
|
|
55
|
+
loading={form.loading}
|
|
57
56
|
>
|
|
58
|
-
<View style={{ marginBottom: 16 }}>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</View>
|
|
57
|
+
<View style={{ marginBottom: 16, marginTop: 20 }}>
|
|
58
|
+
<Select
|
|
59
|
+
options={categories}
|
|
60
|
+
value={form.values.target}
|
|
61
|
+
onChange={(value) => {
|
|
62
|
+
form.setValue("target", value);
|
|
63
|
+
form.clearError("target");
|
|
64
|
+
}}
|
|
65
|
+
label={selectLabel}
|
|
66
|
+
placeholder={selectPlaceholder ?? "Select a category"}
|
|
67
|
+
error={
|
|
68
|
+
form.errors.target
|
|
69
|
+
? t?.(form.errors.target) || form.errors.target
|
|
70
|
+
: undefined
|
|
71
|
+
}
|
|
72
|
+
bgColor={colors.background.card}
|
|
73
|
+
/>
|
|
74
|
+
</View>
|
|
76
75
|
|
|
77
76
|
<TextArea
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
showCharCount
|
|
95
|
-
/>
|
|
96
|
-
<View style={{gap: 10, position: "absolute", left: 0, right:0, bottom: 40}}>
|
|
97
|
-
<SharpButton
|
|
98
|
-
text={submitLabel}
|
|
99
|
-
bgColor={colors.primary}
|
|
100
|
-
onPress={form.handleSubmit}
|
|
101
|
-
loading={form.loading}
|
|
77
|
+
value={form.values.reason}
|
|
78
|
+
onChangeText={(text) => {
|
|
79
|
+
form.setValue("reason", text);
|
|
80
|
+
}}
|
|
81
|
+
label={textLabel}
|
|
82
|
+
placeholder={detailsPlaceholder}
|
|
83
|
+
error={
|
|
84
|
+
form.errors.reason
|
|
85
|
+
? t?.(form.errors.reason) || form.errors.reason
|
|
86
|
+
: undefined
|
|
87
|
+
}
|
|
88
|
+
onClearError={() => form.clearError("reason")}
|
|
89
|
+
maxLength={500}
|
|
90
|
+
minHeight={120}
|
|
91
|
+
bgColor={colors.background.main}
|
|
92
|
+
showCharCount
|
|
102
93
|
/>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
|
|
95
|
+
{/* Cancel button — sits below the content, inside the scroll */}
|
|
96
|
+
{cancel && onCancel ? (
|
|
97
|
+
<View style={{ marginTop: 8 }}>
|
|
98
|
+
<SharpButton
|
|
99
|
+
text={cancel}
|
|
100
|
+
bgColor={colors.primary}
|
|
101
|
+
onPress={onCancel}
|
|
102
|
+
/>
|
|
103
|
+
</View>
|
|
104
|
+
) : null}
|
|
111
105
|
</TemplateSubPage>
|
|
112
106
|
);
|
|
113
107
|
}
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import { Text
|
|
1
|
+
import { Text } from "react-native";
|
|
2
2
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
3
3
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
4
4
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
6
|
+
|
|
7
|
+
interface PrivacyProps {
|
|
8
|
+
title: string;
|
|
9
|
+
subtitle: string;
|
|
10
|
+
content: string[];
|
|
11
|
+
onBack: () => void;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<View key={index}>
|
|
24
|
-
<Text style={{
|
|
13
|
+
|
|
14
|
+
export default function LegalScreen({ title, subtitle, content, onBack }: PrivacyProps) {
|
|
15
|
+
const { colors } = useAppTheme();
|
|
16
|
+
const { isRTL } = useLanguage();
|
|
17
|
+
const align = isRTL ? "right" : "left";
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<TemplateSubPage title={title} text={subtitle} onBack={onBack}>
|
|
21
|
+
{content.map((item, index) => (
|
|
22
|
+
<Text
|
|
23
|
+
key={index}
|
|
24
|
+
style={{
|
|
25
25
|
fontSize: textSize.sm,
|
|
26
26
|
lineHeight: 24,
|
|
27
27
|
fontFamily: Fonts.montserrat.regular,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}}
|
|
28
|
+
textAlign: align,
|
|
29
|
+
color: colors.text.primary,
|
|
30
|
+
}}
|
|
32
31
|
>
|
|
33
|
-
|
|
32
|
+
{item}
|
|
34
33
|
</Text>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</TemplateSubPage>
|
|
39
|
-
)
|
|
34
|
+
))}
|
|
35
|
+
</TemplateSubPage>
|
|
36
|
+
);
|
|
40
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import { Text, TouchableOpacity } from "react-native";
|
|
2
|
+
import { Text, TouchableOpacity, View } from "react-native";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { textSize, Fonts} from "../../tokens/typography";
|
|
5
5
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
@@ -37,7 +37,7 @@ export default function VerificationCodeScreen({
|
|
|
37
37
|
}: VerificationCodeScreenProps) {
|
|
38
38
|
const { colors } = useAppTheme();
|
|
39
39
|
const [code, setCode] = useState("");
|
|
40
|
-
const { count, reset } = useCountdown(
|
|
40
|
+
const { count, reset } = useCountdown(60);
|
|
41
41
|
const handleResend = () => {
|
|
42
42
|
setCode("");
|
|
43
43
|
onResend();
|
|
@@ -55,6 +55,7 @@ export default function VerificationCodeScreen({
|
|
|
55
55
|
onBack={onBack}
|
|
56
56
|
loading={loading}
|
|
57
57
|
>
|
|
58
|
+
<View style={{marginTop:20}}>
|
|
58
59
|
<OtpInput length={4} onChange={setCode} size={70}/>
|
|
59
60
|
{count !== 0 ? (
|
|
60
61
|
<Text style={{ textAlign:align, color: colors.text.placeholder, fontSize: textSize.xs, fontFamily: Fonts.montserrat.regular}}>
|
|
@@ -67,6 +68,7 @@ export default function VerificationCodeScreen({
|
|
|
67
68
|
</Text>
|
|
68
69
|
</TouchableOpacity>
|
|
69
70
|
)}
|
|
71
|
+
</View>
|
|
70
72
|
</TemplateSubPage>
|
|
71
73
|
);
|
|
72
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Modal, Text, View } from "react-native";
|
|
1
|
+
import { KeyboardAvoidingView, Modal, Platform, ScrollView, Text, View } from "react-native";
|
|
2
2
|
import Warning from "../../assets/icons/warning.svg";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
@@ -109,41 +109,95 @@ export default function ConfirmDeleteScreen({
|
|
|
109
109
|
|
|
110
110
|
<SharpButton text={button} bgColor={colors.semantic.error} onPress={onPressDelete} />
|
|
111
111
|
|
|
112
|
-
<Modal
|
|
113
|
-
|
|
112
|
+
<Modal
|
|
113
|
+
visible={modal.visible}
|
|
114
|
+
transparent
|
|
115
|
+
animationType="fade"
|
|
116
|
+
onRequestClose={modal.onCancel}
|
|
117
|
+
statusBarTranslucent
|
|
118
|
+
>
|
|
119
|
+
<KeyboardAvoidingView
|
|
120
|
+
style={{ flex: 1 }}
|
|
121
|
+
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
122
|
+
>
|
|
114
123
|
<View
|
|
115
124
|
style={{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
backgroundColor: colors.background.card,
|
|
119
|
-
borderWidth: 1.5,
|
|
120
|
-
borderColor: colors.text.primary,
|
|
121
|
-
borderRadius: 16,
|
|
122
|
-
padding: 20,
|
|
123
|
-
gap: 15,
|
|
125
|
+
flex: 1,
|
|
126
|
+
justifyContent: "center",
|
|
124
127
|
alignItems: "center",
|
|
128
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
129
|
+
paddingHorizontal: 24,
|
|
130
|
+
paddingVertical: 24,
|
|
125
131
|
}}
|
|
126
132
|
>
|
|
127
|
-
<View
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
<View
|
|
134
|
+
style={{
|
|
135
|
+
width: "100%",
|
|
136
|
+
maxWidth: 400,
|
|
137
|
+
maxHeight: "100%",
|
|
138
|
+
backgroundColor: colors.background.card,
|
|
139
|
+
borderWidth: 1.5,
|
|
140
|
+
borderColor: colors.text.primary,
|
|
141
|
+
borderRadius: 16,
|
|
142
|
+
padding: 20,
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
<ScrollView
|
|
146
|
+
bounces={false}
|
|
147
|
+
showsVerticalScrollIndicator={false}
|
|
148
|
+
contentContainerStyle={{ gap: 15, alignItems: "center" }}
|
|
149
|
+
>
|
|
150
|
+
<View style={{ alignItems: "center", gap: 15, width: "100%" }}>
|
|
151
|
+
<Warning width={50} height={50} color={colors.semantic.error} />
|
|
152
|
+
<View style={{ width: "100%" }}>
|
|
153
|
+
<Text
|
|
154
|
+
style={{
|
|
155
|
+
fontFamily: Fonts.montserrat.bold,
|
|
156
|
+
fontSize: textSize.md,
|
|
157
|
+
color: colors.text.primary,
|
|
158
|
+
textAlign: "center",
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{modal.title}
|
|
162
|
+
</Text>
|
|
163
|
+
<Text
|
|
164
|
+
style={{
|
|
165
|
+
fontFamily: Fonts.montserrat.bold,
|
|
166
|
+
fontSize: textSize.md,
|
|
167
|
+
color: colors.semantic.error,
|
|
168
|
+
textAlign: "center",
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
{modal.subtitle}
|
|
172
|
+
</Text>
|
|
173
|
+
</View>
|
|
174
|
+
</View>
|
|
138
175
|
|
|
139
|
-
|
|
176
|
+
<View
|
|
177
|
+
style={{
|
|
178
|
+
height: 1,
|
|
179
|
+
width: "100%",
|
|
180
|
+
backgroundColor: colors.semantic.border,
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
140
183
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
184
|
+
<View style={{ width: "100%", gap: 12 }}>
|
|
185
|
+
<SharpButton
|
|
186
|
+
text={modal.confirm}
|
|
187
|
+
bgColor={colors.semantic.error}
|
|
188
|
+
onPress={modal.onConfirm}
|
|
189
|
+
loading={modal.loading}
|
|
190
|
+
/>
|
|
191
|
+
<SharpButton
|
|
192
|
+
text={modal.cancel}
|
|
193
|
+
bgColor={colors.semantic.warning}
|
|
194
|
+
onPress={modal.onCancel}
|
|
195
|
+
/>
|
|
196
|
+
</View>
|
|
197
|
+
</ScrollView>
|
|
144
198
|
</View>
|
|
145
199
|
</View>
|
|
146
|
-
</
|
|
200
|
+
</KeyboardAvoidingView>
|
|
147
201
|
</Modal>
|
|
148
202
|
</TemplateSubPage>
|
|
149
203
|
</>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
2
2
|
import "../../utils/inputValidator/customValidator";
|
|
3
3
|
import { useForgotPasswordForm } from "../../hooks/useForgotPasswordForm";
|
|
4
|
-
import SharpInput from "../ui/sharpInput";
|
|
5
|
-
import {Email} from "@towsila/icons";
|
|
6
4
|
import Input from "../ui/input";
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { View } from "react-native";
|
|
9
6
|
|
|
10
7
|
interface ForgetPwScreenProps {
|
|
11
8
|
onSubmit: (input: string) => Promise<void>;
|
|
@@ -13,10 +10,10 @@ interface ForgetPwScreenProps {
|
|
|
13
10
|
subtitle?: string;
|
|
14
11
|
buttonText?: string;
|
|
15
12
|
errorMessage?: string;
|
|
16
|
-
inputLabel?:string;
|
|
13
|
+
inputLabel?: string;
|
|
17
14
|
inputPlaceholder: string;
|
|
18
|
-
onBack: ()=>void;
|
|
19
|
-
t?: (key:string) => string;
|
|
15
|
+
onBack: () => void;
|
|
16
|
+
t?: (key: string) => string;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
export default function ForgotPwScreen({
|
|
@@ -25,13 +22,15 @@ export default function ForgotPwScreen({
|
|
|
25
22
|
subtitle = "Enter your email address below, and we’ll send you an opt code to reset your password.",
|
|
26
23
|
buttonText = "Send OTP",
|
|
27
24
|
errorMessage,
|
|
28
|
-
inputLabel,
|
|
25
|
+
inputLabel = "Email address", // sensible default so the field always has a label
|
|
29
26
|
inputPlaceholder,
|
|
30
27
|
onBack,
|
|
31
28
|
t,
|
|
32
29
|
}: ForgetPwScreenProps) {
|
|
30
|
+
const form = useForgotPasswordForm({ onSubmit });
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
// Avoid stacking a field-level error and a server-level error on top of each other
|
|
33
|
+
const serverError = form.errors.input ? undefined : errorMessage;
|
|
35
34
|
|
|
36
35
|
return (
|
|
37
36
|
<TemplateSubPage
|
|
@@ -39,10 +38,11 @@ export default function ForgotPwScreen({
|
|
|
39
38
|
text={subtitle}
|
|
40
39
|
buttonText={buttonText}
|
|
41
40
|
handleFunction={form.handleSubmit}
|
|
42
|
-
error={
|
|
41
|
+
error={serverError}
|
|
43
42
|
onBack={onBack}
|
|
44
43
|
loading={form.loading}
|
|
45
44
|
>
|
|
45
|
+
<View style={{ marginTop: 20 }}>
|
|
46
46
|
<Input
|
|
47
47
|
value={form.values.input}
|
|
48
48
|
onChangeText={(text) => form.setValue("input", text)}
|
|
@@ -54,9 +54,12 @@ export default function ForgotPwScreen({
|
|
|
54
54
|
autoCapitalize="none"
|
|
55
55
|
autoComplete="email"
|
|
56
56
|
textContentType="emailAddress"
|
|
57
|
-
returnKeyType="next"
|
|
57
|
+
returnKeyType="done" // was "next" — no next field
|
|
58
|
+
onSubmitEditing={form.handleSubmit} // Enter key submits
|
|
59
|
+
blurOnSubmit={false} // optional; see below
|
|
58
60
|
onClearError={() => form.clearError("input")}
|
|
59
61
|
/>
|
|
62
|
+
</View>
|
|
60
63
|
</TemplateSubPage>
|
|
61
64
|
);
|
|
62
|
-
}
|
|
65
|
+
}
|