dhre-ui-kit 0.0.50 → 0.0.52

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.50",
3
+ "version": "0.0.52",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -17,6 +17,7 @@ interface ContactModalProps {
17
17
  visible: boolean;
18
18
  onClose: () => void;
19
19
  isMailOpen: boolean;
20
+ data: string;
20
21
  }
21
22
 
22
23
  const ContactModal: React.FC<ContactModalProps> = ({
@@ -24,6 +25,7 @@ const ContactModal: React.FC<ContactModalProps> = ({
24
25
  visible,
25
26
  onClose,
26
27
  isMailOpen,
28
+ data,
27
29
  }) => {
28
30
  const handleCall = () => {
29
31
  if (Platform.OS === 'ios') {
@@ -33,9 +35,46 @@ const ContactModal: React.FC<ContactModalProps> = ({
33
35
  }
34
36
  onClose();
35
37
  };
38
+ const openEmail = (recipient: string) => {
39
+ const mailtoUrl = `mailto:${recipient}?subject=${encodeURIComponent(
40
+ '',
41
+ )}&body=${encodeURIComponent('')}`;
36
42
 
37
- const handleOptionPress = (appName: string) => {
38
- console.log(`Opening ${appName}`);
43
+ if (Platform.OS === 'android') {
44
+ // Try to open Gmail specifically on Android
45
+ const gmailUrl = `intent://#Intent;scheme=mailto;package=com.google.android.gm;S.to=${recipient};S.subject=${encodeURIComponent(
46
+ '',
47
+ )};S.body=${encodeURIComponent('')};end`;
48
+
49
+ // Check if Gmail can be opened
50
+ Linking.canOpenURL(gmailUrl)
51
+ .then(supported => {
52
+ if (supported) {
53
+ // Open Gmail
54
+ return Linking.openURL(gmailUrl);
55
+ } else {
56
+ // If Gmail is not available, fallback to default mail client
57
+ console.log('Gmail app not available, opening default mail app');
58
+ return Linking.openURL(mailtoUrl);
59
+ }
60
+ })
61
+ .catch(err => console.error('Error:', err));
62
+ } else {
63
+ // iOS: Use mailto URL to open the default email client
64
+ Linking.canOpenURL(mailtoUrl)
65
+ .then(supported => {
66
+ if (!supported) {
67
+ console.log('No email client available');
68
+ } else {
69
+ return Linking.openURL(mailtoUrl);
70
+ }
71
+ })
72
+ .catch(err => console.error('Error:', err));
73
+ }
74
+ };
75
+
76
+ const handleOptionPress = () => {
77
+ openEmail(data);
39
78
  onClose();
40
79
  };
41
80
 
@@ -56,7 +95,7 @@ const ContactModal: React.FC<ContactModalProps> = ({
56
95
  <React.Fragment key={option}>
57
96
  <Line />
58
97
  <Pressable
59
- onPress={() => handleOptionPress(option)}
98
+ onPress={() => handleOptionPress()}
60
99
  style={styles.optionButton}>
61
100
  <CustomText
62
101
  style={styles.optionText}
@@ -6,6 +6,9 @@ export interface AccordionProps {
6
6
  testId?: string;
7
7
  containerStyle?: ViewStyle;
8
8
  titleStyle?: TextStyle;
9
- children: React.ReactNode;
10
9
  headerStyle?: ViewStyle;
10
+ children?: React.ReactNode;
11
+ isOpen: boolean;
12
+ onToggle: () => void;
13
+ optionalElement?: () => React.ReactNode; // Update this line
11
14
  }
@@ -15,7 +15,8 @@ const Accordion = ({
15
15
  children,
16
16
  isOpen,
17
17
  onToggle,
18
- }: AccordionProps & {isOpen: boolean; onToggle: () => void}) => {
18
+ optionalElement, // Destructure the new prop
19
+ }: AccordionProps) => {
19
20
  const contentRef = useRef<View>(null);
20
21
  const [animation] = useState(new Animated.Value(0));
21
22
  const [contentHeight, setContentHeight] = useState(0);
@@ -55,6 +56,9 @@ const Accordion = ({
55
56
  style: styles.iconStyle,
56
57
  })}
57
58
  </Pressable>
59
+
60
+ {optionalElement ? optionalElement() : null}
61
+
58
62
  <Animated.View style={[styles.content, {height: cardHeight}]}>
59
63
  <View
60
64
  ref={contentRef}
@@ -16,4 +16,6 @@ export interface CustomSearchBarProps extends TextInputProps {
16
16
  disablePlaceHolderStyle?: string;
17
17
  enablePlaceHolderStyle?: string;
18
18
  borderColor?: string;
19
+ setValue: (val: string) => void;
20
+ value: string;
19
21
  }
@@ -11,7 +11,15 @@ const mockProps = {
11
11
 
12
12
  describe('Custom search bar component', () => {
13
13
  it('Component renders correctly', () => {
14
- const {getByTestId} = render(<CustomSearchBar {...mockProps} />);
14
+ const {getByTestId} = render(
15
+ <CustomSearchBar
16
+ setValue={(val: string) => {
17
+ return val;
18
+ }}
19
+ value={''}
20
+ {...mockProps}
21
+ />,
22
+ );
15
23
  expect(getByTestId(mockProps.testID)).toBeTruthy();
16
24
  const textInput = getByTestId('CUSTOM-SEARCH-BAR-INPUT');
17
25
  fireEvent.changeText(textInput, 'test@example.com');
@@ -1,4 +1,4 @@
1
- import React, {useState} from 'react';
1
+ import React from 'react';
2
2
  import {Pressable, TextInput, View} from 'react-native';
3
3
  import {CrossIcon, SearchIcon} from '../../assets';
4
4
  import {moderateScale, verticalScale} from '../../utils/stylehelper';
@@ -6,6 +6,7 @@ import {CustomSearchBarProps} from './CustomSearchBar.interface';
6
6
  import styles from './CustomSearchBar.styles';
7
7
 
8
8
  const CustomSearchBar = ({
9
+ value,
9
10
  height = 40,
10
11
  disabled = false,
11
12
  testID = 'CUSTOM-SEARCH-BAR',
@@ -16,6 +17,7 @@ const CustomSearchBar = ({
16
17
  onSearchIconPress,
17
18
  onCrossIconPress,
18
19
  handleOnChangeText,
20
+ setValue,
19
21
  rightIcon = <CrossIcon />,
20
22
  disableBorderColor = '#4F4F4F',
21
23
  borderColor = '#FFFFFF',
@@ -23,8 +25,6 @@ const CustomSearchBar = ({
23
25
  enablePlaceHolderStyle = '#A7A7A7',
24
26
  ...props
25
27
  }: CustomSearchBarProps) => {
26
- const [value, setValue] = useState('');
27
-
28
28
  return (
29
29
  <View
30
30
  testID={testID}