@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
Text, TouchableOpacity, View, ScrollView, KeyboardAvoidingView, Platform,
|
|
4
3
|
} from "react-native";
|
|
4
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
5
|
|
|
6
6
|
import Input from "../ui/input";
|
|
7
7
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
@@ -12,6 +12,7 @@ import SharpButton from "../ui/sharpButton";
|
|
|
12
12
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
13
13
|
import SharpContainer from "../ui/sharpContainer";
|
|
14
14
|
import Google from "../../assets/icons/google.svg";
|
|
15
|
+
|
|
15
16
|
interface LoginScreenProps {
|
|
16
17
|
title?: string;
|
|
17
18
|
subtitle?: string;
|
|
@@ -55,91 +56,194 @@ export default function LoginScreen({
|
|
|
55
56
|
}: LoginScreenProps) {
|
|
56
57
|
const { colors } = useAppTheme();
|
|
57
58
|
const form = useLoginForm({ onLogin });
|
|
58
|
-
const {isRTL} = useLanguage();
|
|
59
|
-
const align = isRTL ? "row-reverse":"row";
|
|
59
|
+
const { isRTL } = useLanguage();
|
|
60
|
+
const align = isRTL ? "row-reverse" : "row";
|
|
61
|
+
|
|
60
62
|
return (
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
63
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background.main }}>
|
|
64
|
+
<KeyboardAvoidingView
|
|
65
|
+
style={{ flex: 1 }}
|
|
66
|
+
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
67
|
+
keyboardVerticalOffset={Platform.OS === "ios" ? 0 : 20}
|
|
68
|
+
>
|
|
69
|
+
<ScrollView
|
|
70
|
+
contentContainerStyle={{
|
|
71
|
+
flexGrow: 1,
|
|
72
|
+
paddingHorizontal: 20,
|
|
73
|
+
paddingTop: 20,
|
|
74
|
+
paddingBottom: 24,
|
|
75
|
+
}}
|
|
76
|
+
keyboardShouldPersistTaps="handled"
|
|
77
|
+
showsVerticalScrollIndicator={false}
|
|
78
|
+
>
|
|
79
|
+
<ScreenHeader title={title} description={subtitle} />
|
|
80
|
+
|
|
81
|
+
<View
|
|
82
|
+
style={{
|
|
83
|
+
marginTop: 32,
|
|
84
|
+
marginBottom: 20,
|
|
85
|
+
padding: 15,
|
|
86
|
+
borderRadius: 10,
|
|
87
|
+
gap: 20,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Input
|
|
91
|
+
label={emailLabel}
|
|
92
|
+
value={form.values.email}
|
|
93
|
+
onChangeText={(text) => form.setValue("email", text)}
|
|
94
|
+
placeholder={emailPlaceholder}
|
|
95
|
+
keyboardType="email-address"
|
|
96
|
+
error={form.errors.email ? t?.(form.errors.email) : ""}
|
|
97
|
+
autoCapitalize="none"
|
|
98
|
+
autoComplete="email"
|
|
99
|
+
textContentType="emailAddress"
|
|
100
|
+
returnKeyType="next"
|
|
101
|
+
onClearError={() => form.clearError("email")}
|
|
102
|
+
iconLeft={"mail-outline"}
|
|
103
|
+
height={52}
|
|
104
|
+
/>
|
|
105
|
+
<Input
|
|
106
|
+
label={passwordLabel}
|
|
107
|
+
value={form.values.password}
|
|
108
|
+
onChangeText={(value) => form.setValue("password", value)}
|
|
109
|
+
placeholder={passwordPlaceholder}
|
|
110
|
+
iconRight={form.showPassword ? "eye-off-outline" : "eye-outline"}
|
|
111
|
+
onPressIconRight={() => form.setShowPassword(!form.showPassword)}
|
|
112
|
+
secureTextEntry={!form.showPassword}
|
|
113
|
+
textContentType="password"
|
|
114
|
+
returnKeyType="done"
|
|
115
|
+
error={form.errors.password ? t?.(form.errors.password) : ""}
|
|
116
|
+
onClearError={() => form.clearError("password")}
|
|
117
|
+
iconLeft={"lock-closed-outline"}
|
|
118
|
+
height={52}
|
|
119
|
+
/>
|
|
120
|
+
<View style={{ gap: 10 }}>
|
|
121
|
+
<SharpButton
|
|
122
|
+
text={loginButtonLabel}
|
|
123
|
+
bgColor={colors.primary}
|
|
124
|
+
onPress={form.handleSubmit}
|
|
125
|
+
height={56}
|
|
126
|
+
loading={form.loading}
|
|
127
|
+
/>
|
|
128
|
+
<TouchableOpacity
|
|
129
|
+
onPress={onForgotPassword}
|
|
130
|
+
activeOpacity={0.7}
|
|
131
|
+
style={{ alignSelf: isRTL ? "flex-end" : "flex-start" }}
|
|
132
|
+
>
|
|
133
|
+
<Text
|
|
134
|
+
style={{
|
|
135
|
+
fontSize: textSize.sm,
|
|
136
|
+
color: colors.text.secondary,
|
|
137
|
+
fontFamily: Fonts.montserrat.regular,
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{forgotPasswordLabel}
|
|
97
141
|
</Text>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
</TouchableOpacity>
|
|
143
|
+
</View>
|
|
144
|
+
</View>
|
|
145
|
+
|
|
146
|
+
{onGoogleLogin && (
|
|
103
147
|
<View>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
148
|
+
<View
|
|
149
|
+
style={{
|
|
150
|
+
flexDirection: align,
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
gap: 12,
|
|
153
|
+
marginVertical: 20,
|
|
154
|
+
marginHorizontal: 20,
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
<View
|
|
158
|
+
style={{
|
|
159
|
+
flex: 1,
|
|
160
|
+
height: 1,
|
|
161
|
+
backgroundColor: colors.text.placeholder,
|
|
162
|
+
opacity: 0.5,
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
165
|
+
<Text
|
|
166
|
+
style={{
|
|
167
|
+
fontSize: textSize.xs,
|
|
168
|
+
color: colors.text.placeholder,
|
|
169
|
+
fontFamily: Fonts.montserrat.regular,
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{dividerLabel}
|
|
173
|
+
</Text>
|
|
174
|
+
<View
|
|
175
|
+
style={{
|
|
176
|
+
flex: 1,
|
|
177
|
+
height: 1,
|
|
178
|
+
backgroundColor: colors.text.placeholder,
|
|
179
|
+
opacity: 0.5,
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
</View>
|
|
183
|
+
<View style={{ marginHorizontal: 28 }}>
|
|
184
|
+
<SharpContainer
|
|
185
|
+
bgColor={colors.background.main}
|
|
186
|
+
borderColor={colors.text.primary}
|
|
187
|
+
height={56}
|
|
188
|
+
>
|
|
189
|
+
<TouchableOpacity
|
|
190
|
+
style={{
|
|
191
|
+
flexDirection: align,
|
|
192
|
+
alignItems: "center",
|
|
193
|
+
justifyContent: "center",
|
|
194
|
+
gap: 10,
|
|
195
|
+
}}
|
|
196
|
+
onPress={onGoogleLogin}
|
|
197
|
+
>
|
|
198
|
+
<Google width={20} height={20} />
|
|
199
|
+
<Text
|
|
200
|
+
style={{
|
|
201
|
+
fontSize: textSize.sm,
|
|
202
|
+
fontFamily: Fonts.montserrat.semiBold,
|
|
203
|
+
color: colors.text.primary,
|
|
204
|
+
}}
|
|
116
205
|
>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
color: colors.text.primary,
|
|
123
|
-
}}>
|
|
124
|
-
{googleLabel}
|
|
125
|
-
</Text>
|
|
126
|
-
</TouchableOpacity>
|
|
127
|
-
</SharpContainer>
|
|
128
|
-
</View>
|
|
206
|
+
{googleLabel}
|
|
207
|
+
</Text>
|
|
208
|
+
</TouchableOpacity>
|
|
209
|
+
</SharpContainer>
|
|
210
|
+
</View>
|
|
129
211
|
</View>
|
|
130
|
-
|
|
212
|
+
)}
|
|
131
213
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
214
|
+
{/* Footer — pinned to bottom when there's space, flows naturally otherwise */}
|
|
215
|
+
<View
|
|
216
|
+
style={{
|
|
217
|
+
marginTop: "auto",
|
|
218
|
+
paddingTop: 24,
|
|
219
|
+
flexDirection: align,
|
|
220
|
+
justifyContent: "center",
|
|
221
|
+
gap: 4,
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
<Text
|
|
225
|
+
style={{
|
|
226
|
+
fontSize: textSize.sm,
|
|
227
|
+
color: colors.text.primary,
|
|
228
|
+
fontFamily: Fonts.montserrat.regular,
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
{noAccountLabel}
|
|
135
232
|
</Text>
|
|
136
233
|
<TouchableOpacity onPress={onSignUp} activeOpacity={0.7}>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
234
|
+
<Text
|
|
235
|
+
style={{
|
|
236
|
+
fontSize: textSize.sm,
|
|
237
|
+
color: colors.primary,
|
|
238
|
+
fontFamily: Fonts.montserrat.semiBold,
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
{signUpLabel}
|
|
242
|
+
</Text>
|
|
140
243
|
</TouchableOpacity>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
244
|
+
</View>
|
|
245
|
+
</ScrollView>
|
|
246
|
+
</KeyboardAvoidingView>
|
|
247
|
+
</SafeAreaView>
|
|
144
248
|
);
|
|
145
249
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, View, StyleSheet } from "react-native";
|
|
2
|
-
import {
|
|
1
|
+
import { Text, TouchableOpacity, View, StyleSheet, ScrollView } from "react-native";
|
|
2
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
5
|
import PageIndicator from "../ui/pageIndicator";
|
|
@@ -32,88 +32,121 @@ export default function OnBoarding({
|
|
|
32
32
|
nextLabel,
|
|
33
33
|
currentIndex,
|
|
34
34
|
total,
|
|
35
|
-
|
|
35
|
+
stepsLabel,
|
|
36
36
|
}: OnBoardingProps) {
|
|
37
37
|
const { colors } = useAppTheme();
|
|
38
|
-
const {isRTL} = useLanguage();
|
|
38
|
+
const { isRTL } = useLanguage();
|
|
39
|
+
|
|
39
40
|
return (
|
|
40
|
-
<
|
|
41
|
-
style={[
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
41
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background.main }}>
|
|
42
|
+
<View style={[styles.container, { backgroundColor: colors.background.main }]}>
|
|
43
|
+
{/* ---------- Header ---------- */}
|
|
44
|
+
<View style={{ minHeight: 40 }}>
|
|
45
|
+
<View
|
|
46
|
+
style={{
|
|
47
|
+
minHeight: 44, // was height: 44 — grows with font
|
|
48
|
+
flexDirection: isRTL ? "row-reverse" : "row",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
gap: 15,
|
|
51
|
+
justifyContent: "space-between",
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<View
|
|
55
|
+
style={{
|
|
56
|
+
flexDirection: isRTL ? "row-reverse" : "row",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
gap: 15,
|
|
59
|
+
flexShrink: 1, // lets title truncate if long
|
|
60
|
+
minWidth: 0,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{onBack && <BackIcon onBack={onBack} />}
|
|
64
|
+
<Text
|
|
65
|
+
numberOfLines={1}
|
|
66
|
+
style={{
|
|
67
|
+
flexShrink: 1,
|
|
68
|
+
fontSize: textSize.xl,
|
|
69
|
+
fontFamily: Fonts.montserrat.bold,
|
|
70
|
+
color: colors.text.primary,
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{title}
|
|
74
|
+
</Text>
|
|
71
75
|
</View>
|
|
76
|
+
<TouchableOpacity onPress={onSkip} hitSlop={8}>
|
|
77
|
+
<Text
|
|
78
|
+
style={[
|
|
79
|
+
styles.skipLabel,
|
|
80
|
+
{
|
|
81
|
+
color: colors.text.primary,
|
|
82
|
+
textAlign: isRTL ? "left" : "right",
|
|
83
|
+
},
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
{skipLabel}
|
|
87
|
+
</Text>
|
|
88
|
+
</TouchableOpacity>
|
|
89
|
+
</View>
|
|
72
90
|
</View>
|
|
73
91
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
|
|
92
|
+
{/* ---------- Content ---------- */}
|
|
93
|
+
<ScrollView
|
|
94
|
+
style={{ flex: 1 }}
|
|
95
|
+
contentContainerStyle={{ flexGrow: 1, justifyContent: "center" }}
|
|
96
|
+
showsVerticalScrollIndicator={false}
|
|
97
|
+
>
|
|
98
|
+
<View style={styles.content}>
|
|
99
|
+
<View
|
|
100
|
+
style={[
|
|
101
|
+
styles.imageContainer,
|
|
102
|
+
isRTL && { transform: [{ scaleX: -1 }] },
|
|
103
|
+
]}
|
|
104
|
+
>
|
|
105
|
+
{image}
|
|
106
|
+
</View>
|
|
80
107
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{/* Text */}
|
|
92
|
-
<Text
|
|
93
|
-
style={[
|
|
94
|
-
styles.description,
|
|
95
|
-
{ color: colors.text.secondary,textAlign: isRTL ? "right" : "left", },
|
|
96
|
-
]}
|
|
97
|
-
>
|
|
98
|
-
{description}
|
|
99
|
-
</Text>
|
|
100
|
-
</View>
|
|
108
|
+
<View style={styles.indicatorContainer}>
|
|
109
|
+
<PageIndicator
|
|
110
|
+
total={total}
|
|
111
|
+
current={currentIndex}
|
|
112
|
+
color={colors.primary}
|
|
113
|
+
textColor={colors.text.primary}
|
|
114
|
+
defaultColor={colors.semantic.border}
|
|
115
|
+
stepsLabel={stepsLabel}
|
|
116
|
+
/>
|
|
117
|
+
</View>
|
|
101
118
|
|
|
102
|
-
|
|
119
|
+
<Text
|
|
120
|
+
style={[
|
|
121
|
+
styles.description,
|
|
122
|
+
{
|
|
123
|
+
color: colors.text.secondary,
|
|
124
|
+
textAlign: isRTL ? "right" : "left",
|
|
125
|
+
},
|
|
126
|
+
]}
|
|
127
|
+
>
|
|
128
|
+
{description}
|
|
129
|
+
</Text>
|
|
130
|
+
</View>
|
|
131
|
+
</ScrollView>
|
|
132
|
+
|
|
133
|
+
{/* ---------- Footer ---------- */}
|
|
103
134
|
<SharpButton
|
|
104
135
|
text={nextLabel}
|
|
105
136
|
bgColor={colors.primary}
|
|
106
137
|
onPress={onNext}
|
|
107
138
|
/>
|
|
108
|
-
|
|
139
|
+
</View>
|
|
140
|
+
</SafeAreaView>
|
|
109
141
|
);
|
|
110
142
|
}
|
|
111
143
|
|
|
112
144
|
const styles = StyleSheet.create({
|
|
113
145
|
container: {
|
|
114
146
|
flex: 1,
|
|
115
|
-
paddingHorizontal: 32
|
|
116
|
-
|
|
147
|
+
paddingHorizontal: 20, // was 32 — matches the rest of the app
|
|
148
|
+
paddingTop: 16, // SafeAreaView handles the notch
|
|
149
|
+
paddingBottom: 16,
|
|
117
150
|
},
|
|
118
151
|
|
|
119
152
|
skipLabel: {
|
|
@@ -121,8 +154,6 @@ const styles = StyleSheet.create({
|
|
|
121
154
|
fontFamily: Fonts.montserrat.regular,
|
|
122
155
|
},
|
|
123
156
|
|
|
124
|
-
|
|
125
|
-
|
|
126
157
|
content: {
|
|
127
158
|
flex: 1,
|
|
128
159
|
justifyContent: "center",
|
|
@@ -142,6 +173,4 @@ const styles = StyleSheet.create({
|
|
|
142
173
|
marginTop: 10,
|
|
143
174
|
marginBottom: 25,
|
|
144
175
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
176
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { View, Text,
|
|
2
|
+
import { View, Text, useWindowDimensions } from "react-native";
|
|
3
3
|
import { FieldConfig } from "../../types/validateForm";
|
|
4
4
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
5
5
|
import { useLanguage } from "../../context/LanguageContext";
|
|
6
6
|
import Input from "../ui/input";
|
|
7
|
-
import ScreenHeader from "../ui/PageTopBar";
|
|
8
7
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
9
|
-
import SharpButton from "../ui/sharpButton";
|
|
10
8
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
11
9
|
|
|
12
10
|
interface Props {
|
|
@@ -18,11 +16,11 @@ interface Props {
|
|
|
18
16
|
onChangeField: (key: string, value: string) => void;
|
|
19
17
|
clearError: (key: string) => void;
|
|
20
18
|
translateError?: (key: string) => string;
|
|
21
|
-
phonePrefix?: React.ReactNode;
|
|
22
|
-
extraCard?: React.ReactNode;
|
|
23
|
-
footer?: React.ReactNode;
|
|
19
|
+
phonePrefix?: React.ReactNode;
|
|
20
|
+
extraCard?: React.ReactNode;
|
|
21
|
+
footer?: React.ReactNode;
|
|
24
22
|
button: string;
|
|
25
|
-
showButton: boolean;
|
|
23
|
+
showButton: boolean;
|
|
26
24
|
loading?: boolean;
|
|
27
25
|
onSubmit: () => void;
|
|
28
26
|
onBack: () => void;
|
|
@@ -38,13 +36,37 @@ const cardStyle = (colors: any) => ({
|
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
export default function ProfileLayout({
|
|
41
|
-
title,
|
|
42
|
-
|
|
39
|
+
title,
|
|
40
|
+
email,
|
|
41
|
+
fields,
|
|
42
|
+
formState,
|
|
43
|
+
errors,
|
|
44
|
+
onChangeField,
|
|
45
|
+
clearError,
|
|
46
|
+
translateError,
|
|
47
|
+
phonePrefix,
|
|
48
|
+
extraCard,
|
|
49
|
+
footer,
|
|
50
|
+
button,
|
|
51
|
+
showButton,
|
|
52
|
+
loading,
|
|
53
|
+
onSubmit,
|
|
54
|
+
onBack,
|
|
43
55
|
}: Props) {
|
|
44
56
|
const { colors } = useAppTheme();
|
|
45
57
|
const { isRTL } = useLanguage();
|
|
58
|
+
const { width } = useWindowDimensions();
|
|
59
|
+
|
|
46
60
|
const byName = (n: string) => fields.find((f) => f.name === n);
|
|
47
61
|
|
|
62
|
+
const firstnameField = byName("firstname");
|
|
63
|
+
const lastnameField = byName("lastname");
|
|
64
|
+
const hasBoth = !!firstnameField && !!lastnameField;
|
|
65
|
+
|
|
66
|
+
// On screens narrower than ~360pt (iPhone SE, small Androids)
|
|
67
|
+
// stack first/last name vertically so inputs aren't too narrow.
|
|
68
|
+
const stackNames = width < 360 || !hasBoth;
|
|
69
|
+
|
|
48
70
|
const renderInput = (field?: FieldConfig) => {
|
|
49
71
|
if (!field) return null;
|
|
50
72
|
return (
|
|
@@ -56,9 +78,19 @@ export default function ProfileLayout({
|
|
|
56
78
|
onChangeText={(text) => onChangeField(field.name, text)}
|
|
57
79
|
autoCapitalize="words"
|
|
58
80
|
returnKeyType="next"
|
|
59
|
-
error={
|
|
81
|
+
error={
|
|
82
|
+
errors[field.name]
|
|
83
|
+
? translateError?.(errors[field.name]) ?? errors[field.name]
|
|
84
|
+
: ""
|
|
85
|
+
}
|
|
60
86
|
onClearError={() => clearError(field.name)}
|
|
61
|
-
keyboardType={
|
|
87
|
+
keyboardType={
|
|
88
|
+
field.type === "phone"
|
|
89
|
+
? "phone-pad"
|
|
90
|
+
: field.type === "numeric"
|
|
91
|
+
? "numeric"
|
|
92
|
+
: "default"
|
|
93
|
+
}
|
|
62
94
|
prefix={field.type === "phone" ? phonePrefix : undefined}
|
|
63
95
|
borderColor={colors.semantic.border}
|
|
64
96
|
/>
|
|
@@ -66,31 +98,51 @@ export default function ProfileLayout({
|
|
|
66
98
|
};
|
|
67
99
|
|
|
68
100
|
return (
|
|
69
|
-
<TemplateSubPage
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
<TemplateSubPage
|
|
102
|
+
title={title}
|
|
103
|
+
text=""
|
|
104
|
+
onBack={onBack}
|
|
105
|
+
// Use TemplateSubPage's built-in pinned button slot so it
|
|
106
|
+
// stays above the keyboard and doesn't scroll away on small screens.
|
|
107
|
+
buttonText={showButton ? button : undefined}
|
|
108
|
+
handleFunction={onSubmit}
|
|
109
|
+
loading={loading}
|
|
110
|
+
>
|
|
111
|
+
<View style={{ gap: 10 }}>
|
|
112
|
+
<Text
|
|
113
|
+
numberOfLines={1}
|
|
114
|
+
ellipsizeMode="middle"
|
|
115
|
+
style={{
|
|
116
|
+
fontSize: textSize.sm,
|
|
117
|
+
fontFamily: Fonts.montserrat.regular,
|
|
118
|
+
color: colors.text.secondary,
|
|
119
|
+
textAlign: isRTL ? "right" : "left",
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
{email}
|
|
123
|
+
</Text>
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
125
|
+
<View style={cardStyle(colors)}>
|
|
126
|
+
<View
|
|
127
|
+
style={{
|
|
128
|
+
flexDirection: stackNames
|
|
129
|
+
? "column"
|
|
130
|
+
: isRTL
|
|
131
|
+
? "row-reverse"
|
|
132
|
+
: "row",
|
|
133
|
+
gap: 10,
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<View style={{ flex: 1 }}>{renderInput(firstnameField)}</View>
|
|
137
|
+
<View style={{ flex: 1 }}>{renderInput(lastnameField)}</View>
|
|
82
138
|
</View>
|
|
83
|
-
|
|
84
|
-
{extraCard ? <View style={cardStyle(colors)}>{extraCard}</View> : null}
|
|
139
|
+
{renderInput(byName("phone"))}
|
|
85
140
|
</View>
|
|
86
141
|
|
|
87
|
-
{
|
|
142
|
+
{extraCard ? <View style={cardStyle(colors)}>{extraCard}</View> : null}
|
|
143
|
+
</View>
|
|
88
144
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<SharpButton text={button} textColor={colors.text.primary} bgColor={colors.primary} onPress={onSubmit} loading={loading} />
|
|
92
|
-
</View>
|
|
93
|
-
)}
|
|
94
|
-
</TemplateSubPage>
|
|
145
|
+
{footer}
|
|
146
|
+
</TemplateSubPage>
|
|
95
147
|
);
|
|
96
148
|
}
|