dhre-ui-kit 0.0.86 → 0.0.88

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhre-ui-kit",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -34,6 +34,7 @@
34
34
  "react-native-country-picker-modal": "^2.0.0",
35
35
  "react-native-document-picker": "^9.3.1",
36
36
  "react-native-element-dropdown": "^2.12.1",
37
+ "react-native-fs": "^2.20.0",
37
38
  "react-native-gesture-handler": "2.17.0",
38
39
  "react-native-otp-verify": "^1.1.8",
39
40
  "react-native-paper": "^5.12.5",
@@ -0,0 +1,8 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4.5 12V3.75C4.5 3.55109 4.57902 3.36032 4.71967 3.21967C4.86032 3.07902 5.05109 3 5.25 3H14.25L19.5 8.25V12" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M14.25 3V8.25H19.5" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M4.5 18.75H6C6.39782 18.75 6.77936 18.592 7.06066 18.3107C7.34196 18.0294 7.5 17.6478 7.5 17.25C7.5 16.8522 7.34196 16.4706 7.06066 16.1893C6.77936 15.908 6.39782 15.75 6 15.75H4.5V20.25" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M20.25 15.75H17.625V20.25" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <path d="M19.875 18.375H17.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
7
+ <path d="M12 20.25C12.5967 20.25 13.169 20.0129 13.591 19.591C14.0129 19.169 14.25 18.5967 14.25 18C14.25 17.4033 14.0129 16.831 13.591 16.409C13.169 15.9871 12.5967 15.75 12 15.75H10.6875V20.25H12Z" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
8
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M20.25 5.25H3.75" stroke="#EB0542" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M9.75 9.75V15.75" stroke="#EB0542" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M14.25 9.75V15.75" stroke="#EB0542" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M18.75 5.25V19.5C18.75 19.6989 18.671 19.8897 18.5303 20.0303C18.3897 20.171 18.1989 20.25 18 20.25H6C5.80109 20.25 5.61032 20.171 5.46967 20.0303C5.32902 19.8897 5.25 19.6989 5.25 19.5V5.25" stroke="#EB0542" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <path d="M15.75 5.25V3.75C15.75 3.35218 15.592 2.97064 15.3107 2.68934C15.0294 2.40804 14.6478 2.25 14.25 2.25H9.75C9.35218 2.25 8.97064 2.40804 8.68934 2.68934C8.40804 2.97064 8.25 3.35218 8.25 3.75V5.25" stroke="#EB0542" stroke-linecap="round" stroke-linejoin="round"/>
7
+ </svg>
@@ -11,6 +11,8 @@ import BellSimple from './images/bellSimple.svg';
11
11
  import UploadFile from './images/uploadFileIcon.svg';
12
12
  import CaretRight from './images/caretRight.svg';
13
13
  import CheckWhite from './images/checkWhite.svg';
14
+ import FileIcon from './images/fileIcon.svg';
15
+ import Trash from './images/trash.svg';
14
16
 
15
17
  export {
16
18
  CalenderDots,
@@ -26,4 +28,6 @@ export {
26
28
  UploadFile,
27
29
  CaretRight,
28
30
  CheckWhite,
31
+ FileIcon,
32
+ Trash,
29
33
  };
@@ -2,7 +2,7 @@ import {TextStyle, ViewStyle} from 'react-native';
2
2
  import {DocumentPickerResponse} from 'react-native-document-picker';
3
3
 
4
4
  export interface CustomDocumentPickerProps {
5
- onDocumentUpload: (document: DocumentPickerResponse) => void;
5
+ onDocumentUpload: (base64: string, document?: DocumentPickerResponse) => void;
6
6
  title?: string;
7
7
  hint?: string;
8
8
  maxFileSize?: number;
@@ -9,14 +9,24 @@ const styles = StyleSheet.create({
9
9
  container: {
10
10
  flexDirection: 'row',
11
11
  alignItems: 'center',
12
+ justifyContent: 'space-between',
12
13
  paddingVertical: verticalScale(16),
13
14
  paddingHorizontal: horizontalScale(24),
14
15
  borderWidth: 1,
15
16
  borderStyle: 'dashed',
16
17
  borderRadius: moderateScale(8),
17
- gap: moderateScale(24),
18
18
  marginBottom: verticalScale(8),
19
19
  },
20
+ fileUploadContainerStyle: {
21
+ flexDirection: 'row',
22
+ alignItems: 'center',
23
+ justifyContent: 'space-between',
24
+ paddingVertical: verticalScale(16),
25
+ paddingHorizontal: horizontalScale(24),
26
+ borderRadius: moderateScale(8),
27
+ marginBottom: verticalScale(8),
28
+ },
29
+ innerContainer: {flexDirection: 'row', columnGap: horizontalScale(24)},
20
30
  titleContainer: {gap: verticalScale(4)},
21
31
  });
22
32
 
@@ -1,7 +1,10 @@
1
- import React, {useState} from 'react';
1
+ import React, {useState, useCallback, memo} from 'react';
2
2
  import {View, Pressable, Alert} from 'react-native';
3
- import DocumentPicker from 'react-native-document-picker';
4
- import {UploadFile} from '../../assets';
3
+ import DocumentPicker, {
4
+ DocumentPickerResponse,
5
+ } from 'react-native-document-picker';
6
+ import RNFS from 'react-native-fs';
7
+ import {FileIcon, Trash, UploadFile} from '../../assets';
5
8
  import {FontStyle} from '../../utils/appEnum';
6
9
  import CustomTypography from '../customTypography';
7
10
  import {useTheme} from '../../theme/ThemeContext';
@@ -20,20 +23,26 @@ const CustomDocumentPicker = ({
20
23
  hintStyle,
21
24
  }: CustomDocumentPickerProps) => {
22
25
  const [error, setError] = useState('');
26
+ const [docDetails, setDocDetails] = useState<DocumentPickerResponse>();
27
+ const {theme} = useTheme();
23
28
 
24
- const pickDocument = async () => {
29
+ const pickDocument = useCallback(async () => {
25
30
  try {
26
31
  const res = await DocumentPicker.pickSingle({
27
32
  type: fileTypes,
28
33
  });
29
34
 
30
- if (res?.size && res?.size > maxFileSize * 1024 * 1024) {
35
+ if (res?.size && res.size > maxFileSize * 1024 * 1024) {
31
36
  setError(
32
37
  `File size higher than ${maxFileSize}MB. Please upload a smaller file.`,
33
38
  );
34
39
  return;
35
40
  }
36
- onDocumentUpload(res);
41
+
42
+ setError(''); // Clear error on successful upload
43
+ setDocDetails(res);
44
+ const base64Data = await RNFS.readFile(res.uri, 'base64');
45
+ onDocumentUpload(base64Data, res); // Pass base64 data to onDocumentUpload
37
46
  } catch (err) {
38
47
  if (DocumentPicker.isCancel(err)) {
39
48
  Alert.alert('User canceled the picker');
@@ -43,32 +52,40 @@ const CustomDocumentPicker = ({
43
52
  Alert.alert('Unknown Error: ' + JSON.stringify(err));
44
53
  }
45
54
  }
46
- };
55
+ }, [fileTypes, maxFileSize, onDocumentUpload]);
56
+
57
+ const removeDocument = useCallback(() => {
58
+ setDocDetails(undefined);
59
+ }, []);
47
60
 
48
- const {theme} = useTheme();
49
61
  return (
50
62
  <>
51
- <Pressable
63
+ <View
52
64
  style={[
53
- styles.container,
65
+ docDetails ? styles.fileUploadContainerStyle : styles.container,
54
66
  {borderColor: error ? theme.ERROR : theme.BORDER_SECONDRY},
67
+ docDetails ? {backgroundColor: theme.SURFACE_SECONDARY} : {},
55
68
  containerStyle,
56
- ]}
57
- onPress={pickDocument}>
58
- <UploadFile />
59
- <View style={styles.titleContainer}>
60
- <CustomTypography
61
- variant={FontStyle.L2_REGULAR}
62
- text={title}
63
- style={[{color: theme.CONTENT_PRIMARY}, titleStyle]}
64
- />
65
- <CustomTypography
66
- variant={FontStyle.L3_REGULAR}
67
- text={hint}
68
- style={[{color: theme.CONTENT_SECONDRY}, hintStyle]}
69
- />
70
- </View>
71
- </Pressable>
69
+ ]}>
70
+ <Pressable style={styles.innerContainer} onPress={pickDocument}>
71
+ {docDetails ? <FileIcon /> : <UploadFile />}
72
+ <View style={styles.titleContainer}>
73
+ <CustomTypography
74
+ variant={FontStyle.L2_REGULAR}
75
+ text={docDetails?.name ?? title}
76
+ style={[{color: theme.CONTENT_PRIMARY}, titleStyle]}
77
+ />
78
+ {!docDetails && (
79
+ <CustomTypography
80
+ variant={FontStyle.L3_REGULAR}
81
+ text={hint}
82
+ style={[{color: theme.CONTENT_SECONDRY}, hintStyle]}
83
+ />
84
+ )}
85
+ </View>
86
+ </Pressable>
87
+ {docDetails && <Trash onPress={removeDocument} />}
88
+ </View>
72
89
  {error && (
73
90
  <CustomTypography
74
91
  variant={FontStyle.L2_REGULAR}
@@ -80,4 +97,4 @@ const CustomDocumentPicker = ({
80
97
  );
81
98
  };
82
99
 
83
- export default withThemeProvider(CustomDocumentPicker);
100
+ export default withThemeProvider(memo(CustomDocumentPicker));
@@ -4,6 +4,8 @@ import {CaretRight} from '../../assets/index';
4
4
  import {CustomTypography, FontStyle} from '../../index';
5
5
  import styles from './styles';
6
6
  import {CustomSlideButtonProps} from './custom-slide-button.interface';
7
+ import {useTheme} from '../../theme/ThemeContext';
8
+ import {withThemeProvider} from '../../theme/withThemeProvider';
7
9
 
8
10
  const {width} = Dimensions.get('window');
9
11
  const BUTTON_WIDTH = 40; // Width of the button
@@ -41,15 +43,31 @@ const CustomSlideButton = ({label, onComplete}: CustomSlideButtonProps) => {
41
43
  }),
42
44
  ).current;
43
45
 
46
+ const {theme} = useTheme();
44
47
  return (
45
- <View style={styles.sliderContainer}>
48
+ <View
49
+ style={{
50
+ ...styles.sliderContainer,
51
+ backgroundColor: theme.SURFACE_PRIMARY,
52
+ }}>
46
53
  <View style={styles.buttonTextCOntainer}>
47
- <CustomTypography text={label} variant={FontStyle.L1_REGULAR} />
54
+ <CustomTypography
55
+ text={label}
56
+ variant={FontStyle.L1_REGULAR}
57
+ style={{
58
+ color: theme.CONTENT_PRIMARY,
59
+ }}
60
+ />
48
61
  </View>
49
62
  <Animated.View
50
63
  style={[styles.slider, {transform: [{translateX: pan}]}]}
51
64
  {...panResponder.panHandlers}>
52
- <View style={{...styles.button, width: BUTTON_WIDTH}}>
65
+ <View
66
+ style={{
67
+ ...styles.button,
68
+ backgroundColor: theme.SURFACE_INVERTED,
69
+ width: BUTTON_WIDTH,
70
+ }}>
53
71
  <CaretRight />
54
72
  </View>
55
73
  </Animated.View>
@@ -57,4 +75,4 @@ const CustomSlideButton = ({label, onComplete}: CustomSlideButtonProps) => {
57
75
  );
58
76
  };
59
77
 
60
- export default CustomSlideButton;
78
+ export default withThemeProvider(CustomSlideButton);
@@ -1,17 +1,15 @@
1
1
  import {StyleSheet} from 'react-native';
2
+ import {moderateScale, verticalScale} from '../../utils/stylehelper';
2
3
 
3
4
  const styles = StyleSheet.create({
4
5
  container: {
5
6
  flex: 1,
6
7
  justifyContent: 'center',
7
8
  alignItems: 'center',
8
- backgroundColor: '#f8f8f8',
9
9
  },
10
10
  sliderContainer: {
11
- width: '100%',
12
- height: 48,
13
- backgroundColor: '#e0e0e0',
14
- borderRadius: 25,
11
+ height: verticalScale(48),
12
+ borderRadius: moderateScale(25),
15
13
  overflow: 'hidden',
16
14
  justifyContent: 'center',
17
15
  },
@@ -21,12 +19,11 @@ const styles = StyleSheet.create({
21
19
  position: 'absolute',
22
20
  },
23
21
  button: {
24
- height: 40,
25
- backgroundColor: '#000',
22
+ height: verticalScale(40),
26
23
  justifyContent: 'center',
27
24
  alignItems: 'center',
28
- borderRadius: 20,
29
- margin: 4,
25
+ borderRadius: moderateScale(20),
26
+ margin: moderateScale(4),
30
27
  },
31
28
  buttonTextCOntainer: {
32
29
  position: 'absolute',