@teamnhz/rn-ui-toolkit 1.3.7 → 1.3.9

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.
@@ -5,6 +5,7 @@ import { launchCamera, launchImageLibrary } from "react-native-image-picker";
5
5
  import ImageCropPicker from "react-native-image-crop-picker";
6
6
  import { Image as ImageCompressor, Video as VideoCompressor, } from "react-native-compressor";
7
7
  import { Colors, Images, Scale, Typography } from "../../styles";
8
+ import ImageResizer from "react-native-image-resizer";
8
9
  // Permissions
9
10
  import { cameraPermissions, galleryPermissions, checkMicroPhonePermission, } from "../../utils/permissions";
10
11
  import { scale } from "../../styles/scale";
@@ -14,18 +15,34 @@ const ImagePicker = ({ mediaType, isMultiSelect = false, onSuccess, visible, onC
14
15
  onClose();
15
16
  }, [onSuccess, onClose]);
16
17
  // Compress Image
18
+ // const compressImage = async (imagePath: string) => {
19
+ // if (!enableCompression) return imagePath;
20
+ // try {
21
+ // const compressedImage = await ImageCompressor.compress(imagePath, {
22
+ // maxWidth: imageCompressionOptions.maxWidth,
23
+ // quality: imageCompressionOptions.quality,
24
+ // });
25
+ // return compressedImage;
26
+ // } catch (error) {
27
+ // console.error("Image compression error:", error);
28
+ // return imagePath;
29
+ // }
30
+ // };
17
31
  const compressImage = async (imagePath) => {
18
- if (!enableCompression)
19
- return imagePath;
20
32
  try {
21
- const compressedImage = await ImageCompressor.compress(imagePath, {
22
- maxWidth: imageCompressionOptions.maxWidth,
23
- quality: imageCompressionOptions.quality,
33
+ if (!enableCompression)
34
+ return imagePath;
35
+ // STEP 1 — Resize using image resizer
36
+ const resized = await ImageResizer.createResizedImage(imagePath, imageCompressionOptions.maxWidth ?? 1080, imageCompressionOptions.maxWidth ?? 1080, "JPEG", (imageCompressionOptions.quality ?? 0.7) * 100, 0, undefined, false);
37
+ // STEP 2 — Compress using compressor
38
+ const compressedUri = await ImageCompressor.compress(resized.uri, {
39
+ maxWidth: imageCompressionOptions.maxWidth ?? 1080,
40
+ quality: imageCompressionOptions.quality ?? 0.7,
24
41
  });
25
- return compressedImage;
42
+ return compressedUri;
26
43
  }
27
- catch (error) {
28
- console.error("Image compression error:", error);
44
+ catch (err) {
45
+ console.log("Image final compression error:", err);
29
46
  return imagePath;
30
47
  }
31
48
  };
@@ -3,11 +3,10 @@ import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, } from "react-na
3
3
  import LinearGradient from "react-native-linear-gradient";
4
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
5
  const isDisabled = loading || disabled;
6
- return (React.createElement(TouchableOpacity, { activeOpacity: 0.8, onPress: onPress, disabled: isDisabled, style: { opacity: isDisabled ? 0.6 : 1 } },
6
+ return (React.createElement(TouchableOpacity, { activeOpacity: 0.8, onPress: onPress, disabled: isDisabled, style: [{ opacity: isDisabled ? 0.6 : 1 }, containerStyle,] },
7
7
  React.createElement(LinearGradient, { colors: colors, start: start, end: end, style: [
8
8
  styles.button,
9
- { height, borderRadius },
10
- containerStyle,
9
+ { height, borderRadius }
11
10
  ] }, loading ? (React.createElement(ActivityIndicator, { color: "#fff", size: "small" })) : (React.createElement(Text, { style: [styles.text, textStyle] }, title)))));
12
11
  };
13
12
  const styles = StyleSheet.create({
@@ -15,6 +14,7 @@ const styles = StyleSheet.create({
15
14
  justifyContent: "center",
16
15
  alignItems: "center",
17
16
  paddingHorizontal: 12,
17
+ width: "100%",
18
18
  },
19
19
  text: {
20
20
  color: "#fff",
@@ -1,68 +1,33 @@
1
- // import React, { ReactNode } from "react";
2
- // import Modal, { ModalProps } from "react-native-modal";
1
+ import React from "react";
2
+ import Modal from "react-native-modal";
3
+ // Base Modal Component customized for app needs
4
+ const Modals = ({ children, closing, bkO = 0.5, ...props }) => (React.createElement(Modal, { backdropOpacity: bkO, animationInTiming: 400, animationOutTiming: 400, backdropTransitionOutTiming: 0, swipeDirection: ["down", "left", "right", "up"], onSwipeComplete: closing, onBackdropPress: closing, onBackButtonPress: closing, ...props }, children));
5
+ export default Modals;
6
+ // import React, { ReactNode } from 'react';
7
+ // import Modal, { ModalProps } from 'react-native-modal';
3
8
  // type AppModalProps = Partial<ModalProps> & {
4
9
  // children: ReactNode;
5
10
  // closing: () => void;
6
11
  // bkO?: number;
7
12
  // };
8
13
  // // Base Modal Component customized for app needs
9
- // const Modals = ({ children, closing, bkO = 0.5, ...props }: AppModalProps) => (
14
+ // const Modals = ({
15
+ // children,
16
+ // closing,
17
+ // bkO = 0.5,
18
+ // ...props
19
+ // }: AppModalProps) => (
10
20
  // <Modal
11
21
  // backdropOpacity={bkO}
12
22
  // animationInTiming={400}
13
23
  // animationOutTiming={400}
14
24
  // backdropTransitionOutTiming={0}
15
- // swipeDirection={["down", "left", "right", "up"]}
25
+ // swipeDirection={['down', 'left', 'right', 'up']}
16
26
  // onSwipeComplete={closing}
17
27
  // onBackdropPress={closing}
18
28
  // onBackButtonPress={closing}
19
- // {...props}
20
- // >
29
+ // {...props}>
21
30
  // {children}
22
31
  // </Modal>
23
32
  // );
24
33
  // export default Modals;
25
- // // import React, { ReactNode } from 'react';
26
- // // import Modal, { ModalProps } from 'react-native-modal';
27
- // // type AppModalProps = Partial<ModalProps> & {
28
- // // children: ReactNode;
29
- // // closing: () => void;
30
- // // bkO?: number;
31
- // // };
32
- // // // Base Modal Component customized for app needs
33
- // // const Modals = ({
34
- // // children,
35
- // // closing,
36
- // // bkO = 0.5,
37
- // // ...props
38
- // // }: AppModalProps) => (
39
- // // <Modal
40
- // // backdropOpacity={bkO}
41
- // // animationInTiming={400}
42
- // // animationOutTiming={400}
43
- // // backdropTransitionOutTiming={0}
44
- // // swipeDirection={['down', 'left', 'right', 'up']}
45
- // // onSwipeComplete={closing}
46
- // // onBackdropPress={closing}
47
- // // onBackButtonPress={closing}
48
- // // {...props}>
49
- // // {children}
50
- // // </Modal>
51
- // // );
52
- // // export default Modals;
53
- import React from "react";
54
- import { View, StyleSheet } from "react-native";
55
- import Modal from "react-native-modal";
56
- const Modals = ({ children, closing, bkO = 0.5, ...props }) => (React.createElement(Modal, { useNativeDriver: true, useNativeDriverForBackdrop: true, backdropOpacity: bkO, animationInTiming: 300, animationOutTiming: 300, onBackdropPress: closing, onBackButtonPress: closing, swipeDirection: ["down"], onSwipeComplete: closing, propagateSwipe: true, ...props },
57
- React.createElement(View, { style: styles.innerContainer }, children)));
58
- const styles = StyleSheet.create({
59
- innerContainer: {
60
- width: "100%",
61
- alignSelf: "center",
62
- justifyContent: "center",
63
- // MOST IMPORTANT FIX ⚠️
64
- // Prevents children from being animated up/down
65
- transform: [{ translateY: 0 }],
66
- },
67
- });
68
- export default Modals;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnhz/rn-ui-toolkit",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -33,7 +33,8 @@
33
33
  "react-native-video-trim": "^3.0.9",
34
34
  "react-native-compressor": "^1.13.0",
35
35
  "react-native-fs": "^2.20.0",
36
- "react-native-linear-gradient": "^2.8.3"
36
+ "react-native-linear-gradient": "^2.8.3",
37
+ "react-native-image-resizer":"^1.4.5"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@react-native-documents/picker": "^10.1.5",