@towsila/expo-ui-library 4.2.0 → 4.3.0
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
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, ScrollView } from "react-native";
|
|
3
|
+
import { FieldConfig } from "../../types/validateForm";
|
|
4
|
+
import { useAppTheme } from "../../context/ThemeContext";
|
|
5
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
6
|
+
import Input from "../ui/input";
|
|
7
|
+
import ScreenHeader from "../ui/PageTopBar";
|
|
8
|
+
import { Fonts, textSize } from "../../tokens/typography";
|
|
9
|
+
import SharpButton from "../ui/sharpButton";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title: string;
|
|
13
|
+
email: string;
|
|
14
|
+
fields: FieldConfig[];
|
|
15
|
+
formState: Record<string, string>;
|
|
16
|
+
errors: Record<string, string>;
|
|
17
|
+
onChangeField: (key: string, value: string) => void;
|
|
18
|
+
clearError: (key: string) => void;
|
|
19
|
+
translateError?: (key: string) => string;
|
|
20
|
+
phonePrefix?: React.ReactNode; // app passes the flag + 213+
|
|
21
|
+
extraCard?: React.ReactNode; // provider only: basePrice, licence, authorisation
|
|
22
|
+
footer?: React.ReactNode; // client only: sits above the button
|
|
23
|
+
button: string;
|
|
24
|
+
showButton: boolean; // e.g. isChanged
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
onSubmit: () => void;
|
|
27
|
+
onBack?: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const cardStyle = (colors: any) => ({
|
|
31
|
+
borderWidth: 2,
|
|
32
|
+
borderColor: colors.text.primary,
|
|
33
|
+
borderRadius: 16,
|
|
34
|
+
padding: 15,
|
|
35
|
+
backgroundColor: colors.background.card,
|
|
36
|
+
gap: 15,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default function ProfileLayout({
|
|
40
|
+
title, email, fields, formState, errors, onChangeField, clearError, translateError,
|
|
41
|
+
phonePrefix, extraCard, footer, button, showButton, loading, onSubmit, onBack,
|
|
42
|
+
}: Props) {
|
|
43
|
+
const { colors } = useAppTheme();
|
|
44
|
+
const { isRTL } = useLanguage();
|
|
45
|
+
const byName = (n: string) => fields.find((f) => f.name === n);
|
|
46
|
+
|
|
47
|
+
const renderInput = (field?: FieldConfig) => {
|
|
48
|
+
if (!field) return null;
|
|
49
|
+
return (
|
|
50
|
+
<Input
|
|
51
|
+
key={field.name}
|
|
52
|
+
label={field.label}
|
|
53
|
+
value={formState[field.name] ?? ""}
|
|
54
|
+
placeholder=""
|
|
55
|
+
onChangeText={(text) => onChangeField(field.name, text)}
|
|
56
|
+
autoCapitalize="words"
|
|
57
|
+
returnKeyType="next"
|
|
58
|
+
error={errors[field.name] ? (translateError?.(errors[field.name]) ?? errors[field.name]) : ""}
|
|
59
|
+
onClearError={() => clearError(field.name)}
|
|
60
|
+
keyboardType={field.type === "phone" ? "phone-pad" : field.type === "numeric" ? "numeric" : "default"}
|
|
61
|
+
prefix={field.type === "phone" ? phonePrefix : undefined}
|
|
62
|
+
borderColor={colors.semantic.border}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View style={{ flex: 1, paddingHorizontal: 20, paddingTop: 60, backgroundColor: colors.background.main }}>
|
|
69
|
+
<ScreenHeader title={title} description="" onBack={onBack} />
|
|
70
|
+
<ScrollView
|
|
71
|
+
style={{ flex: 1 }}
|
|
72
|
+
contentContainerStyle={{ gap: 30, paddingBottom: 40 }}
|
|
73
|
+
showsVerticalScrollIndicator={false}
|
|
74
|
+
keyboardShouldPersistTaps="handled"
|
|
75
|
+
>
|
|
76
|
+
<View style={{ gap: 20 }}>
|
|
77
|
+
<Text style={{ fontSize: textSize.sm, fontFamily: Fonts.montserrat.regular, color: colors.text.placeholder, textAlign: isRTL ? "left" : "right" }}>
|
|
78
|
+
{email}
|
|
79
|
+
</Text>
|
|
80
|
+
|
|
81
|
+
<View style={cardStyle(colors)}>
|
|
82
|
+
<View style={{ flexDirection: isRTL ? "row" : "row-reverse", gap: 10 }}>
|
|
83
|
+
<View style={{ flex: 1 }}>{renderInput(byName("firstname"))}</View>
|
|
84
|
+
<View style={{ flex: 1 }}>{renderInput(byName("lastname"))}</View>
|
|
85
|
+
</View>
|
|
86
|
+
{renderInput(byName("phone"))}
|
|
87
|
+
</View>
|
|
88
|
+
|
|
89
|
+
{extraCard ? <View style={cardStyle(colors)}>{extraCard}</View> : null}
|
|
90
|
+
</View>
|
|
91
|
+
|
|
92
|
+
{footer}
|
|
93
|
+
|
|
94
|
+
{showButton && (
|
|
95
|
+
<View style={{ paddingHorizontal: 15 }}>
|
|
96
|
+
<SharpButton text={button} textColor={colors.text.primary} bgColor={colors.primary} onPress={onSubmit} loading={loading} />
|
|
97
|
+
</View>
|
|
98
|
+
)}
|
|
99
|
+
</ScrollView>
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { View, Text } from "react-native";
|
|
2
|
+
import DzFlag from "@/assets/images/icons/dz_flag.svg";
|
|
3
|
+
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
5
|
+
import { Fonts, textSize } from "../../tokens/typography";
|
|
6
|
+
|
|
7
|
+
export default function PhonePrefix() {
|
|
8
|
+
const { colors } = useAppTheme();
|
|
9
|
+
const { isRTL } = useLanguage();
|
|
10
|
+
return (
|
|
11
|
+
<View
|
|
12
|
+
style={{
|
|
13
|
+
flexDirection: isRTL ? "row" : "row-reverse",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
gap: 4,
|
|
16
|
+
height: 50,
|
|
17
|
+
paddingHorizontal: 14,
|
|
18
|
+
[isRTL ? "borderRightWidth" : "borderLeftWidth"]: 1,
|
|
19
|
+
[isRTL ? "borderRightColor" : "borderLeftColor"]: colors.semantic.border,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<DzFlag width={23} height={15} />
|
|
23
|
+
<Text style={{ fontSize: textSize.sm, fontFamily: Fonts.montserrat.semiBold, color: colors.text.primary }}>
|
|
24
|
+
213+
|
|
25
|
+
</Text>
|
|
26
|
+
</View>
|
|
27
|
+
);
|
|
28
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -76,4 +76,6 @@ export {useRelativeTime} from "./hooks/useRelativeTime";
|
|
|
76
76
|
export { bearing, distanceM } from "./utils/geo";
|
|
77
77
|
export { formatPrice } from "./utils/formatPrice";
|
|
78
78
|
export { shortAddress, getWilaya } from "./utils/shortanName";
|
|
79
|
-
export {RouteInfo} from "./types/route";
|
|
79
|
+
export {RouteInfo} from "./types/route";
|
|
80
|
+
export {default as PhonePrefix} from "./components/ui/phonePrefix";
|
|
81
|
+
export {default as ProfileScreen} from "./components/screens/profileScreen";
|