@teamnhz/rn-ui-toolkit 1.0.1 → 1.0.3
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/README.md +3 -2
- package/dist/assets/images/ic_calendar.png +0 -0
- package/dist/assets/images/ic_time.png +0 -0
- package/dist/components/BottomSheet/index.js +58 -2
- package/dist/components/Buttons/index.d.ts +2 -2
- package/dist/components/Buttons/index.js +102 -11
- package/dist/components/CheckBox/index.d.ts +2 -2
- package/dist/components/CheckBox/index.js +112 -15
- package/dist/components/DateTimePicker/index.d.ts +25 -3
- package/dist/components/DateTimePicker/index.js +248 -22
- package/dist/components/Dividers/index.d.ts +3 -3
- package/dist/components/Dividers/index.js +41 -5
- package/dist/components/HorizontalFlatList/index.d.ts +2 -2
- package/dist/components/HorizontalFlatList/index.js +47 -8
- package/dist/components/Image/index.d.ts +2 -4
- package/dist/components/Image/index.js +22 -4
- package/dist/components/ImagePicker/index.d.ts +8 -1
- package/dist/components/ImagePicker/index.js +154 -18
- package/dist/components/Input/index.d.ts +17 -3
- package/dist/components/Input/index.js +302 -19
- package/dist/components/KeyboardScroll/index.d.ts +3 -0
- package/dist/components/KeyboardScroll/index.js +76 -0
- package/dist/components/Modal/index.d.ts +2 -2
- package/dist/components/Modal/index.js +31 -3
- package/dist/components/Switch/index.d.ts +13 -3
- package/dist/components/Switch/index.js +93 -12
- package/dist/components/T/index.d.ts +5 -4
- package/dist/components/T/index.js +69 -10
- package/dist/components/Toast/index.js +123 -3
- package/dist/components/VerticalFlatList/index.d.ts +2 -2
- package/dist/components/VerticalFlatList/index.js +22 -5
- package/dist/components/index.d.ts +29 -29
- package/dist/components/index.js +29 -29
- package/dist/styles/colors.d.ts +1 -0
- package/dist/styles/colors.js +30 -29
- package/dist/styles/images.d.ts +2 -0
- package/dist/styles/images.js +5 -1
- package/package.json +20 -16
- package/dist/components/ScrolledContainer/index.d.ts +0 -13
- package/dist/components/ScrolledContainer/index.js +0 -30
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { View, TouchableOpacity, Text, StyleSheet } from
|
|
3
|
-
import DatePicker from
|
|
4
|
-
import { useTranslation } from
|
|
5
|
-
import { Colors, Scale, Typography } from
|
|
6
|
-
const DateTimePicker = ({ value, onChange, label, intlType, mode =
|
|
7
|
-
const { t } = useTranslation([
|
|
8
|
-
const
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { View, TouchableOpacity, Text, StyleSheet, Image, } from "react-native";
|
|
3
|
+
import DatePicker from "react-native-date-picker";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { Colors, Scale, Typography, Images } from "../../styles";
|
|
6
|
+
const DateTimePicker = ({ value, onChange, label, placeholder, intlType, mode = "date", disabled = false, minimumDate, maximumDate, modal = true, confirmText, cancelText, containerStyle, pickerContainerStyle, labelStyle, textStyle, leftImageStyle, rightImageStyle, leftIcon, rightIcon, leftIconShow, onCancel, error, errorTextStyle, }) => {
|
|
7
|
+
const { t } = useTranslation(["common", "validation", "address", "sell"]);
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
/** default icons based on mode */
|
|
10
|
+
const defaultLeftIcon = mode === "time"
|
|
11
|
+
? Images.ic_time // ⏰ your clock asset
|
|
12
|
+
: Images.ic_calendar; // 📅 your calendar asset
|
|
13
|
+
const getTranslatedLabel = () => {
|
|
9
14
|
if (intlType) {
|
|
10
15
|
const translated = t(label, { ns: intlType });
|
|
11
16
|
if (translated !== label)
|
|
@@ -13,38 +18,259 @@ const DateTimePicker = ({ value, onChange, label, intlType, mode = 'date', disab
|
|
|
13
18
|
}
|
|
14
19
|
return label;
|
|
15
20
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
React.createElement(TouchableOpacity, { style:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
return (React.createElement(View, { style: containerStyle },
|
|
22
|
+
label ? (React.createElement(Text, { style: [styles.label, labelStyle] }, getTranslatedLabel())) : null,
|
|
23
|
+
React.createElement(TouchableOpacity, { style: [
|
|
24
|
+
styles.button,
|
|
25
|
+
pickerContainerStyle,
|
|
26
|
+
disabled && { backgroundColor: Colors.disabledGrey, borderWidth: 0 },
|
|
27
|
+
], disabled: disabled, onPress: () => setOpen(true) },
|
|
28
|
+
leftIconShow && (React.createElement(Image, { source: leftIcon || defaultLeftIcon, style: [styles.icon, leftImageStyle] })),
|
|
29
|
+
React.createElement(Text, { style: [styles.text, textStyle, !value && { color: Colors.textGrey }], numberOfLines: 1 }, value ? formatValue(value, mode) : placeholder || "Select"),
|
|
30
|
+
rightIcon && (React.createElement(Image, { source: rightIcon, style: [styles.icon, rightImageStyle] }))),
|
|
31
|
+
typeof error === "string" && error.length > 0 && (React.createElement(Text, { style: [styles.errorText, errorTextStyle] }, error)),
|
|
32
|
+
React.createElement(DatePicker, { modal: modal, open: open, date: value || new Date(), mode: mode, minimumDate: minimumDate, maximumDate: maximumDate, confirmText: confirmText, cancelText: cancelText, onConfirm: (val) => {
|
|
21
33
|
setOpen(false);
|
|
22
34
|
onChange(val);
|
|
23
|
-
}, onCancel: () =>
|
|
35
|
+
}, onCancel: () => {
|
|
36
|
+
setOpen(false);
|
|
37
|
+
onCancel && onCancel();
|
|
38
|
+
} })));
|
|
24
39
|
};
|
|
25
40
|
const formatValue = (date, mode) => {
|
|
26
41
|
try {
|
|
27
42
|
switch (mode) {
|
|
28
|
-
case
|
|
29
|
-
return date.toLocaleTimeString(
|
|
30
|
-
|
|
43
|
+
case "time":
|
|
44
|
+
return date.toLocaleTimeString([], {
|
|
45
|
+
hour: "2-digit",
|
|
46
|
+
minute: "2-digit",
|
|
47
|
+
});
|
|
48
|
+
case "datetime":
|
|
31
49
|
return date.toLocaleString();
|
|
32
50
|
default:
|
|
33
51
|
return date.toLocaleDateString();
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
54
|
catch {
|
|
37
|
-
return
|
|
55
|
+
return "";
|
|
38
56
|
}
|
|
39
57
|
};
|
|
40
58
|
const styles = StyleSheet.create({
|
|
41
|
-
|
|
59
|
+
label: {
|
|
60
|
+
...Typography.style.standardU(),
|
|
61
|
+
color: Colors.textColor,
|
|
62
|
+
marginBottom: Scale.moderateScale(8),
|
|
63
|
+
},
|
|
42
64
|
button: {
|
|
43
65
|
borderWidth: 1,
|
|
44
66
|
borderColor: Colors.primaryColor,
|
|
45
|
-
borderRadius:
|
|
46
|
-
|
|
67
|
+
borderRadius: Scale.moderateScale(6),
|
|
68
|
+
paddingVertical: Scale.moderateScale(12),
|
|
69
|
+
paddingHorizontal: Scale.moderateScale(10),
|
|
70
|
+
flexDirection: "row",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
},
|
|
73
|
+
text: {
|
|
74
|
+
flex: 1,
|
|
75
|
+
...Typography.style.standardU(),
|
|
76
|
+
color: Colors.textColor,
|
|
77
|
+
textTransform: "none",
|
|
78
|
+
},
|
|
79
|
+
icon: {
|
|
80
|
+
width: Scale.moderateScale(20),
|
|
81
|
+
height: Scale.moderateScale(20),
|
|
82
|
+
resizeMode: "contain",
|
|
83
|
+
},
|
|
84
|
+
errorText: {
|
|
85
|
+
color: Colors.dangerRed,
|
|
86
|
+
fontSize: Scale.moderateScale(12),
|
|
87
|
+
marginTop: 3,
|
|
47
88
|
},
|
|
48
|
-
text: { ...Typography.style.standardU(), color: Colors.primaryColor },
|
|
49
89
|
});
|
|
50
90
|
export default DateTimePicker;
|
|
91
|
+
// import React, { useState } from 'react';
|
|
92
|
+
// import {
|
|
93
|
+
// View,
|
|
94
|
+
// TouchableOpacity,
|
|
95
|
+
// Text,
|
|
96
|
+
// StyleSheet,
|
|
97
|
+
// Image,
|
|
98
|
+
// ImageSourcePropType,
|
|
99
|
+
// StyleProp,
|
|
100
|
+
// TextStyle,
|
|
101
|
+
// ViewStyle,
|
|
102
|
+
// ImageStyle,
|
|
103
|
+
// } from 'react-native';
|
|
104
|
+
// import DatePicker from 'react-native-date-picker';
|
|
105
|
+
// import { useTranslation } from 'react-i18next';
|
|
106
|
+
// import { Colors, Scale, Typography, Images } from '../../styles';
|
|
107
|
+
// interface DateTimePickerProps {
|
|
108
|
+
// value: Date | null;
|
|
109
|
+
// onChange: (date: Date) => void;
|
|
110
|
+
// label?: string;
|
|
111
|
+
// placeholder?: string;
|
|
112
|
+
// intlType?: string;
|
|
113
|
+
// mode?: 'date' | 'time' | 'datetime';
|
|
114
|
+
// disabled?: boolean;
|
|
115
|
+
// /** raw DatePicker props */
|
|
116
|
+
// minimumDate?: Date;
|
|
117
|
+
// maximumDate?: Date;
|
|
118
|
+
// modal?: boolean;
|
|
119
|
+
// confirmText?: string;
|
|
120
|
+
// cancelText?: string;
|
|
121
|
+
// /** style overrides */
|
|
122
|
+
// containerStyle?: StyleProp<ViewStyle>;
|
|
123
|
+
// pickerContainerStyle?: StyleProp<ViewStyle>;
|
|
124
|
+
// labelStyle?: StyleProp<TextStyle>;
|
|
125
|
+
// textStyle?: StyleProp<TextStyle>;
|
|
126
|
+
// leftImageStyle?: StyleProp<ImageStyle>;
|
|
127
|
+
// rightImageStyle?: StyleProp<ImageStyle>;
|
|
128
|
+
// /** icons */
|
|
129
|
+
// leftIcon?: ImageSourcePropType;
|
|
130
|
+
// rightIcon?: ImageSourcePropType;
|
|
131
|
+
// leftIconShow?: boolean;
|
|
132
|
+
// onCancel?: () => void;
|
|
133
|
+
// }
|
|
134
|
+
// const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
135
|
+
// value,
|
|
136
|
+
// onChange,
|
|
137
|
+
// label,
|
|
138
|
+
// placeholder,
|
|
139
|
+
// intlType,
|
|
140
|
+
// mode = 'date',
|
|
141
|
+
// disabled = false,
|
|
142
|
+
// minimumDate,
|
|
143
|
+
// maximumDate,
|
|
144
|
+
// modal = true,
|
|
145
|
+
// confirmText,
|
|
146
|
+
// cancelText,
|
|
147
|
+
// containerStyle,
|
|
148
|
+
// pickerContainerStyle,
|
|
149
|
+
// labelStyle,
|
|
150
|
+
// textStyle,
|
|
151
|
+
// leftImageStyle,
|
|
152
|
+
// rightImageStyle,
|
|
153
|
+
// leftIcon,
|
|
154
|
+
// rightIcon,
|
|
155
|
+
// leftIconShow,
|
|
156
|
+
// onCancel,
|
|
157
|
+
// }) => {
|
|
158
|
+
// const { t } = useTranslation(['common', 'validation', 'address', 'sell']);
|
|
159
|
+
// const [open, setOpen] = useState(false);
|
|
160
|
+
// /** default icons based on mode */
|
|
161
|
+
// const defaultLeftIcon =
|
|
162
|
+
// mode === 'time'
|
|
163
|
+
// ? Images.ic_time // ⏰ your clock asset
|
|
164
|
+
// : Images.ic_calendar; // 📅 your calendar asset
|
|
165
|
+
// const getTranslatedLabel = () => {
|
|
166
|
+
// if (intlType) {
|
|
167
|
+
// const translated = t(label, { ns: intlType });
|
|
168
|
+
// if (translated !== label) return translated;
|
|
169
|
+
// }
|
|
170
|
+
// return label;
|
|
171
|
+
// };
|
|
172
|
+
// return (
|
|
173
|
+
// <View style={[styles.container, containerStyle]}>
|
|
174
|
+
// {/* Top label */}
|
|
175
|
+
// {label ? (
|
|
176
|
+
// <Text style={[styles.label, labelStyle]}>{getTranslatedLabel()}</Text>
|
|
177
|
+
// ) : null}
|
|
178
|
+
// <TouchableOpacity
|
|
179
|
+
// style={[
|
|
180
|
+
// styles.button,
|
|
181
|
+
// pickerContainerStyle,
|
|
182
|
+
// disabled && { backgroundColor: Colors.disabledGrey, borderWidth: 0 },
|
|
183
|
+
// ]}
|
|
184
|
+
// disabled={disabled}
|
|
185
|
+
// onPress={() => setOpen(true)}
|
|
186
|
+
// >
|
|
187
|
+
// {/* Left icon */}
|
|
188
|
+
// {leftIconShow &&
|
|
189
|
+
// <Image
|
|
190
|
+
// source={leftIcon || defaultLeftIcon}
|
|
191
|
+
// style={[styles.icon, leftImageStyle]}
|
|
192
|
+
// />}
|
|
193
|
+
// {/* Text / Placeholder */}
|
|
194
|
+
// <Text
|
|
195
|
+
// style={[
|
|
196
|
+
// styles.text,
|
|
197
|
+
// textStyle,
|
|
198
|
+
// !value && { color: Colors.textGrey },
|
|
199
|
+
// ]}
|
|
200
|
+
// numberOfLines={1}
|
|
201
|
+
// >
|
|
202
|
+
// {value ? formatValue(value, mode) : placeholder || 'Select'}
|
|
203
|
+
// </Text>
|
|
204
|
+
// {/* Right icon (mandatory) */}
|
|
205
|
+
// {rightIcon &&
|
|
206
|
+
// <Image
|
|
207
|
+
// source={rightIcon}
|
|
208
|
+
// style={[styles.icon, rightImageStyle]}
|
|
209
|
+
// />}
|
|
210
|
+
// </TouchableOpacity>
|
|
211
|
+
// <DatePicker
|
|
212
|
+
// modal={modal}
|
|
213
|
+
// open={open}
|
|
214
|
+
// date={value || new Date()}
|
|
215
|
+
// mode={mode}
|
|
216
|
+
// minimumDate={minimumDate}
|
|
217
|
+
// maximumDate={maximumDate}
|
|
218
|
+
// confirmText={confirmText}
|
|
219
|
+
// cancelText={cancelText}
|
|
220
|
+
// onConfirm={(val) => {
|
|
221
|
+
// setOpen(false);
|
|
222
|
+
// onChange(val);
|
|
223
|
+
// }}
|
|
224
|
+
// onCancel={() => {
|
|
225
|
+
// setOpen(false);
|
|
226
|
+
// onCancel && onCancel();
|
|
227
|
+
// }}
|
|
228
|
+
// />
|
|
229
|
+
// </View>
|
|
230
|
+
// );
|
|
231
|
+
// };
|
|
232
|
+
// const formatValue = (date: Date, mode: 'date' | 'time' | 'datetime') => {
|
|
233
|
+
// try {
|
|
234
|
+
// switch (mode) {
|
|
235
|
+
// case 'time':
|
|
236
|
+
// return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
237
|
+
// case 'datetime':
|
|
238
|
+
// return date.toLocaleString();
|
|
239
|
+
// default:
|
|
240
|
+
// return date.toLocaleDateString();
|
|
241
|
+
// }
|
|
242
|
+
// } catch {
|
|
243
|
+
// return '';
|
|
244
|
+
// }
|
|
245
|
+
// };
|
|
246
|
+
// const styles = StyleSheet.create({
|
|
247
|
+
// container: {
|
|
248
|
+
// marginVertical: Scale.moderateScale(8),
|
|
249
|
+
// },
|
|
250
|
+
// label: {
|
|
251
|
+
// ...Typography.style.standardU(),
|
|
252
|
+
// color: Colors.textColor,
|
|
253
|
+
// marginBottom: Scale.moderateScale(8),
|
|
254
|
+
// },
|
|
255
|
+
// button: {
|
|
256
|
+
// borderWidth: 1,
|
|
257
|
+
// borderColor: Colors.primaryColor,
|
|
258
|
+
// borderRadius: Scale.moderateScale(6),
|
|
259
|
+
// paddingVertical: Scale.moderateScale(12),
|
|
260
|
+
// paddingHorizontal: Scale.moderateScale(10),
|
|
261
|
+
// flexDirection: 'row',
|
|
262
|
+
// alignItems: 'center',
|
|
263
|
+
// },
|
|
264
|
+
// text: {
|
|
265
|
+
// flex: 1,
|
|
266
|
+
// ...Typography.style.standardU(),
|
|
267
|
+
// color: Colors.textColor,
|
|
268
|
+
// textTransform: "none",
|
|
269
|
+
// },
|
|
270
|
+
// icon: {
|
|
271
|
+
// width: Scale.moderateScale(20),
|
|
272
|
+
// height: Scale.moderateScale(20),
|
|
273
|
+
// resizeMode: 'contain',
|
|
274
|
+
// },
|
|
275
|
+
// });
|
|
276
|
+
// export default DateTimePicker;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { ViewStyle } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
3
|
type DividerProps = {
|
|
4
4
|
small?: boolean;
|
|
5
5
|
disableMargin?: boolean;
|
|
6
6
|
marginStyle?: ViewStyle;
|
|
7
7
|
};
|
|
8
|
-
declare const Dividers: ({ small, disableMargin, marginStyle
|
|
8
|
+
declare const Dividers: ({ small, disableMargin, marginStyle }: DividerProps) => React.JSX.Element;
|
|
9
9
|
export default Dividers;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { StyleSheet } from
|
|
3
|
-
import { Divider } from
|
|
4
|
-
import { Colors, Scale } from
|
|
5
|
-
const Dividers = ({ small, disableMargin, marginStyle
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { Divider } from "react-native-elements";
|
|
4
|
+
import { Colors, Scale } from "../../styles";
|
|
5
|
+
const Dividers = ({ small, disableMargin, marginStyle }) => (React.createElement(Divider, { style: [
|
|
6
6
|
small ? styles.dividerStyleSmall : styles.dividerStyleBig,
|
|
7
7
|
!disableMargin ? styles.verticalMargin : null,
|
|
8
8
|
marginStyle,
|
|
@@ -21,3 +21,39 @@ const styles = StyleSheet.create({
|
|
|
21
21
|
marginVertical: Scale?.moderateScale(20),
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
|
+
// import React from 'react';
|
|
25
|
+
// import { StyleSheet, ViewStyle } from 'react-native';
|
|
26
|
+
// import { Divider } from 'react-native-elements';
|
|
27
|
+
// import { Colors, Scale } from '../../styles';
|
|
28
|
+
// type DividerProps = {
|
|
29
|
+
// small?: boolean;
|
|
30
|
+
// disableMargin?: boolean;
|
|
31
|
+
// marginStyle?: ViewStyle;
|
|
32
|
+
// };
|
|
33
|
+
// const Dividers = ({
|
|
34
|
+
// small,
|
|
35
|
+
// disableMargin,
|
|
36
|
+
// marginStyle,
|
|
37
|
+
// }: DividerProps) => (
|
|
38
|
+
// <Divider
|
|
39
|
+
// style={[
|
|
40
|
+
// small ? styles.dividerStyleSmall : styles.dividerStyleBig,
|
|
41
|
+
// !disableMargin ? styles.verticalMargin : null,
|
|
42
|
+
// marginStyle,
|
|
43
|
+
// ]}
|
|
44
|
+
// />
|
|
45
|
+
// );
|
|
46
|
+
// export default Dividers;
|
|
47
|
+
// const styles = StyleSheet.create({
|
|
48
|
+
// dividerStyleBig: {
|
|
49
|
+
// backgroundColor: Colors.lightGrey,
|
|
50
|
+
// height: Scale?.moderateScale(10),
|
|
51
|
+
// },
|
|
52
|
+
// dividerStyleSmall: {
|
|
53
|
+
// backgroundColor: Colors.lightGrey,
|
|
54
|
+
// height: 1,
|
|
55
|
+
// },
|
|
56
|
+
// verticalMargin: {
|
|
57
|
+
// marginVertical: Scale?.moderateScale(20),
|
|
58
|
+
// },
|
|
59
|
+
// });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { FlatListProps } from "react-native";
|
|
2
|
+
import { FlatList, FlatListProps } from "react-native";
|
|
3
3
|
interface HorizontalFlatListProps<ItemT> extends Omit<FlatListProps<ItemT>, "horizontal" | "renderItem"> {
|
|
4
4
|
spacing?: number;
|
|
5
5
|
renderItem: ({ item }: {
|
|
6
6
|
item: ItemT;
|
|
7
7
|
}) => React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare const HorizontalFlatList: <
|
|
9
|
+
declare const HorizontalFlatList: React.ForwardRefExoticComponent<HorizontalFlatListProps<unknown> & React.RefAttributes<FlatList<unknown>>>;
|
|
10
10
|
export default HorizontalFlatList;
|
|
@@ -1,14 +1,53 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FlatList, View, StyleSheet } from "react-native";
|
|
3
|
-
const HorizontalFlatList = ({ spacing = 10, renderItem, ...props }) => {
|
|
4
|
-
return (React.createElement(FlatList, { ...props, horizontal: true, showsHorizontalScrollIndicator: props.showsHorizontalScrollIndicator, keyExtractor: (item, index) => item
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { FlatList, View, StyleSheet, } from "react-native";
|
|
3
|
+
const HorizontalFlatList = forwardRef(({ spacing = 10, renderItem, ...props }, ref) => {
|
|
4
|
+
return (React.createElement(FlatList, { ...props, ref: ref, horizontal: true, showsHorizontalScrollIndicator: props.showsHorizontalScrollIndicator ?? false, keyExtractor: (item, index) => item?.id?.toString() || index.toString(), renderItem: ({ item, index }) => (React.createElement(View, { style: [
|
|
5
5
|
styles.box,
|
|
6
|
-
{
|
|
6
|
+
{
|
|
7
|
+
marginRight: index === (props.data?.length ?? 0) - 1 ? 0 : spacing,
|
|
8
|
+
},
|
|
7
9
|
] }, renderItem({ item }))) }));
|
|
8
|
-
};
|
|
10
|
+
});
|
|
11
|
+
export default HorizontalFlatList;
|
|
9
12
|
const styles = StyleSheet.create({
|
|
10
13
|
box: {
|
|
11
|
-
flex: 1
|
|
14
|
+
flex: 1,
|
|
12
15
|
},
|
|
13
16
|
});
|
|
14
|
-
|
|
17
|
+
// import React from "react";
|
|
18
|
+
// import { FlatList, FlatListProps, View, StyleSheet } from "react-native";
|
|
19
|
+
// import { Colors, Scale } from "../../styles"; // ✅ using your custom styles
|
|
20
|
+
// interface HorizontalFlatListProps<ItemT>
|
|
21
|
+
// extends Omit<FlatListProps<ItemT>, "horizontal" | "renderItem"> {
|
|
22
|
+
// spacing?: number;
|
|
23
|
+
// renderItem: ({ item }: { item: ItemT }) => React.ReactNode;
|
|
24
|
+
// }
|
|
25
|
+
// const HorizontalFlatList = <ItemT,>({
|
|
26
|
+
// spacing = 10,
|
|
27
|
+
// renderItem,
|
|
28
|
+
// ...props
|
|
29
|
+
// }: HorizontalFlatListProps<ItemT>) => {
|
|
30
|
+
// return (
|
|
31
|
+
// <FlatList
|
|
32
|
+
// {...props}
|
|
33
|
+
// horizontal
|
|
34
|
+
// showsHorizontalScrollIndicator={props.showsHorizontalScrollIndicator}
|
|
35
|
+
// keyExtractor={(item: any, index) => item.id?.toString() || index.toString()}
|
|
36
|
+
// renderItem={({ item, index }) => (
|
|
37
|
+
// <View
|
|
38
|
+
// style={[
|
|
39
|
+
// styles.box,
|
|
40
|
+
// { marginRight: index === (props.data?.length ?? 0) - 1 ? 0 : spacing },
|
|
41
|
+
// ]}
|
|
42
|
+
// >
|
|
43
|
+
// {renderItem({ item })}
|
|
44
|
+
// </View>
|
|
45
|
+
// )}
|
|
46
|
+
// />
|
|
47
|
+
// );
|
|
48
|
+
// };
|
|
49
|
+
// const styles = StyleSheet.create({
|
|
50
|
+
// box: {
|
|
51
|
+
// flex:1},
|
|
52
|
+
// });
|
|
53
|
+
// export default HorizontalFlatList;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { ActivityIndicator } from "react-native";
|
|
3
|
+
import FastImage from "react-native-fast-image";
|
|
4
|
+
const Image = (props) => {
|
|
5
|
+
const [loading, setLoading] = useState(true);
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(FastImage, { ...props, onLoadStart: () => {
|
|
8
|
+
setLoading(true);
|
|
9
|
+
}, onLoadEnd: () => {
|
|
10
|
+
setLoading(false);
|
|
11
|
+
}, resizeMode: props.resizeMode }, loading ? (React.createElement(ActivityIndicator, { style: {
|
|
12
|
+
position: "absolute",
|
|
13
|
+
alignSelf: "center",
|
|
14
|
+
top: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
}, size: props.loaderSize || "small", color: props.loaderColor || "#919191" })) : null)));
|
|
5
17
|
};
|
|
6
18
|
export default Image;
|
|
19
|
+
// import React from 'react';
|
|
20
|
+
// import FastImage from 'react-native-fast-image';
|
|
21
|
+
// const Image = ({ ...props }) => {
|
|
22
|
+
// return <FastImage {...props} />;
|
|
23
|
+
// };
|
|
24
|
+
// export default Image;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { ViewStyle, TextStyle, ImageStyle } from "react-native";
|
|
3
|
+
type StyleProps = {
|
|
4
|
+
containerStyle?: ViewStyle;
|
|
5
|
+
rowStyle?: ViewStyle;
|
|
6
|
+
textStyle?: TextStyle;
|
|
7
|
+
iconStyle?: ImageStyle;
|
|
8
|
+
};
|
|
2
9
|
type Props = {
|
|
3
10
|
mediaType: "photo" | "video";
|
|
4
11
|
isMultiSelect?: boolean;
|
|
5
12
|
onSuccess: (data: any) => void;
|
|
6
13
|
visible: boolean;
|
|
7
14
|
onClose: () => void;
|
|
8
|
-
};
|
|
15
|
+
} & StyleProps;
|
|
9
16
|
declare const ImagePicker: React.FC<Props>;
|
|
10
17
|
export default ImagePicker;
|