@towsila/expo-ui-library 4.4.0 → 4.6.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 +1 -1
- package/src/assets/icons/clock.svg +3 -0
- package/src/assets/icons/destination.svg +3 -0
- package/src/assets/icons/flag.svg +3 -0
- package/src/assets/icons/warning.svg +5 -0
- package/src/components/ui/requestCard.tsx +121 -69
- package/src/index.ts +1 -1
- package/src/types/request.ts +13 -17
package/package.json
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M6.8338 3.33352V6.8338L9.16732 8.00056M12.6676 6.8338C12.6676 10.0557 10.0557 12.6676 6.8338 12.6676C3.61188 12.6676 1 10.0557 1 6.8338C1 3.61188 3.61188 1 6.8338 1C10.0557 1 12.6676 3.61188 12.6676 6.8338Z" stroke-width="1" stroke-linecap="round" stroke="currentColor"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="19" viewBox="0 0 16 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M14.2324 7.56719C14.2324 11.7284 9.61702 16.0621 8.06717 17.4006C7.92279 17.5092 7.74704 17.5679 7.56639 17.5679C7.38574 17.5679 7.20999 17.5092 7.06561 17.4006C5.51576 16.0621 0.900391 11.7284 0.900391 7.56719C0.900391 5.79891 1.6027 4.10306 2.85282 2.8527C4.10293 1.60235 5.79846 0.899902 7.56639 0.899902C9.33432 0.899902 11.0298 1.60235 12.28 2.8527C13.5301 4.10306 14.2324 5.79891 14.2324 7.56719ZM10.0661 7.56719C10.0661 8.94802 8.94696 10.0674 7.56639 10.0674C6.18582 10.0674 5.06664 8.94802 5.06664 7.56719C5.06664 6.18635 6.18582 5.06695 7.56639 5.06695C8.94696 5.06695 10.0661 6.18635 10.0661 7.56719Z" stroke-width="1.8" stroke-linecap="round" stroke="currentColor"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="17" height="21" viewBox="0 0 17 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M0.900391 19.2347V13.3016M0.900391 13.3016V2.73338C0.900391 2.59106 0.93352 2.4507 0.997156 2.3234C1.06079 2.19611 1.15319 2.08538 1.26702 1.99999C2.21895 1.28591 3.37677 0.899902 4.56669 0.899902C7.31642 0.899902 9.14957 2.73338 11.2879 2.73338C12.51 2.73338 13.4471 2.48892 14.0991 1.99999C14.2352 1.89784 14.3972 1.83564 14.5667 1.82035C14.7362 1.80506 14.9067 1.83729 15.0589 1.91343C15.2112 1.98956 15.3392 2.1066 15.4287 2.25142C15.5182 2.39625 15.5656 2.56313 15.5656 2.73338V11.9008C15.5656 12.0431 15.5325 12.1835 15.4688 12.3108C15.4052 12.4381 15.3128 12.5488 15.199 12.6342C14.247 13.3483 13.0892 13.7343 11.8993 13.7343C9.14956 13.7343 7.31642 11.9008 4.56669 11.9008C3.21393 11.9008 1.90865 12.3995 0.900391 13.3016Z" stroke-width="1.8" stroke-linecap="round" stroke="currentColor"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M9.44172 3.57508L1.65005 16.5001C1.49033 16.7766 1.40562 17.0901 1.40431 17.4095C1.403 17.7288 1.48514 18.043 1.64259 18.3208C1.80004 18.5987 2.02734 18.8306 2.30198 18.9936C2.57661 19.1566 2.88906 19.245 3.20838 19.2501H18.7917C19.111 19.245 19.4235 19.1566 19.6981 18.9936C19.9728 18.8306 20.2001 18.5987 20.3575 18.3208C20.515 18.043 20.5971 17.7288 20.5958 17.4095C20.5945 17.0901 20.5098 16.7766 20.35 16.5001L12.5584 3.57508C12.394 3.30978 12.1645 3.09085 11.8918 2.93903C11.6191 2.78721 11.3122 2.70752 11.0001 2.70752C10.6879 2.70752 10.381 2.78721 10.1083 2.93903C9.83557 3.09085 9.60614 3.30978 9.44172 3.57508Z" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/>
|
|
3
|
+
<path d="M11 8.25V11.9167" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/>
|
|
4
|
+
<path d="M11 15.5835H11.0092" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/>
|
|
5
|
+
</svg>
|
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
import { View, Text } from "react-native";
|
|
2
|
+
import Clock from "../../assets/icons/clock.svg";
|
|
3
|
+
import Destination from "../../assets/icons/destination.svg";
|
|
4
|
+
import Flag from "../../assets/icons/flag.svg";
|
|
5
|
+
import Warning from "../../assets/icons/warning.svg";
|
|
2
6
|
import { SvgProps } from "react-native-svg";
|
|
3
|
-
import Clock from "@/assets/images/icons/clock.svg";
|
|
4
|
-
import Destination from "@/assets/images/icons/destination.svg";
|
|
5
|
-
import Flag from "@/assets/images/icons/flag.svg";
|
|
6
|
-
import Warning from "@/assets/images/icons/warning.svg";
|
|
7
|
-
import { RequestCardData, RequestCardLabels } from "../../types/request";
|
|
8
7
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
8
|
+
import { useRelativeTime } from "../../hooks/useRelativeTime";
|
|
9
9
|
import { useLanguage } from "../../context/LanguageContext";
|
|
10
|
+
import {Request} from "../../types/request";
|
|
10
11
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
11
12
|
import CircularCountdown from "./circularCountdown";
|
|
12
13
|
import { formatPrice } from "../../utils/formatPrice";
|
|
14
|
+
export default function RequestCard({
|
|
15
|
+
request,
|
|
16
|
+
addRow = false,
|
|
17
|
+
onExpire,
|
|
18
|
+
t,
|
|
19
|
+
locationName,
|
|
20
|
+
destinationName,
|
|
21
|
+
}: { request: Request, addRow?: boolean, onExpire?: (id:string)=>void, t: (key: string, opts?: any) => string; locationName: string; destinationName: string;}) {
|
|
22
|
+
const {colors} = useAppTheme();
|
|
23
|
+
const formatRelative = useRelativeTime(t);
|
|
24
|
+
const {isRTL} = useLanguage();
|
|
25
|
+
const statusColors = {
|
|
26
|
+
PENDING: colors.semantic.warning,
|
|
27
|
+
CONFIRMED: colors.semantic.success,
|
|
28
|
+
REJECTED: colors.semantic.error,
|
|
29
|
+
CANCELLED: colors.text.placeholder,
|
|
30
|
+
AWAITING_PICK_UP: colors.semantic.warning,
|
|
31
|
+
PICK_UP:colors.semantic.warning,
|
|
32
|
+
DROP_OFF:colors.semantic.warning,
|
|
33
|
+
EXPIRED: colors.text.placeholder,
|
|
34
|
+
};
|
|
13
35
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
const statusLabels = {
|
|
37
|
+
PENDING: t("request.status.PENDING"),
|
|
38
|
+
CONFIRMED: t("request.status.CONFIRMED"),
|
|
39
|
+
REJECTED: t("request.status.REJECTED"),
|
|
40
|
+
CANCELLED: t("request.status.CANCELLED"),
|
|
41
|
+
AWAITING_PICK_UP:t("request.status.AWAITING_PICK_UP"),
|
|
42
|
+
PICK_UP:t("request.status.PICK_UP"),
|
|
43
|
+
DROP_OFF:t("request.status.DROP_OFF"),
|
|
44
|
+
EXPIRED: t("request.status.EXPIRED")
|
|
45
|
+
};
|
|
46
|
+
const result = t("request.time.ago", { time: formatRelative(request.time) });
|
|
47
|
+
|
|
48
|
+
// const locationName = shortAddress(usePlaceName(request.location)); // [lat, lng]
|
|
49
|
+
// const destinationName =shortAddress(usePlaceName(request.destination));
|
|
50
|
+
const carStateText = request.carState
|
|
51
|
+
.map((s) => t(`request.carStateEnum.${s}`))
|
|
52
|
+
.join(" - ");
|
|
28
53
|
|
|
29
|
-
export default function RequestCard({
|
|
30
|
-
data, labels, statusLabel, statusColor, vehicleLabel, carStateText,
|
|
31
|
-
locationName, destinationName, agoText,
|
|
32
|
-
showCountdown = false, addRow = false, onExpire,
|
|
33
|
-
}: Props) {
|
|
34
|
-
const { colors } = useAppTheme();
|
|
35
|
-
const { isRTL } = useLanguage();
|
|
36
|
-
const rowDir = isRTL ? "row" : "row-reverse";
|
|
37
54
|
|
|
38
|
-
const deadline = new Date(
|
|
55
|
+
const deadline = new Date(request.time).getTime() + 2 * 60 * 1000;
|
|
39
56
|
|
|
40
57
|
return (
|
|
41
58
|
<View
|
|
@@ -43,56 +60,85 @@ export default function RequestCard({
|
|
|
43
60
|
backgroundColor: colors.background.card,
|
|
44
61
|
borderRadius: 15,
|
|
45
62
|
padding: 12,
|
|
63
|
+
// marginBottom: 0,
|
|
46
64
|
borderWidth: 1.5,
|
|
47
65
|
borderColor: colors.text.primary,
|
|
48
|
-
gap: 10
|
|
66
|
+
gap: 10
|
|
49
67
|
}}
|
|
50
68
|
>
|
|
51
|
-
|
|
52
|
-
<View style={{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
<View style={{gap: 5}}>
|
|
70
|
+
<View style={{
|
|
71
|
+
flexDirection: isRTL ?"row":"row-reverse",
|
|
72
|
+
justifyContent: "space-between",
|
|
73
|
+
}}>
|
|
74
|
+
<Text
|
|
75
|
+
style={{
|
|
76
|
+
fontSize: textSize.lg,
|
|
77
|
+
fontFamily: Fonts.montserrat.bold,
|
|
78
|
+
color: colors.text.primary,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{request.name}
|
|
82
|
+
</Text>
|
|
83
|
+
<View
|
|
57
84
|
style={{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
backgroundColor: statusColors[request.status] + "20",
|
|
86
|
+
paddingHorizontal: 10,
|
|
87
|
+
paddingVertical: 4,
|
|
88
|
+
borderRadius: 20,
|
|
62
89
|
}}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
>
|
|
91
|
+
<Text
|
|
92
|
+
style={{
|
|
93
|
+
fontSize: textSize.sm,
|
|
94
|
+
fontFamily: Fonts.montserrat.regular,
|
|
95
|
+
color: statusColors[request.status],
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{statusLabels[request.status]}
|
|
99
|
+
</Text>
|
|
100
|
+
</View>
|
|
68
101
|
</View>
|
|
69
|
-
|
|
70
102
|
{addRow && (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
103
|
+
<View style={{
|
|
104
|
+
flexDirection: isRTL ?"row":"row-reverse",
|
|
105
|
+
justifyContent: "space-between",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
}}>
|
|
108
|
+
<Text style={{
|
|
109
|
+
fontSize: textSize.xs,
|
|
110
|
+
fontFamily: Fonts.montserrat.regular,
|
|
111
|
+
color:colors.text.secondary
|
|
112
|
+
}}>
|
|
113
|
+
{request.phone} · {t(`request.vehicleType.${request.vehicleType}`)}
|
|
74
114
|
</Text>
|
|
75
|
-
{
|
|
76
|
-
<CircularCountdown deadline={deadline} onExpire={() => onExpire?.(
|
|
77
|
-
)
|
|
78
|
-
<View style={{
|
|
79
|
-
<View style={[isRTL
|
|
80
|
-
|
|
115
|
+
{request.status === "PENDING" ? (
|
|
116
|
+
<CircularCountdown deadline={deadline} onExpire={() => onExpire?.(request.id)}/>
|
|
117
|
+
):(
|
|
118
|
+
<View style={{flexDirection: isRTL ?"row":"row-reverse", alignItems: "center", gap: 4}}>
|
|
119
|
+
<View style={[isRTL && {transform :[{scaleX:-1}]}]}>
|
|
120
|
+
<Clock width={13} height={13} color={colors.text.placeholder} />
|
|
81
121
|
</View>
|
|
82
|
-
<Text
|
|
83
|
-
|
|
122
|
+
<Text
|
|
123
|
+
style={{
|
|
124
|
+
fontSize: textSize.xs,
|
|
125
|
+
fontFamily: Fonts.montserrat.regular,
|
|
126
|
+
color: colors.text.placeholder,
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
{result}
|
|
84
130
|
</Text>
|
|
85
|
-
|
|
131
|
+
</View>
|
|
86
132
|
)}
|
|
87
|
-
|
|
133
|
+
|
|
134
|
+
</View>
|
|
88
135
|
)}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<View
|
|
136
|
+
</View>
|
|
137
|
+
<CardRow icon={Destination} label={t("request.pickUp")} value={locationName}/>
|
|
138
|
+
<CardRow icon={Flag} label={t("request.destination")} value={destinationName}/>
|
|
139
|
+
<CardRow icon={Warning} label={t("request.carState")} value={carStateText}/>
|
|
140
|
+
<View style={{borderWidth:0.5, borderColor: colors.semantic.border}}/>
|
|
141
|
+
<View
|
|
96
142
|
style={{
|
|
97
143
|
flexDirection: isRTL ? "row" : "row-reverse",
|
|
98
144
|
justifyContent: "space-between",
|
|
@@ -106,7 +152,7 @@ export default function RequestCard({
|
|
|
106
152
|
fontFamily: Fonts.montserrat.regular,
|
|
107
153
|
}}
|
|
108
154
|
>
|
|
109
|
-
{
|
|
155
|
+
{t("request.total")}
|
|
110
156
|
</Text>
|
|
111
157
|
<Text
|
|
112
158
|
style={[
|
|
@@ -117,10 +163,10 @@ export default function RequestCard({
|
|
|
117
163
|
},
|
|
118
164
|
]}
|
|
119
165
|
>
|
|
120
|
-
{`${formatPrice(
|
|
166
|
+
{`${formatPrice(request.price)} ${t("request.price.unit")}`}
|
|
121
167
|
</Text>
|
|
122
168
|
</View>
|
|
123
|
-
|
|
169
|
+
</View>
|
|
124
170
|
);
|
|
125
171
|
}
|
|
126
172
|
|
|
@@ -128,7 +174,13 @@ function CardRow({ icon: Icon, label, value }: { icon: React.ComponentType<SvgPr
|
|
|
128
174
|
const { isRTL } = useLanguage();
|
|
129
175
|
const { colors } = useAppTheme();
|
|
130
176
|
return (
|
|
131
|
-
<View
|
|
177
|
+
<View
|
|
178
|
+
style={{
|
|
179
|
+
flexDirection: isRTL ? "row" : "row-reverse",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
gap: 10,
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
132
184
|
<View style={{ flexShrink: 0 }}>
|
|
133
185
|
<Icon color={colors.primary} width={20} height={20} />
|
|
134
186
|
</View>
|
package/src/index.ts
CHANGED
|
@@ -80,4 +80,4 @@ export {RouteInfo} from "./types/route";
|
|
|
80
80
|
export {default as PhonePrefix} from "./components/ui/phonePrefix";
|
|
81
81
|
export {default as ProfileScreen} from "./components/screens/profileScreen";
|
|
82
82
|
export { default as RequestCard } from "./components/ui/requestCard";
|
|
83
|
-
export {
|
|
83
|
+
export { Request, RequestStatus } from "./types/request";
|
package/src/types/request.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
carState: string;
|
|
15
|
-
total: string;
|
|
16
|
-
currency: string; // t("request.price.unit")
|
|
17
|
-
};
|
|
1
|
+
export type RequestStatus = "PENDING" | "CONFIRMED" | "REJECTED" | "CANCELLED" | "AWAITING_PICK_UP" | "PICK_UP" |"DROP_OFF" | "EXPIRED"
|
|
2
|
+
export type Request = {
|
|
3
|
+
id: string;
|
|
4
|
+
vehicleType: string;
|
|
5
|
+
name: string;
|
|
6
|
+
phone: string;
|
|
7
|
+
location: [number, number];
|
|
8
|
+
destination: [number, number];
|
|
9
|
+
status:RequestStatus;
|
|
10
|
+
price: number;
|
|
11
|
+
time: string;
|
|
12
|
+
carState:string[];
|
|
13
|
+
}
|