@hoddy-ui/core 1.0.81 → 1.0.83
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/StarRating.tsx +31 -29
- package/src/Components/Typography.tsx +2 -1
- package/src/types.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Ionicons } from "@expo/vector-icons";
|
|
2
2
|
import * as Haptics from "expo-haptics";
|
|
3
3
|
import { FC, useEffect, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ActivityIndicator,
|
|
6
|
+
TextInput,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
5
10
|
import { ScaledSheet } from "react-native-size-matters";
|
|
6
11
|
import { useColors } from "../hooks";
|
|
7
12
|
import { RatingInputProps, RatingStarsProps } from "../types";
|
|
@@ -41,7 +46,6 @@ export const RatingStars: FC<RatingStarsProps> = ({
|
|
|
41
46
|
export const RatingInput: FC<RatingInputProps> = ({
|
|
42
47
|
onSubmit: _onSubmit,
|
|
43
48
|
rating = 0,
|
|
44
|
-
noReview,
|
|
45
49
|
size = 16,
|
|
46
50
|
}) => {
|
|
47
51
|
const [showReviewsModal, setShowReviewsModal] = useState(false);
|
|
@@ -57,7 +61,7 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
57
61
|
inputCon: {
|
|
58
62
|
marginBottom: "20@vs",
|
|
59
63
|
backgroundColor: colors.white[3],
|
|
60
|
-
padding: "
|
|
64
|
+
padding: "15@ms",
|
|
61
65
|
borderRadius: 20,
|
|
62
66
|
},
|
|
63
67
|
input: {
|
|
@@ -67,10 +71,6 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
67
71
|
},
|
|
68
72
|
});
|
|
69
73
|
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (noReview && rate) onSubmit();
|
|
72
|
-
}, [rate, noReview]);
|
|
73
|
-
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
setRate(rating);
|
|
76
76
|
}, [rating]);
|
|
@@ -78,37 +78,40 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
78
78
|
setRate(index + 1);
|
|
79
79
|
Haptics.selectionAsync();
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, 500);
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
setShowReviewsModal(true);
|
|
83
|
+
}, 500);
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
const onSubmit = async () => {
|
|
88
87
|
setLoading(true);
|
|
89
|
-
_onSubmit && (await _onSubmit({ rating: rate, review }));
|
|
90
88
|
setShowReviewsModal(false);
|
|
89
|
+
_onSubmit && (await _onSubmit({ rating: rate, review }));
|
|
91
90
|
setLoading(false);
|
|
92
91
|
};
|
|
93
92
|
return (
|
|
94
93
|
<>
|
|
95
94
|
<View style={styles.root}>
|
|
96
|
-
{
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
{loading ? (
|
|
96
|
+
<ActivityIndicator />
|
|
97
|
+
) : (
|
|
98
|
+
[...Array(5)].map((_, index) => (
|
|
99
|
+
<TouchableOpacity
|
|
100
|
+
key={index}
|
|
101
|
+
activeOpacity={0.9}
|
|
102
|
+
onPress={() => {
|
|
103
|
+
onRate(index);
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<Ionicons
|
|
107
|
+
style={{ marginLeft: 10 }}
|
|
108
|
+
name={index < rate ? "star" : "star-outline"}
|
|
109
|
+
size={size}
|
|
110
|
+
color={colors.primary.light}
|
|
111
|
+
/>
|
|
112
|
+
</TouchableOpacity>
|
|
113
|
+
))
|
|
114
|
+
)}
|
|
112
115
|
</View>
|
|
113
116
|
<Popup
|
|
114
117
|
sheet
|
|
@@ -138,7 +141,6 @@ export const RatingInput: FC<RatingInputProps> = ({
|
|
|
138
141
|
<TextInput
|
|
139
142
|
style={styles.input}
|
|
140
143
|
multiline
|
|
141
|
-
placeholderTextColor={colors.textSecondary.main}
|
|
142
144
|
value={review}
|
|
143
145
|
onChangeText={(text) => setReview(text)}
|
|
144
146
|
placeholder="Type review here.."
|
|
@@ -16,7 +16,7 @@ const Typography: React.FC<TypographyProps> = ({
|
|
|
16
16
|
adjustsFontSizeToFit,
|
|
17
17
|
fontWeight = 400,
|
|
18
18
|
}) => {
|
|
19
|
-
const colors = useColors();
|
|
19
|
+
const colors: any = useColors();
|
|
20
20
|
const fontSize = {
|
|
21
21
|
h1: moderateScale(42),
|
|
22
22
|
h2: moderateScale(37),
|
|
@@ -50,4 +50,5 @@ const Typography: React.FC<TypographyProps> = ({
|
|
|
50
50
|
);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
<Typography color="#f90">col</Typography>;
|
|
53
54
|
export default Typography;
|
package/src/types.ts
CHANGED
|
@@ -254,7 +254,7 @@ export interface TextFieldProps extends TextInputProps {
|
|
|
254
254
|
|
|
255
255
|
export interface TypographyProps {
|
|
256
256
|
children: ReactNode;
|
|
257
|
-
color?: colorTypes &
|
|
257
|
+
color?: colorTypes | (string & {});
|
|
258
258
|
style?: TextStyle | ViewStyle;
|
|
259
259
|
textCase?: "capitalize" | "uppercase" | "lowercase" | null;
|
|
260
260
|
variant?:
|