@teamnhz/rn-ui-toolkit 1.3.3 → 1.3.4
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.
|
@@ -1,584 +1,3 @@
|
|
|
1
|
-
// // import React, { useCallback } from "react";
|
|
2
|
-
// // import {
|
|
3
|
-
// // View,
|
|
4
|
-
// // Text,
|
|
5
|
-
// // TouchableOpacity,
|
|
6
|
-
// // StyleSheet,
|
|
7
|
-
// // Image,
|
|
8
|
-
// // Alert,
|
|
9
|
-
// // ViewStyle,
|
|
10
|
-
// // TextStyle,
|
|
11
|
-
// // ImageStyle,
|
|
12
|
-
// // } from "react-native";
|
|
13
|
-
// // import { BottomSheet, Dividers } from "../index";
|
|
14
|
-
// // import { launchCamera, launchImageLibrary } from "react-native-image-picker";
|
|
15
|
-
// // import ImageCropPicker from "react-native-image-crop-picker";
|
|
16
|
-
// // import { Colors, Images, Scale, Typography } from "../../styles";
|
|
17
|
-
// // type StyleProps = {
|
|
18
|
-
// // containerStyle?: ViewStyle;
|
|
19
|
-
// // rowStyle?: ViewStyle;
|
|
20
|
-
// // textStyle?: TextStyle;
|
|
21
|
-
// // iconStyle?: ImageStyle;
|
|
22
|
-
// // };
|
|
23
|
-
// // type Props = {
|
|
24
|
-
// // mediaType: "photo" | "video";
|
|
25
|
-
// // isMultiSelect?: boolean;
|
|
26
|
-
// // onSuccess: (data: any) => void;
|
|
27
|
-
// // visible: boolean;
|
|
28
|
-
// // onClose: () => void;
|
|
29
|
-
// // } & StyleProps;
|
|
30
|
-
// // const ImagePicker: React.FC<Props> = ({
|
|
31
|
-
// // mediaType,
|
|
32
|
-
// // isMultiSelect = false,
|
|
33
|
-
// // onSuccess,
|
|
34
|
-
// // visible,
|
|
35
|
-
// // onClose,
|
|
36
|
-
// // containerStyle,
|
|
37
|
-
// // rowStyle,
|
|
38
|
-
// // textStyle,
|
|
39
|
-
// // iconStyle,
|
|
40
|
-
// // }) => {
|
|
41
|
-
// // const onComplete = useCallback(
|
|
42
|
-
// // (data: any) => {
|
|
43
|
-
// // onSuccess(data);
|
|
44
|
-
// // onClose();
|
|
45
|
-
// // },
|
|
46
|
-
// // [onSuccess, onClose]
|
|
47
|
-
// // );
|
|
48
|
-
// // const onCamera = () => {
|
|
49
|
-
// // if (mediaType === "photo") {
|
|
50
|
-
// // if (isMultiSelect) {
|
|
51
|
-
// // ImageCropPicker.openCamera({ mediaType: "photo" })
|
|
52
|
-
// // .then((response) => onComplete([response]))
|
|
53
|
-
// // .catch(() => {});
|
|
54
|
-
// // } else {
|
|
55
|
-
// // ImageCropPicker.openCamera({ mediaType: "photo" })
|
|
56
|
-
// // .then((response) =>
|
|
57
|
-
// // ImageCropPicker.openCropper({
|
|
58
|
-
// // path: response?.path,
|
|
59
|
-
// // width: response?.width,
|
|
60
|
-
// // height: response?.height,
|
|
61
|
-
// // mediaType: "photo",
|
|
62
|
-
// // freeStyleCropEnabled: true,
|
|
63
|
-
// // }).then(onComplete)
|
|
64
|
-
// // )
|
|
65
|
-
// // .catch(() => {});
|
|
66
|
-
// // }
|
|
67
|
-
// // } else {
|
|
68
|
-
// // launchCamera({ mediaType: "video" }, (response) => {
|
|
69
|
-
// // if (response?.assets) {
|
|
70
|
-
// // onComplete({
|
|
71
|
-
// // path: response.assets[0]?.uri,
|
|
72
|
-
// // duration: response.assets[0]?.duration,
|
|
73
|
-
// // });
|
|
74
|
-
// // }
|
|
75
|
-
// // });
|
|
76
|
-
// // }
|
|
77
|
-
// // };
|
|
78
|
-
// // const onGallery = () => {
|
|
79
|
-
// // if (mediaType === "photo") {
|
|
80
|
-
// // if (isMultiSelect) {
|
|
81
|
-
// // ImageCropPicker.openPicker({
|
|
82
|
-
// // mediaType: "photo",
|
|
83
|
-
// // multiple: true,
|
|
84
|
-
// // maxFiles: 5,
|
|
85
|
-
// // })
|
|
86
|
-
// // .then((images) => {
|
|
87
|
-
// // if (images.length > 5) {
|
|
88
|
-
// // Alert.alert(
|
|
89
|
-
// // "Limit Exceeded",
|
|
90
|
-
// // "You can only select up to 5 images."
|
|
91
|
-
// // );
|
|
92
|
-
// // } else {
|
|
93
|
-
// // onComplete(images);
|
|
94
|
-
// // }
|
|
95
|
-
// // })
|
|
96
|
-
// // .catch(() => {});
|
|
97
|
-
// // } else {
|
|
98
|
-
// // ImageCropPicker.openPicker({ mediaType: "photo" })
|
|
99
|
-
// // .then((response) =>
|
|
100
|
-
// // ImageCropPicker.openCropper({
|
|
101
|
-
// // path: response?.path,
|
|
102
|
-
// // width: response?.width,
|
|
103
|
-
// // height: response?.height,
|
|
104
|
-
// // mediaType: "photo",
|
|
105
|
-
// // freeStyleCropEnabled: true,
|
|
106
|
-
// // }).then(onComplete)
|
|
107
|
-
// // )
|
|
108
|
-
// // .catch(() => {});
|
|
109
|
-
// // }
|
|
110
|
-
// // } else {
|
|
111
|
-
// // launchImageLibrary({ mediaType: "video" }, (result) => {
|
|
112
|
-
// // if (result?.assets) {
|
|
113
|
-
// // onComplete({
|
|
114
|
-
// // path: result.assets[0]?.uri,
|
|
115
|
-
// // duration: result.assets[0]?.duration,
|
|
116
|
-
// // });
|
|
117
|
-
// // }
|
|
118
|
-
// // });
|
|
119
|
-
// // }
|
|
120
|
-
// // };
|
|
121
|
-
// // return (
|
|
122
|
-
// // <BottomSheet visible={visible} onClose={onClose} height={230}>
|
|
123
|
-
// // <View style={[styles.container, containerStyle]}>
|
|
124
|
-
// // {/* Camera */}
|
|
125
|
-
// // <TouchableOpacity style={[styles.row, rowStyle]} onPress={onCamera}>
|
|
126
|
-
// // <Image source={Images.video_icon} style={[styles.icon, iconStyle]} />
|
|
127
|
-
// // <Text style={[styles.text, textStyle]}>Camera</Text>
|
|
128
|
-
// // </TouchableOpacity>
|
|
129
|
-
// // <Dividers small />
|
|
130
|
-
// // {/* Gallery */}
|
|
131
|
-
// // <TouchableOpacity style={[styles.row, rowStyle]} onPress={onGallery}>
|
|
132
|
-
// // <Image source={Images.image_icon} style={[styles.icon, iconStyle]} />
|
|
133
|
-
// // <Text style={[styles.text, textStyle]}>Gallery</Text>
|
|
134
|
-
// // </TouchableOpacity>
|
|
135
|
-
// // <Dividers small />
|
|
136
|
-
// // {/* Cancel */}
|
|
137
|
-
// // <TouchableOpacity style={[styles.row, rowStyle]} onPress={onClose}>
|
|
138
|
-
// // <Image source={Images.cancel} style={[styles.icon, iconStyle]} />
|
|
139
|
-
// // <Text style={[styles.text, textStyle]}>Cancel</Text>
|
|
140
|
-
// // </TouchableOpacity>
|
|
141
|
-
// // </View>
|
|
142
|
-
// // </BottomSheet>
|
|
143
|
-
// // );
|
|
144
|
-
// // };
|
|
145
|
-
// // export default ImagePicker;
|
|
146
|
-
// // const styles = StyleSheet.create({
|
|
147
|
-
// // container: { flex: 1, padding: 16 },
|
|
148
|
-
// // row: {
|
|
149
|
-
// // flexDirection: "row",
|
|
150
|
-
// // alignItems: "center",
|
|
151
|
-
// // },
|
|
152
|
-
// // text: { ...Typography.style.standardU(), color: Colors.white },
|
|
153
|
-
// // icon: {
|
|
154
|
-
// // width: Scale.moderateScale(20),
|
|
155
|
-
// // height: Scale.moderateScale(20),
|
|
156
|
-
// // marginRight: 10,
|
|
157
|
-
// // tintColor: Colors.white,
|
|
158
|
-
// // },
|
|
159
|
-
// // });
|
|
160
|
-
// import React, { useCallback } from "react";
|
|
161
|
-
// import {
|
|
162
|
-
// View,
|
|
163
|
-
// Text,
|
|
164
|
-
// TouchableOpacity,
|
|
165
|
-
// StyleSheet,
|
|
166
|
-
// Image,
|
|
167
|
-
// Alert,
|
|
168
|
-
// } from "react-native";
|
|
169
|
-
// import { BottomSheet, Dividers } from "../index";
|
|
170
|
-
// import { launchCamera, launchImageLibrary } from "react-native-image-picker";
|
|
171
|
-
// import ImageCropPicker from "react-native-image-crop-picker";
|
|
172
|
-
// import { Colors, Images, Scale, Typography } from "../../styles";
|
|
173
|
-
// // 👇 Import your permission utilities
|
|
174
|
-
// import {
|
|
175
|
-
// cameraPermissions,
|
|
176
|
-
// galleryPermissions,
|
|
177
|
-
// } from "../../utils/permissions"; // ✅ Make sure path is correct
|
|
178
|
-
// type Props = {
|
|
179
|
-
// mediaType: "photo" | "video";
|
|
180
|
-
// isMultiSelect?: boolean;
|
|
181
|
-
// onSuccess: (data: any) => void;
|
|
182
|
-
// visible: boolean;
|
|
183
|
-
// onClose: () => void;
|
|
184
|
-
// };
|
|
185
|
-
// const ImagePicker: React.FC<Props> = ({
|
|
186
|
-
// mediaType,
|
|
187
|
-
// isMultiSelect = false,
|
|
188
|
-
// onSuccess,
|
|
189
|
-
// visible,
|
|
190
|
-
// onClose,
|
|
191
|
-
// }) => {
|
|
192
|
-
// // ✅ Success handler
|
|
193
|
-
// const onComplete = useCallback(
|
|
194
|
-
// (data: any) => {
|
|
195
|
-
// onSuccess(data);
|
|
196
|
-
// onClose();
|
|
197
|
-
// },
|
|
198
|
-
// [onSuccess, onClose]
|
|
199
|
-
// );
|
|
200
|
-
// // ✅ CAMERA HANDLER with permission check
|
|
201
|
-
// const handleCamera = async () => {
|
|
202
|
-
// await cameraPermissions(async (granted: boolean) => {
|
|
203
|
-
// if (!granted) return; // ❌ Permission denied, handled by your alert
|
|
204
|
-
// if (mediaType === "photo") {
|
|
205
|
-
// if (isMultiSelect) {
|
|
206
|
-
// // single capture, multiple not supported directly from camera
|
|
207
|
-
// ImageCropPicker.openCamera({ mediaType: "photo" })
|
|
208
|
-
// .then((response) => onComplete([response]))
|
|
209
|
-
// .catch(() => {});
|
|
210
|
-
// } else {
|
|
211
|
-
// ImageCropPicker.openCamera({ mediaType: "photo" })
|
|
212
|
-
// .then((response) =>
|
|
213
|
-
// ImageCropPicker.openCropper({
|
|
214
|
-
// path: response?.path,
|
|
215
|
-
// width: response?.width,
|
|
216
|
-
// height: response?.height,
|
|
217
|
-
// mediaType: "photo",
|
|
218
|
-
// freeStyleCropEnabled: true,
|
|
219
|
-
// }).then(onComplete)
|
|
220
|
-
// )
|
|
221
|
-
// .catch(() => {});
|
|
222
|
-
// }
|
|
223
|
-
// } else {
|
|
224
|
-
// // 🎥 VIDEO CAPTURE
|
|
225
|
-
// launchCamera({ mediaType: "video" }, (response) => {
|
|
226
|
-
// if (response?.assets?.length) {
|
|
227
|
-
// onComplete({
|
|
228
|
-
// path: response.assets[0]?.uri,
|
|
229
|
-
// duration: response.assets[0]?.duration,
|
|
230
|
-
// });
|
|
231
|
-
// }
|
|
232
|
-
// });
|
|
233
|
-
// }
|
|
234
|
-
// });
|
|
235
|
-
// };
|
|
236
|
-
// // ✅ GALLERY HANDLER with permission check
|
|
237
|
-
// const handleGallery = async () => {
|
|
238
|
-
// await galleryPermissions(async (granted: boolean) => {
|
|
239
|
-
// if (!granted) return; // ❌ Permission denied, handled by your alert
|
|
240
|
-
// if (mediaType === "photo") {
|
|
241
|
-
// if (isMultiSelect) {
|
|
242
|
-
// ImageCropPicker.openPicker({
|
|
243
|
-
// mediaType: "photo",
|
|
244
|
-
// multiple: true,
|
|
245
|
-
// maxFiles: 5,
|
|
246
|
-
// })
|
|
247
|
-
// .then((images) => {
|
|
248
|
-
// if (images.length > 5) {
|
|
249
|
-
// Alert.alert(
|
|
250
|
-
// "Limit Exceeded",
|
|
251
|
-
// "You can only select up to 5 images."
|
|
252
|
-
// );
|
|
253
|
-
// } else {
|
|
254
|
-
// onComplete(images);
|
|
255
|
-
// }
|
|
256
|
-
// })
|
|
257
|
-
// .catch(() => {});
|
|
258
|
-
// } else {
|
|
259
|
-
// ImageCropPicker.openPicker({ mediaType: "photo" })
|
|
260
|
-
// .then((response) =>
|
|
261
|
-
// ImageCropPicker.openCropper({
|
|
262
|
-
// path: response?.path,
|
|
263
|
-
// width: response?.width,
|
|
264
|
-
// height: response?.height,
|
|
265
|
-
// mediaType: "photo",
|
|
266
|
-
// freeStyleCropEnabled: true,
|
|
267
|
-
// }).then(onComplete)
|
|
268
|
-
// )
|
|
269
|
-
// .catch(() => {});
|
|
270
|
-
// }
|
|
271
|
-
// } else {
|
|
272
|
-
// // 🎥 VIDEO FROM GALLERY
|
|
273
|
-
// launchImageLibrary({ mediaType: "video" }, (result) => {
|
|
274
|
-
// if (result?.assets?.length) {
|
|
275
|
-
// onComplete({
|
|
276
|
-
// path: result.assets[0]?.uri,
|
|
277
|
-
// duration: result.assets[0]?.duration,
|
|
278
|
-
// });
|
|
279
|
-
// }
|
|
280
|
-
// });
|
|
281
|
-
// }
|
|
282
|
-
// });
|
|
283
|
-
// };
|
|
284
|
-
// return (
|
|
285
|
-
// <BottomSheet visible={visible} onClose={onClose} height={230}>
|
|
286
|
-
// <View style={styles.container}>
|
|
287
|
-
// {/* 📸 Camera */}
|
|
288
|
-
// <TouchableOpacity style={styles.row} onPress={handleCamera}>
|
|
289
|
-
// <Image source={Images.video_icon} style={styles.icon} />
|
|
290
|
-
// <Text style={styles.text}>Camera</Text>
|
|
291
|
-
// </TouchableOpacity>
|
|
292
|
-
// <Dividers small />
|
|
293
|
-
// {/* 🖼️ Gallery */}
|
|
294
|
-
// <TouchableOpacity style={styles.row} onPress={handleGallery}>
|
|
295
|
-
// <Image source={Images.image_icon} style={styles.icon} />
|
|
296
|
-
// <Text style={styles.text}>Gallery</Text>
|
|
297
|
-
// </TouchableOpacity>
|
|
298
|
-
// <Dividers small />
|
|
299
|
-
// {/* ❌ Cancel */}
|
|
300
|
-
// <TouchableOpacity style={styles.row} onPress={onClose}>
|
|
301
|
-
// <Image source={Images.cancel} style={styles.icon} />
|
|
302
|
-
// <Text style={styles.text}>Cancel</Text>
|
|
303
|
-
// </TouchableOpacity>
|
|
304
|
-
// </View>
|
|
305
|
-
// </BottomSheet>
|
|
306
|
-
// );
|
|
307
|
-
// };
|
|
308
|
-
// export default ImagePicker;
|
|
309
|
-
// const styles = StyleSheet.create({
|
|
310
|
-
// container: { flex: 1, padding: 16 },
|
|
311
|
-
// row: {
|
|
312
|
-
// flexDirection: "row",
|
|
313
|
-
// alignItems: "center",
|
|
314
|
-
// },
|
|
315
|
-
// text: { ...Typography.style.standardU(), color: Colors.white },
|
|
316
|
-
// icon: {
|
|
317
|
-
// width: Scale.moderateScale(20),
|
|
318
|
-
// height: Scale.moderateScale(20),
|
|
319
|
-
// marginRight: 10,
|
|
320
|
-
// tintColor: Colors.white,
|
|
321
|
-
// },
|
|
322
|
-
// });
|
|
323
|
-
// import React, { useCallback } from "react";
|
|
324
|
-
// import {
|
|
325
|
-
// View,
|
|
326
|
-
// Text,
|
|
327
|
-
// TouchableOpacity,
|
|
328
|
-
// StyleSheet,
|
|
329
|
-
// Image,
|
|
330
|
-
// Alert,
|
|
331
|
-
// ViewStyle,
|
|
332
|
-
// } from "react-native";
|
|
333
|
-
// import { BottomSheet, Dividers } from "../index";
|
|
334
|
-
// import { launchCamera, launchImageLibrary } from "react-native-image-picker";
|
|
335
|
-
// import ImageCropPicker from "react-native-image-crop-picker";
|
|
336
|
-
// import {
|
|
337
|
-
// Image as ImageCompressor,
|
|
338
|
-
// Video as VideoCompressor,
|
|
339
|
-
// } from "react-native-compressor";
|
|
340
|
-
// import RNFS from "react-native-fs";
|
|
341
|
-
// import { Colors, Images, Scale, Typography } from "../../styles";
|
|
342
|
-
// // Import your permission utilities
|
|
343
|
-
// import {
|
|
344
|
-
// cameraPermissions,
|
|
345
|
-
// galleryPermissions,
|
|
346
|
-
// checkMicroPhonePermission,
|
|
347
|
-
// } from "../../utils/permissions";
|
|
348
|
-
// type Props = {
|
|
349
|
-
// mediaType: "photo" | "video";
|
|
350
|
-
// isMultiSelect?: boolean;
|
|
351
|
-
// onSuccess: (data: any) => void;
|
|
352
|
-
// visible: boolean;
|
|
353
|
-
// onClose: () => void;
|
|
354
|
-
// // Compression options
|
|
355
|
-
// enableCompression?: boolean;
|
|
356
|
-
// imageCompressionOptions?: {
|
|
357
|
-
// maxWidth?: number;
|
|
358
|
-
// quality?: number;
|
|
359
|
-
// };
|
|
360
|
-
// videoCompressionOptions?: {
|
|
361
|
-
// compressionMethod?: "auto" | "manual";
|
|
362
|
-
// };
|
|
363
|
-
// customStyle?:ViewStyle
|
|
364
|
-
// };
|
|
365
|
-
// const ImagePicker: React.FC<Props> = ({
|
|
366
|
-
// mediaType,
|
|
367
|
-
// isMultiSelect = false,
|
|
368
|
-
// onSuccess,
|
|
369
|
-
// visible,
|
|
370
|
-
// onClose,
|
|
371
|
-
// enableCompression = true,
|
|
372
|
-
// imageCompressionOptions = { maxWidth: 1080, quality: 0.7 },
|
|
373
|
-
// videoCompressionOptions = { compressionMethod: "auto" },
|
|
374
|
-
// customStyle
|
|
375
|
-
// }) => {
|
|
376
|
-
// // Success handler
|
|
377
|
-
// const onComplete = useCallback(
|
|
378
|
-
// (data: any) => {
|
|
379
|
-
// onSuccess(data);
|
|
380
|
-
// onClose();
|
|
381
|
-
// },
|
|
382
|
-
// [onSuccess, onClose]
|
|
383
|
-
// );
|
|
384
|
-
// // Helper: Compress Image
|
|
385
|
-
// const compressImage = async (imagePath: string) => {
|
|
386
|
-
// if (!enableCompression) return imagePath;
|
|
387
|
-
// try {
|
|
388
|
-
// const compressedImage = await ImageCompressor.compress(imagePath, {
|
|
389
|
-
// maxWidth: imageCompressionOptions.maxWidth,
|
|
390
|
-
// quality: imageCompressionOptions.quality,
|
|
391
|
-
// });
|
|
392
|
-
// // Log compressed size (optional)
|
|
393
|
-
// const stats = await RNFS.stat(compressedImage.replace("file://", ""));
|
|
394
|
-
// const sizeInMB = stats.size / (1024 * 1024);
|
|
395
|
-
// console.log("Compressed Image Size (MB):", sizeInMB);
|
|
396
|
-
// return compressedImage;
|
|
397
|
-
// } catch (error) {
|
|
398
|
-
// console.error("Image compression error:", error);
|
|
399
|
-
// return imagePath; // Return original if compression fails
|
|
400
|
-
// }
|
|
401
|
-
// };
|
|
402
|
-
// // Helper: Compress Video
|
|
403
|
-
// const compressVideo = async (videoUri: string) => {
|
|
404
|
-
// if (!enableCompression) return videoUri;
|
|
405
|
-
// try {
|
|
406
|
-
// const compressedVideo = await VideoCompressor.compress(videoUri, {
|
|
407
|
-
// compressionMethod: videoCompressionOptions.compressionMethod,
|
|
408
|
-
// });
|
|
409
|
-
// // Log compressed size (optional)
|
|
410
|
-
// const stats = await RNFS.stat(compressedVideo.replace("file://", ""));
|
|
411
|
-
// const sizeInMB = stats.size / (1024 * 1024);
|
|
412
|
-
// console.log("Compressed Video Size (MB):", sizeInMB);
|
|
413
|
-
// return compressedVideo;
|
|
414
|
-
// } catch (error) {
|
|
415
|
-
// console.error("Video compression error:", error);
|
|
416
|
-
// return videoUri; // Return original if compression fails
|
|
417
|
-
// }
|
|
418
|
-
// };
|
|
419
|
-
// // CAMERA HANDLER with permission check and compression
|
|
420
|
-
// const handleCamera = async () => {
|
|
421
|
-
// await cameraPermissions(async (granted: boolean) => {
|
|
422
|
-
// if (!granted) return;
|
|
423
|
-
// if (mediaType === "photo") {
|
|
424
|
-
// try {
|
|
425
|
-
// const response = await ImageCropPicker.openCamera({
|
|
426
|
-
// mediaType: "photo",
|
|
427
|
-
// });
|
|
428
|
-
// if (isMultiSelect) {
|
|
429
|
-
// // Single capture for multi-select mode
|
|
430
|
-
// const compressedPath = await compressImage(response.path);
|
|
431
|
-
// onComplete([{ ...response, path: compressedPath }]);
|
|
432
|
-
// } else {
|
|
433
|
-
// // Crop and compress single image
|
|
434
|
-
// const cropped = await ImageCropPicker.openCropper({
|
|
435
|
-
// path: response?.path,
|
|
436
|
-
// width: response?.width,
|
|
437
|
-
// height: response?.height,
|
|
438
|
-
// mediaType: "photo",
|
|
439
|
-
// freeStyleCropEnabled: true,
|
|
440
|
-
// });
|
|
441
|
-
// const compressedPath = await compressImage(cropped.path);
|
|
442
|
-
// onComplete({ ...cropped, path: compressedPath });
|
|
443
|
-
// }
|
|
444
|
-
// } catch (error) {
|
|
445
|
-
// console.log("Camera cancelled or error:", error);
|
|
446
|
-
// }
|
|
447
|
-
// } else {
|
|
448
|
-
// // VIDEO CAPTURE - check microphone permission first
|
|
449
|
-
// const micPermission = await checkMicroPhonePermission();
|
|
450
|
-
// if (!micPermission) {
|
|
451
|
-
// Alert.alert(
|
|
452
|
-
// "Microphone Permission Required",
|
|
453
|
-
// "Please enable microphone access to record videos."
|
|
454
|
-
// );
|
|
455
|
-
// return;
|
|
456
|
-
// }
|
|
457
|
-
// launchCamera(
|
|
458
|
-
// {
|
|
459
|
-
// mediaType: "video",
|
|
460
|
-
// durationLimit: 60,
|
|
461
|
-
// videoQuality: "high",
|
|
462
|
-
// },
|
|
463
|
-
// async (response) => {
|
|
464
|
-
// if (response?.assets?.length) {
|
|
465
|
-
// const videoUri = response.assets[0]?.uri;
|
|
466
|
-
// const compressedPath = await compressVideo(videoUri);
|
|
467
|
-
// onComplete({
|
|
468
|
-
// path: compressedPath,
|
|
469
|
-
// duration: response.assets[0]?.duration,
|
|
470
|
-
// });
|
|
471
|
-
// }
|
|
472
|
-
// }
|
|
473
|
-
// );
|
|
474
|
-
// }
|
|
475
|
-
// });
|
|
476
|
-
// };
|
|
477
|
-
// // GALLERY HANDLER with permission check and compression
|
|
478
|
-
// const handleGallery = async () => {
|
|
479
|
-
// await galleryPermissions(async (granted: boolean) => {
|
|
480
|
-
// if (!granted) return;
|
|
481
|
-
// if (mediaType === "photo") {
|
|
482
|
-
// try {
|
|
483
|
-
// if (isMultiSelect) {
|
|
484
|
-
// const images = await ImageCropPicker.openPicker({
|
|
485
|
-
// mediaType: "photo",
|
|
486
|
-
// multiple: true,
|
|
487
|
-
// maxFiles: 5,
|
|
488
|
-
// });
|
|
489
|
-
// if (images.length > 5) {
|
|
490
|
-
// Alert.alert(
|
|
491
|
-
// "Limit Exceeded",
|
|
492
|
-
// "You can only select up to 5 images."
|
|
493
|
-
// );
|
|
494
|
-
// return;
|
|
495
|
-
// }
|
|
496
|
-
// // Compress multiple images
|
|
497
|
-
// const compressedImages = await Promise.all(
|
|
498
|
-
// images.map(async (img) => ({
|
|
499
|
-
// ...img,
|
|
500
|
-
// path: await compressImage(img.path),
|
|
501
|
-
// }))
|
|
502
|
-
// );
|
|
503
|
-
// onComplete(compressedImages);
|
|
504
|
-
// } else {
|
|
505
|
-
// // Single image with crop
|
|
506
|
-
// const response = await ImageCropPicker.openPicker({
|
|
507
|
-
// mediaType: "photo",
|
|
508
|
-
// });
|
|
509
|
-
// const cropped = await ImageCropPicker.openCropper({
|
|
510
|
-
// path: response?.path,
|
|
511
|
-
// width: response?.width,
|
|
512
|
-
// height: response?.height,
|
|
513
|
-
// mediaType: "photo",
|
|
514
|
-
// freeStyleCropEnabled: true,
|
|
515
|
-
// });
|
|
516
|
-
// const compressedPath = await compressImage(cropped.path);
|
|
517
|
-
// onComplete({ ...cropped, path: compressedPath });
|
|
518
|
-
// }
|
|
519
|
-
// } catch (error) {
|
|
520
|
-
// console.log("Gallery cancelled or error:", error);
|
|
521
|
-
// }
|
|
522
|
-
// } else {
|
|
523
|
-
// // VIDEO FROM GALLERY
|
|
524
|
-
// launchImageLibrary(
|
|
525
|
-
// {
|
|
526
|
-
// mediaType: "video",
|
|
527
|
-
// assetRepresentationMode: "current",
|
|
528
|
-
// },
|
|
529
|
-
// async (result) => {
|
|
530
|
-
// if (result?.assets?.length) {
|
|
531
|
-
// const videoUri = result.assets[0]?.uri;
|
|
532
|
-
// const compressedPath = await compressVideo(videoUri);
|
|
533
|
-
// onComplete({
|
|
534
|
-
// path: compressedPath,
|
|
535
|
-
// duration: result.assets[0]?.duration,
|
|
536
|
-
// });
|
|
537
|
-
// }
|
|
538
|
-
// }
|
|
539
|
-
// );
|
|
540
|
-
// }
|
|
541
|
-
// });
|
|
542
|
-
// };
|
|
543
|
-
// return (
|
|
544
|
-
// <BottomSheet visible={visible} onClose={onClose} height={230} sheetBackground={customStyle?.backgroundColor}>
|
|
545
|
-
// <View style={styles.container}>
|
|
546
|
-
// {/* Camera */}
|
|
547
|
-
// <TouchableOpacity style={styles.row} onPress={handleCamera}>
|
|
548
|
-
// <Image source={Images.video_icon} style={styles.icon} />
|
|
549
|
-
// <Text style={styles.text}>Camera</Text>
|
|
550
|
-
// </TouchableOpacity>
|
|
551
|
-
// <Dividers small />
|
|
552
|
-
// {/* Gallery */}
|
|
553
|
-
// <TouchableOpacity style={styles.row} onPress={handleGallery}>
|
|
554
|
-
// <Image source={Images.image_icon} style={styles.icon} />
|
|
555
|
-
// <Text style={styles.text}>Gallery</Text>
|
|
556
|
-
// </TouchableOpacity>
|
|
557
|
-
// <Dividers small />
|
|
558
|
-
// {/* Cancel */}
|
|
559
|
-
// <TouchableOpacity style={styles.row} onPress={onClose}>
|
|
560
|
-
// <Image source={Images.cancel} style={styles.icon} />
|
|
561
|
-
// <Text style={styles.text}>Cancel</Text>
|
|
562
|
-
// </TouchableOpacity>
|
|
563
|
-
// </View>
|
|
564
|
-
// </BottomSheet>
|
|
565
|
-
// );
|
|
566
|
-
// };
|
|
567
|
-
// export default ImagePicker;
|
|
568
|
-
// const styles = StyleSheet.create({
|
|
569
|
-
// container: { flex: 1, padding: 16 },
|
|
570
|
-
// row: {
|
|
571
|
-
// flexDirection: "row",
|
|
572
|
-
// alignItems: "center",
|
|
573
|
-
// },
|
|
574
|
-
// text: { ...Typography.style.standardU(), color: Colors.white },
|
|
575
|
-
// icon: {
|
|
576
|
-
// width: Scale.moderateScale(20),
|
|
577
|
-
// height: Scale.moderateScale(20),
|
|
578
|
-
// marginRight: 10,
|
|
579
|
-
// tintColor: Colors.white,
|
|
580
|
-
// },
|
|
581
|
-
// });
|
|
582
1
|
import React, { useCallback } from "react";
|
|
583
2
|
import { View, Text, TouchableOpacity, StyleSheet, Image, Alert, } from "react-native";
|
|
584
3
|
import { BottomSheet, Dividers } from "../index";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle, TextStyle } from "react-native";
|
|
3
|
+
interface LinearGradientButtonProps {
|
|
4
|
+
title: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
colors?: string[];
|
|
9
|
+
start?: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
end?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
containerStyle?: ViewStyle;
|
|
18
|
+
textStyle?: TextStyle;
|
|
19
|
+
height?: number;
|
|
20
|
+
borderRadius?: number;
|
|
21
|
+
}
|
|
22
|
+
declare const LinearGradientButton: React.FC<LinearGradientButtonProps>;
|
|
23
|
+
export default LinearGradientButton;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, } from "react-native";
|
|
3
|
+
import LinearGradient from "react-native-linear-gradient";
|
|
4
|
+
const LinearGradientButton = ({ title, onPress, loading = false, disabled = false, colors = ["#4c669f", "#3b5998", "#192f6a"], start = { x: 0, y: 0 }, end = { x: 1, y: 1 }, containerStyle, textStyle, height = 50, borderRadius = 12, }) => {
|
|
5
|
+
const isDisabled = loading || disabled;
|
|
6
|
+
return (React.createElement(TouchableOpacity, { activeOpacity: 0.8, onPress: onPress, disabled: isDisabled, style: { opacity: isDisabled ? 0.6 : 1 } },
|
|
7
|
+
React.createElement(LinearGradient, { colors: colors, start: start, end: end, style: [
|
|
8
|
+
styles.button,
|
|
9
|
+
{ height, borderRadius },
|
|
10
|
+
containerStyle,
|
|
11
|
+
] }, loading ? (React.createElement(ActivityIndicator, { color: "#fff", size: "small" })) : (React.createElement(Text, { style: [styles.text, textStyle] }, title)))));
|
|
12
|
+
};
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
button: {
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
paddingHorizontal: 12,
|
|
18
|
+
},
|
|
19
|
+
text: {
|
|
20
|
+
color: "#fff",
|
|
21
|
+
fontSize: 16,
|
|
22
|
+
fontWeight: "600",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
export default LinearGradientButton;
|
|
@@ -27,3 +27,4 @@ export { default as ProgressBar } from "./ProgressBar";
|
|
|
27
27
|
export { default as DocumentPicker } from "./DocumentPicker";
|
|
28
28
|
export { default as ImagePicker } from "./ImagePicker";
|
|
29
29
|
export { default as AppHeader } from "./AppHeader";
|
|
30
|
+
export { default as LinearGradientButton } from "./LinearGradientButton";
|
package/dist/components/index.js
CHANGED
|
@@ -27,3 +27,4 @@ export { default as ProgressBar } from "./ProgressBar";
|
|
|
27
27
|
export { default as DocumentPicker } from "./DocumentPicker";
|
|
28
28
|
export { default as ImagePicker } from "./ImagePicker";
|
|
29
29
|
export { default as AppHeader } from "./AppHeader";
|
|
30
|
+
export { default as LinearGradientButton } from "./LinearGradientButton";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnhz/rn-ui-toolkit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"react-native-element-dropdown": "^2.12.4",
|
|
22
22
|
"react-native-elements": "^3.4.3",
|
|
23
23
|
"react-native-gesture-handler": "^2.26.0",
|
|
24
|
-
"react-native-image-crop-picker": "^0.
|
|
24
|
+
"react-native-image-crop-picker": "^0.51.1",
|
|
25
25
|
"react-native-image-picker": "^8.2.0",
|
|
26
26
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
27
27
|
"react-native-modal": "^14.0.0-rc.1",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"react-native-vector-icons": "^10.3.0",
|
|
33
33
|
"react-native-video-trim": "^3.0.9",
|
|
34
34
|
"react-native-compressor": "^1.13.0",
|
|
35
|
-
"react-native-fs": "^2.20.0"
|
|
35
|
+
"react-native-fs": "^2.20.0",
|
|
36
|
+
"react-native-linear-gradient": "^2.8.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@react-native-documents/picker": "^10.1.5",
|