@hoddy-ui/core 1.0.45 → 1.0.47
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/index.ts +1 -0
- package/package.json +2 -1
- package/src/Components/Popup.tsx +1 -1
- package/src/Components/StarRating.tsx +12 -35
- package/src/types.ts +1 -0
package/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { default as Button } from "./src/Components/Button";
|
|
|
10
10
|
export * from "./src/Components/Checkbox";
|
|
11
11
|
export * from "./src/Components/FlashMessage";
|
|
12
12
|
export * from "./src/Components/FormWrapper";
|
|
13
|
+
export * from "./src/Components/StarRating";
|
|
13
14
|
export * from "./src/Components/Grid";
|
|
14
15
|
export * from "./src/Components/Locator";
|
|
15
16
|
export * from "./src/Components/Popup";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoddy-ui/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "Core rich react native components written in typescript",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@react-navigation/native": ">=6.1.7",
|
|
17
17
|
"@types/react": "^18.2.6",
|
|
18
18
|
"@types/react-native": "^0.72.0",
|
|
19
|
+
"expo-haptics": "^12.6.0",
|
|
19
20
|
"expo-location": ">=15.1.1",
|
|
20
21
|
"expo-navigation-bar": ">=2.1.1",
|
|
21
22
|
"expo-system-ui": ">=2.2.1",
|
package/src/Components/Popup.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
22
22
|
container: {
|
|
23
23
|
marginTop: sheet ? "auto" : "50%",
|
|
24
24
|
paddingBottom: sheet ? "30@ms" : 0,
|
|
25
|
-
minHeight: sheet,
|
|
25
|
+
minHeight: typeof sheet === "number" ? sheet : undefined,
|
|
26
26
|
maxHeight: "80%",
|
|
27
27
|
backgroundColor: colors.white[2],
|
|
28
28
|
borderTopLeftRadius: 20,
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Ionicons } from "@expo/vector-icons";
|
|
2
2
|
import * as Haptics from "expo-haptics";
|
|
3
|
-
import { FC,
|
|
4
|
-
import {
|
|
5
|
-
import { TextInput } from "react-native-gesture-handler";
|
|
3
|
+
import { FC, useEffect, useState } from "react";
|
|
4
|
+
import { TextInput, TouchableOpacity, View } from "react-native";
|
|
6
5
|
import { ScaledSheet } from "react-native-size-matters";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import { useColors } from "../hooks";
|
|
7
|
+
import { RatingInputProps, RatingStarsProps } from "../types";
|
|
9
8
|
import Button from "./Button";
|
|
10
|
-
import Popup from "./Popup";
|
|
9
|
+
import { Popup } from "./Popup";
|
|
11
10
|
import Typography from "./Typography";
|
|
12
|
-
import { errorMessage } from "../../utility";
|
|
13
|
-
import client from "../../api/client";
|
|
14
|
-
import { useColors } from "../hooks";
|
|
15
|
-
import { RatingInputProps, RatingStarsProps, StarRatingProps } from "../types";
|
|
16
11
|
|
|
17
12
|
export const RatingStars: FC<RatingStarsProps> = ({
|
|
18
13
|
rating = 0,
|
|
@@ -45,13 +40,12 @@ export const RatingStars: FC<RatingStarsProps> = ({
|
|
|
45
40
|
|
|
46
41
|
export const RatingInput: FC<RatingInputProps> = ({
|
|
47
42
|
onSubmit: _onSubmit,
|
|
48
|
-
_id,
|
|
49
43
|
rating = 0,
|
|
50
44
|
size = 16,
|
|
51
45
|
}) => {
|
|
52
|
-
const { themeState } = useContext(GlobalContext);
|
|
53
46
|
const [showReviewsModal, setShowReviewsModal] = useState(false);
|
|
54
47
|
const [rate, setRate] = useState(0);
|
|
48
|
+
const colors = useColors();
|
|
55
49
|
const [loading, setLoading] = useState(false);
|
|
56
50
|
const [review, setReview] = useState("");
|
|
57
51
|
const styles = ScaledSheet.create({
|
|
@@ -61,13 +55,13 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
61
55
|
},
|
|
62
56
|
inputCon: {
|
|
63
57
|
marginBottom: "20@vs",
|
|
64
|
-
backgroundColor: colors
|
|
58
|
+
backgroundColor: colors.white[3],
|
|
65
59
|
padding: "15@ms",
|
|
66
60
|
borderRadius: 20,
|
|
67
61
|
},
|
|
68
62
|
input: {
|
|
69
63
|
fontSize: "16@ms",
|
|
70
|
-
color: colors
|
|
64
|
+
color: colors.dark.main,
|
|
71
65
|
height: "100@vs",
|
|
72
66
|
},
|
|
73
67
|
});
|
|
@@ -75,7 +69,7 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
75
69
|
useEffect(() => {
|
|
76
70
|
setRate(rating);
|
|
77
71
|
}, [rating]);
|
|
78
|
-
const onRate = (index) => {
|
|
72
|
+
const onRate = (index: number) => {
|
|
79
73
|
setRate(index + 1);
|
|
80
74
|
Haptics.selectionAsync();
|
|
81
75
|
|
|
@@ -86,23 +80,7 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
86
80
|
|
|
87
81
|
const onSubmit = async () => {
|
|
88
82
|
setLoading(true);
|
|
89
|
-
|
|
90
|
-
const res = (
|
|
91
|
-
await client.post("customer/review/product", {
|
|
92
|
-
rate,
|
|
93
|
-
review,
|
|
94
|
-
productId: _id,
|
|
95
|
-
})
|
|
96
|
-
).data;
|
|
97
|
-
|
|
98
|
-
console.log("R", res);
|
|
99
|
-
_onSubmit(res.data);
|
|
100
|
-
setShowReviewsModal(false);
|
|
101
|
-
Alert.alert("Review received", "Thank you for your review");
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.log("Couldn't add review", errorMessage(error));
|
|
104
|
-
Alert.alert("couldn't add review", errorMessage(error));
|
|
105
|
-
}
|
|
83
|
+
await _onSubmit({ rating: rate, review });
|
|
106
84
|
setLoading(false);
|
|
107
85
|
};
|
|
108
86
|
return (
|
|
@@ -120,14 +98,13 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
120
98
|
style={{ marginLeft: 10 }}
|
|
121
99
|
name={index < rate ? "star" : "star-outline"}
|
|
122
100
|
size={size}
|
|
123
|
-
color={colors
|
|
101
|
+
color={colors.primary.light}
|
|
124
102
|
/>
|
|
125
103
|
</TouchableOpacity>
|
|
126
104
|
))}
|
|
127
105
|
</View>
|
|
128
106
|
<Popup
|
|
129
107
|
sheet
|
|
130
|
-
port
|
|
131
108
|
open={showReviewsModal}
|
|
132
109
|
onClose={() => {
|
|
133
110
|
setShowReviewsModal(false);
|
|
@@ -139,7 +116,7 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
139
116
|
marginBottom: 5,
|
|
140
117
|
}}
|
|
141
118
|
>
|
|
142
|
-
<
|
|
119
|
+
<RatingStars rating={rate} size={24} />
|
|
143
120
|
</View>
|
|
144
121
|
<Typography
|
|
145
122
|
align="center"
|