dhre-ui-kit 0.0.8 → 0.0.10

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.8",
3
+ "version": "0.0.10",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -22,6 +22,7 @@
22
22
  "prepare": "husky"
23
23
  },
24
24
  "dependencies": {
25
+ "@react-native-community/blur": "^4.4.1",
25
26
  "@testing-library/react-native": "^12.5.1",
26
27
  "lint-staged": "^15.2.7",
27
28
  "react": "18.2.0",
package/src/App.tsx CHANGED
@@ -1,43 +1,11 @@
1
1
  import React from 'react';
2
2
  import {ThemeProvider} from './theme/ThemeContext';
3
- import {
4
- Badge,
5
- Button,
6
- CustomDropdown,
7
- CustomTextInput,
8
- FileUpload,
9
- StarRating,
10
- Tabs,
11
- Tags,
12
- } from './index';
13
- import {CalenderDots} from './assets';
3
+ import {Badge} from './index';
4
+ import {ArrowLeft, CalenderDots} from './assets';
14
5
  import {View} from 'react-native';
15
- import {BUTTON_TYPES} from './utils/constants';
16
- import Checkbox from './components/checkBox';
17
- import {Text} from 'react-native-svg';
6
+ import CustomButton from './components/button/Button';
18
7
 
19
- import {DHRE_COLORS_PRIMARY, DHRE_COLORS_TEXT} from './theme/colors';
20
- import {moderateScale} from './utils/stylehelper';
21
- import CustomTooltip from './components/customTooltip';
22
8
  const App = () => {
23
- const options = [
24
- {id: '1', value: 'user1', label: 'User 1'},
25
- {id: '2', value: 'user2', label: 'User 2'},
26
- {id: '3', value: 'user3', label: 'User 3'},
27
- ];
28
- const handleTabPress = (index: number) => {
29
- console.log('Tab pressed:', index);
30
- };
31
-
32
- const handleSetSelectedTagsOptions = (tags: string[]) => {
33
- console.log('Selected tags:', tags);
34
- };
35
- const handleTagsChange = (tag: string) => {
36
- console.log('Tag removed:', tag);
37
- };
38
- const handleSelect = (option: {id: string; value: string; label: string}) => {
39
- console.log('Selected:', option);
40
- };
41
9
  return (
42
10
  <ThemeProvider>
43
11
  <View style={{marginTop: 50}}>
@@ -50,94 +18,23 @@ const App = () => {
50
18
  iconStyle={{}}
51
19
  />
52
20
 
53
- <Button
54
- onPress={function (): void {
55
- throw new Error('Function not implemented.');
56
- }}
57
- title={'dfghj'}
58
- buttonType={BUTTON_TYPES.PRIMARY}
59
- variant={'H6bold'}
60
- iconShown={true}
61
- iconName={<CalenderDots width={20} height={20} />}
62
- />
63
-
64
- <Checkbox
65
- isChecked={false}
66
- labelName={'circle'}
67
- checkedIcon={<CalenderDots width={20} height={20} />}
68
- uncheckedIcon={<CalenderDots width={20} height={20} />}
69
- />
70
- <CustomDropdown
71
- label="Select User"
72
- placeholder="Choose Option"
73
- options={options}
74
- oneSelect={handleSelect}
75
- selectedValue={options[0]} // Initially selected value
76
- iconName={<CalenderDots />} // Dynamic icon for the dropdown
77
- upArrowIcon={<CalenderDots />} // Up arrow icon
78
- downArrowIcon={<CalenderDots />} // Down arrow icon
79
- testId="CUSTOM-DROPDOWN"
80
- iconStyle={{marginRight: 10}}
81
- />
82
- <CustomTextInput
83
- label="Search"
84
- placeholder="Type here"
85
- isSearchBar={true}
86
- searchIcon={<CalenderDots />}
87
- rightIcon1={<CalenderDots />}
88
- rightIcon2={<CalenderDots />}
89
- secureTextEntry={true}
90
- errorMessage="This field is required."
91
- handleOnChangeText={text => console.log(text)}
92
- />
93
- <FileUpload
94
- onUpload={() => console.log('Upload clicked')}
95
- title="Upload Files"
96
- btnText="Browse"
97
- containerStyle={{width: 200}}
98
- uploadImageStyling={{width: 10, height: 10}} // Example styling
99
- icon={<CalenderDots />} // Pass your icon here
100
- iconStyle={{}} // Optional styling for the icon
101
- />
102
- <Tags
103
- tags={['Tag1', 'Tag2', 'Tag3']}
104
- handleSetSelectedTagsOptions={handleSetSelectedTagsOptions}
105
- handleTagsChange={handleTagsChange}
106
- testID="tags-component"
107
- icon={<CalenderDots />} // Pass your icon here
108
- iconStyle={{backgroundColor: DHRE_COLORS_TEXT.DH_WHITE}} // Optional styling for the icon
109
- />
21
+ <CustomButton
22
+ title="Yes"
23
+ onPress={() => console.log('Yes Button Pressed')}
24
+ leftIcon={<ArrowLeft />}
25
+ // titleColor={color.CONTENT_SECONDRY[currentTheme]}
26
+ titleVariant="L2_REGULAR"
27
+ containerStyle={[
28
+ {
29
+ borderWidth: 1,
30
+ borderRadius: 20,
110
31
 
111
- <Tabs
112
- tabs={[{label: 'Tab 1'}, {label: 'Tab 2'}, {label: 'Tab 3'}]}
113
- onTabPress={handleTabPress}
114
- testID="tabs-component"
115
- icon={<CalenderDots />}
116
- iconStyle={{width: 24, height: 24}}
117
- />
118
- <StarRating
119
- rating={3.5}
120
- count={5}
121
- size={24}
122
- fullStarIcon={<CalenderDots />}
123
- halfStarIcon={<CalenderDots />}
124
- fullStarColor="gold"
125
- emptyStarColor="gray"
126
- starStyle={{marginHorizontal: 2}}
32
+ height: 40,
33
+ },
34
+ ]}
35
+ // iconStyle={styles.iconStyle}
36
+ imagePosition="left"
127
37
  />
128
- <CustomTooltip
129
- message="This is a tooltip"
130
- icon={
131
- <CalenderDots
132
- width={moderateScale(16)}
133
- height={moderateScale(16)}
134
- />
135
- }
136
- iconStyle={{width: moderateScale(16), height: moderateScale(16)}} // Optional styling for the icon
137
- iconColor={DHRE_COLORS_PRIMARY.DH_RED_100} // Example icon color
138
- >
139
- <Text>Hover over me</Text>
140
- </CustomTooltip>
141
38
  </View>
142
39
  </ThemeProvider>
143
40
  );
@@ -15,6 +15,7 @@ const styles = StyleSheet.create({
15
15
  flexDirection: 'row',
16
16
  justifyContent: 'space-between',
17
17
  alignItems: 'center',
18
+ paddingHorizontal: horizontalScale(16),
18
19
  },
19
20
  title: {flex: 1, color: '#FFFFFF'},
20
21
  iconStyle: {marginLeft: horizontalScale(20)},
@@ -9,6 +9,8 @@ export interface BottomDrawerProps {
9
9
  testID?: string;
10
10
  style?: ViewStyle;
11
11
  modalContainerStyle?: ViewStyle;
12
+ blurAmount?: number;
13
+ blurViewStyle?: ViewStyle;
12
14
  leftIcon?: React.ReactElement;
13
15
  rightIcon?: React.ReactElement;
14
16
  showLeftIcon?: boolean;
@@ -10,6 +10,7 @@ const styles = StyleSheet.create({
10
10
  flex: 1,
11
11
  justifyContent: 'flex-end',
12
12
  },
13
+ blurView: {...StyleSheet.absoluteFillObject},
13
14
  modalContainer: {
14
15
  flex: 0.5,
15
16
  backgroundColor: '#000',
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import {View, Modal} from 'react-native';
3
+ import {BlurView} from '@react-native-community/blur';
3
4
  import {BottomDrawerProps} from './BottomDrawer.interface';
4
5
  import styles from './BottomDrawer.styles';
5
6
  import CustomTypography from '../customTypography/CustomTypography';
@@ -14,6 +15,8 @@ const BottomDrawer: React.FC<BottomDrawerProps> = ({
14
15
  testID = 'BOTTOM-DRAWER',
15
16
  style,
16
17
  modalContainerStyle,
18
+ blurAmount = 10,
19
+ blurViewStyle,
17
20
  showLeftIcon = false,
18
21
  showRightIcon = true,
19
22
  leftIcon = <ArrowLeft />,
@@ -27,6 +30,11 @@ const BottomDrawer: React.FC<BottomDrawerProps> = ({
27
30
  visible={isModalVisible}
28
31
  onRequestClose={toggleModal}>
29
32
  <View style={[styles.mainContainer, style]} testID={testID}>
33
+ <BlurView
34
+ style={[styles.blurView, blurViewStyle]}
35
+ blurType="light"
36
+ blurAmount={blurAmount}
37
+ />
30
38
  <View style={[styles.modalContainer, modalContainerStyle]}>
31
39
  <View style={styles.separator} />
32
40
  <View style={styles.headerContainer}>
@@ -1,53 +1,75 @@
1
- import React from 'react';
2
- import {Pressable, View} from 'react-native';
3
- import styles from './Button.styles';
4
- import {BUTTON_TYPES} from '../../utils/constants';
5
- import {ButtonProps} from './Button.interface';
6
- import {DHRE_COLORS_TEXT} from '../../theme/colors';
7
- import CustomTypography from '../customTypography/CustomTypography';
1
+ import React, {ReactElement} from 'react';
2
+ import {
3
+ TouchableOpacity,
4
+ StyleSheet,
5
+ View,
6
+ ViewStyle,
7
+ StyleProp,
8
+ } from 'react-native';
9
+ import {SvgProps} from 'react-native-svg';
10
+ import CustomText from '../customText';
8
11
 
9
- const Button: React.FC<ButtonProps> = ({
10
- onPress,
11
- title = '',
12
- buttonType = BUTTON_TYPES.PRIMARY,
13
- buttonStyle,
14
- titleStyle,
15
- variant,
16
- iconStyles,
17
- testID,
18
- titleShown = true,
19
- iconShown = false,
20
- iconName,
21
- }) => {
22
- const buttonStyles = [styles.button, styles[buttonType], buttonStyle];
23
- const textStyle = [styles[buttonType + BUTTON_TYPES.TEXT], titleStyle];
24
- const iconStyle = [styles.iconStyle, iconStyles];
12
+ interface CustomButtonProps {
13
+ title: string;
14
+ onPress: () => void;
15
+ containerStyle?: StyleProp<ViewStyle>;
16
+ textStyle?: ViewStyle;
17
+ leftIcon?: ReactElement<SvgProps>;
18
+ rightIcon?: ReactElement<SvgProps>;
19
+ iconStyle?: ViewStyle;
20
+ titleColor?: string;
21
+ titleVariant?: string;
22
+ imagePosition?: 'left' | 'right';
23
+ testID?:string
24
+ }
25
25
 
26
+ const CustomButton = ({
27
+ title,
28
+ testID,
29
+ onPress,
30
+ containerStyle,
31
+ textStyle,
32
+ leftIcon,
33
+ rightIcon,
34
+ iconStyle,
35
+ titleColor,
36
+ titleVariant = 'L2_REGULAR',
37
+ imagePosition = 'right',
38
+ }: CustomButtonProps) => {
26
39
  return (
27
- <View testID={testID} style={styles.mainContainer}>
28
- <Pressable
29
- disabled={buttonType === BUTTON_TYPES.DISABLE}
30
- onPress={onPress}
31
- style={buttonStyles}>
32
- <View style={styles.directionStyle}>
33
- {titleShown ? (
34
- <CustomTypography
35
- variant={variant}
36
- style={textStyle}
37
- text={title}
38
- />
39
- ) : null}
40
- {iconShown && iconName && (
41
- <View style={iconStyle}>
42
- {React.cloneElement(iconName, {
43
- fill: DHRE_COLORS_TEXT.DH_WHITE,
44
- })}
45
- </View>
46
- )}
40
+ <TouchableOpacity testID={testID}
41
+ style={[styles.buttonContainer, containerStyle]}
42
+ onPress={onPress}>
43
+ {imagePosition === 'left' && leftIcon && (
44
+ <View style={iconStyle}>
45
+ {React.cloneElement(leftIcon, {width: 20, height: 20})}
47
46
  </View>
48
- </Pressable>
49
- </View>
47
+ )}
48
+ <CustomText
49
+ text={title}
50
+ variant={titleVariant}
51
+ style={[textStyle, {color: '#A7A7A7'}]}
52
+ textColor={titleColor}
53
+ />
54
+
55
+ {imagePosition === 'right' && rightIcon && (
56
+ <View style={iconStyle}>
57
+ {React.cloneElement(rightIcon, {width: 20, height: 20})}
58
+ </View>
59
+ )}
60
+ </TouchableOpacity>
50
61
  );
51
62
  };
52
63
 
53
- export default Button;
64
+ const styles = StyleSheet.create({
65
+ buttonContainer: {
66
+ flexDirection: 'row',
67
+ alignItems: 'center',
68
+ padding: 10,
69
+ backgroundColor: '#000000',
70
+ borderRadius: 8,
71
+ justifyContent: 'center',
72
+ },
73
+ });
74
+
75
+ export default CustomButton;
@@ -4,7 +4,6 @@ const styles = StyleSheet.create({
4
4
  container: {
5
5
  justifyContent: 'center',
6
6
  alignItems: 'center',
7
- backgroundColor: '#fff',
8
7
  },
9
8
  title: {
10
9
  color: '#000',
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {TextProps, TextStyle} from 'react-native';
2
+ import {StyleProp, TextProps, TextStyle} from 'react-native';
3
3
  import {useTheme} from '../../theme/ThemeContext';
4
4
  import {withThemeProvider} from '../../theme/withThemeProvider';
5
5
  import {FONT_STYLES} from '../../theme/fonts';
@@ -8,7 +8,7 @@ import CustomTypography from '../customTypography/CustomTypography';
8
8
  interface CustomTextProps extends TextProps {
9
9
  text: string;
10
10
  variant: keyof typeof FONT_STYLES | string;
11
- style?: TextStyle;
11
+ style?: StyleProp<TextStyle>;
12
12
  textColor?: string;
13
13
  }
14
14
 
@@ -3,14 +3,25 @@ import {TextStyle, ViewStyle} from 'react-native';
3
3
 
4
4
  export interface ListItem {
5
5
  id: string;
6
+ templateId: number;
6
7
  title: string;
7
- isPinned: boolean;
8
+ subTitle: string;
9
+ icon: string;
8
10
  isRead: boolean;
11
+ isPinned: boolean;
12
+ isDeleted: boolean;
13
+ isActionable: boolean;
14
+ category: string;
15
+ url: string;
16
+ channel: string;
17
+ status: string;
18
+ createdBy: string;
19
+ createdDateTime: string;
9
20
  }
10
21
 
11
22
  export interface ActionButtonProps {
12
23
  icon: ReactNode;
13
- title: string;
24
+ title?: string;
14
25
  onPress: () => void;
15
26
  style?: object;
16
27
  testID: string;
@@ -20,17 +31,21 @@ export interface SwipableListProps {
20
31
  data: ListItem[];
21
32
  testId?: string;
22
33
  renderItem: (item: ListItem) => ReactNode;
23
- leftPrimaryActionIcon?: ReactNode;
24
- leftPrimaryActionTitle?: string;
25
- leftPrimaryActionHandler?: (id: string) => void;
34
+ leftPrimaryActionActiveIcon?: ReactNode;
35
+ leftPrimaryActionActiveTitle?: string;
36
+ leftPrimaryActionInActiveIcon?: ReactNode;
37
+ leftPrimaryActionInActiveTitle?: string;
38
+ leftPrimaryActionHandler?: (item: ListItem) => void;
26
39
  leftPrimaryActionStyle?: ViewStyle;
27
- leftSecondaryActionIcon?: ReactNode;
28
- leftSecondaryActionTitle?: string;
29
- leftSecondaryActionHandler?: (id: string) => void;
40
+ leftSecondaryActionActiveIcon?: ReactNode;
41
+ leftSecondaryActionActiveTitle?: string;
42
+ leftSecondaryActionInActiveIcon?: ReactNode;
43
+ leftSecondaryActionInActiveTitle?: string;
44
+ leftSecondaryActionHandler?: (item: ListItem) => void;
30
45
  leftSecondaryActionStyle?: ViewStyle;
31
46
  rightPrimaryActionIcon?: ReactNode;
32
47
  rightPrimaryActionTitle?: string;
33
- rightPrimaryActionHandler?: (id: string) => void;
48
+ rightPrimaryActionHandler?: (item: ListItem) => void;
34
49
  rightPrimaryActionStyle?: ViewStyle;
35
50
  itemStyle?: ViewStyle;
36
51
  titleStyle?: TextStyle;
@@ -1,4 +1,4 @@
1
- import {moderateScale, verticalScale} from '../../utils/stylehelper';
1
+ import {horizontalScale, verticalScale} from '../../utils/stylehelper';
2
2
  import {StyleSheet} from 'react-native';
3
3
 
4
4
  export const styles = StyleSheet.create({
@@ -9,19 +9,20 @@ export const styles = StyleSheet.create({
9
9
  actionButton: {
10
10
  justifyContent: 'center',
11
11
  alignItems: 'center',
12
- paddingHorizontal: moderateScale(24),
13
- paddingVertical: moderateScale(8),
14
12
  },
15
13
  titleStyle: {
16
14
  color: '#fff',
17
15
  },
18
16
  leftActions: {
19
17
  flexDirection: 'row',
20
- justifyContent: 'flex-start',
18
+ justifyContent: 'center',
19
+ alignItems: 'center',
20
+ width: horizontalScale(150),
21
+ gap: horizontalScale(24),
21
22
  },
22
23
  rightActions: {
23
24
  flexDirection: 'row',
24
- justifyContent: 'flex-end',
25
+ paddingHorizontal: horizontalScale(24),
25
26
  },
26
27
  seprator: {
27
28
  height: verticalScale(16),
@@ -35,18 +35,114 @@ const customStyle = {backgroundColor: 'red', padding: 20};
35
35
 
36
36
  describe('Notification Component', () => {
37
37
  const notifications = [
38
- {id: '1', title: 'Notification 1', isPinned: false, isRead: true},
39
- {id: '2', title: 'Notification 2', isPinned: true, isRead: false},
38
+ {
39
+ id: '1',
40
+ title: 'Notification 1',
41
+ isPinned: false,
42
+ isRead: true,
43
+ templateId: 1,
44
+ subTitle: 'Welcome Albus',
45
+ icon: 'https://svgshare.com/i/U7z.svg',
46
+ isDeleted: false,
47
+ isActionable: false,
48
+ category: 'general',
49
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
50
+ channel: 'push',
51
+ status: 'sent',
52
+ createdBy: 'system',
53
+ createdDateTime: '2024-09-02T12:00:00+05:30',
54
+ },
55
+ {
56
+ id: '2',
57
+ title: 'Notification 2',
58
+ isPinned: true,
59
+ isRead: false,
60
+ templateId: 1,
61
+ subTitle: 'Welcome Albus',
62
+ icon: 'https://svgshare.com/i/U7z.svg',
63
+ isDeleted: false,
64
+ isActionable: false,
65
+ category: 'general',
66
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
67
+ channel: 'push',
68
+ status: 'sent',
69
+ createdBy: 'system',
70
+ createdDateTime: '2024-09-02T12:00:00+05:30',
71
+ },
40
72
  ];
41
73
 
42
74
  const notificationsPinned = [
43
- {id: '1', title: 'Notification 1', isPinned: true, isRead: true},
44
- {id: '2', title: 'Notification 2', isPinned: false, isRead: false},
75
+ {
76
+ id: '1',
77
+ title: 'Notification 1',
78
+ isPinned: true,
79
+ isRead: true,
80
+ templateId: 1,
81
+ subTitle: 'Welcome Albus',
82
+ icon: 'https://svgshare.com/i/U7z.svg',
83
+ isDeleted: false,
84
+ isActionable: false,
85
+ category: 'general',
86
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
87
+ channel: 'push',
88
+ status: 'sent',
89
+ createdBy: 'system',
90
+ createdDateTime: '2024-09-02T12:00:00+05:30',
91
+ },
92
+ {
93
+ id: '2',
94
+ title: 'Notification 2',
95
+ isPinned: false,
96
+ isRead: false,
97
+ templateId: 1,
98
+ subTitle: 'Welcome Albus',
99
+ icon: 'https://svgshare.com/i/U7z.svg',
100
+ isDeleted: false,
101
+ isActionable: false,
102
+ category: 'general',
103
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
104
+ channel: 'push',
105
+ status: 'sent',
106
+ createdBy: 'system',
107
+ createdDateTime: '2024-09-02T12:00:00+05:30',
108
+ },
45
109
  ];
46
110
 
47
111
  const notificationsUnPinned = [
48
- {id: '1', title: 'Notification 1', isPinned: false, isRead: false},
49
- {id: '2', title: 'Notification 2', isPinned: false, isRead: false},
112
+ {
113
+ id: '1',
114
+ title: 'Notification 1',
115
+ isPinned: false,
116
+ isRead: false,
117
+ templateId: 1,
118
+ subTitle: 'Welcome Albus',
119
+ icon: 'https://svgshare.com/i/U7z.svg',
120
+ isDeleted: false,
121
+ isActionable: false,
122
+ category: 'general',
123
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
124
+ channel: 'push',
125
+ status: 'sent',
126
+ createdBy: 'system',
127
+ createdDateTime: '2024-09-02T12:00:00+05:30',
128
+ },
129
+ {
130
+ id: '2',
131
+ title: 'Notification 2',
132
+ isPinned: false,
133
+ isRead: false,
134
+ templateId: 1,
135
+ subTitle: 'Welcome Albus',
136
+ icon: 'https://svgshare.com/i/U7z.svg',
137
+ isDeleted: false,
138
+ isActionable: false,
139
+ category: 'general',
140
+ url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIzIiBmaWxsPSJyZWQiIC8+Cjwvc3ZnPg==',
141
+ channel: 'push',
142
+ status: 'sent',
143
+ createdBy: 'system',
144
+ createdDateTime: '2024-09-02T12:00:00+05:30',
145
+ },
50
146
  ];
51
147
 
52
148
  const mockLeftPrimaryActionHandler = jest.fn();
@@ -95,8 +191,6 @@ describe('Notification Component', () => {
95
191
  <SwipableList {...props} renderItem={() => <Text>Title</Text>} />,
96
192
  );
97
193
  expect(getByTestId('SWIPABLE-LIST')).toBeTruthy();
98
- fireEvent.press(getByTestId('SWIPABLE-LIST-LEFT-PRIMARY-1'));
99
- fireEvent.press(getByTestId('SWIPABLE-LIST-LEFT-SECONDARY-1'));
100
194
  fireEvent.press(getByTestId('SWIPABLE-LIST-RIGHT-PRIMARY-1'));
101
195
  });
102
196
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, {ReactNode} from 'react';
2
2
  import {FlatList, View, Pressable} from 'react-native';
3
3
  import {GestureHandlerRootView, Swipeable} from 'react-native-gesture-handler';
4
4
  import {
@@ -13,12 +13,16 @@ const SwipableList = (props: SwipableListProps) => {
13
13
  const {
14
14
  data,
15
15
  testId = 'SWIPABLE-LIST',
16
- leftPrimaryActionIcon,
17
- leftPrimaryActionTitle,
16
+ leftPrimaryActionActiveIcon,
17
+ leftPrimaryActionInActiveIcon,
18
+ leftPrimaryActionActiveTitle,
19
+ leftPrimaryActionInActiveTitle,
20
+ leftSecondaryActionActiveIcon,
21
+ leftSecondaryActionInActiveIcon,
22
+ leftSecondaryActionActiveTitle,
23
+ leftSecondaryActionInActiveTitle,
18
24
  leftPrimaryActionHandler,
19
25
  leftPrimaryActionStyle,
20
- leftSecondaryActionIcon,
21
- leftSecondaryActionTitle,
22
26
  leftSecondaryActionHandler,
23
27
  leftSecondaryActionStyle,
24
28
  rightPrimaryActionIcon,
@@ -48,13 +52,19 @@ const SwipableList = (props: SwipableListProps) => {
48
52
  </Pressable>
49
53
  );
50
54
 
51
- const leftActionHandle = (item: ListItem) => (
55
+ const leftActionHandle = (
56
+ item: ListItem,
57
+ leftPrimaryActionIcon: ReactNode,
58
+ leftPrimaryActionTitle: string | undefined,
59
+ leftSecondaryActionIcon: ReactNode,
60
+ leftSecondaryActionTitle: string | undefined,
61
+ ) => (
52
62
  <View style={[styles.leftActions, leftPrimaryActionStyle]}>
53
63
  {leftPrimaryActionIcon && (
54
64
  <ActionButton
55
65
  icon={leftPrimaryActionIcon}
56
- title={leftPrimaryActionTitle || ''}
57
- onPress={() => leftPrimaryActionHandler?.(item.id)}
66
+ title={leftPrimaryActionTitle}
67
+ onPress={() => leftPrimaryActionHandler?.(item)}
58
68
  style={leftPrimaryActionStyle}
59
69
  testID={`${testId}-LEFT-PRIMARY-${item.id}`}
60
70
  />
@@ -62,8 +72,8 @@ const SwipableList = (props: SwipableListProps) => {
62
72
  {leftSecondaryActionIcon && (
63
73
  <ActionButton
64
74
  icon={leftSecondaryActionIcon}
65
- title={leftSecondaryActionTitle || ''}
66
- onPress={() => leftSecondaryActionHandler?.(item.id)}
75
+ title={leftSecondaryActionTitle}
76
+ onPress={() => leftSecondaryActionHandler?.(item)}
67
77
  style={leftSecondaryActionStyle}
68
78
  testID={`${testId}-LEFT-SECONDARY-${item.id}`}
69
79
  />
@@ -77,7 +87,7 @@ const SwipableList = (props: SwipableListProps) => {
77
87
  <ActionButton
78
88
  icon={rightPrimaryActionIcon}
79
89
  title={rightPrimaryActionTitle || ''}
80
- onPress={() => rightPrimaryActionHandler?.(item.id)}
90
+ onPress={() => rightPrimaryActionHandler?.(item)}
81
91
  style={rightPrimaryActionStyle}
82
92
  testID={`${testId}-RIGHT-PRIMARY-${item.id}`}
83
93
  />
@@ -88,7 +98,23 @@ const SwipableList = (props: SwipableListProps) => {
88
98
  const renderItem = ({item}: {item: ListItem}) => (
89
99
  <GestureHandlerRootView testID={`${testId}-LIST`} style={styles.container}>
90
100
  <Swipeable
91
- renderLeftActions={() => leftActionHandle(item)}
101
+ renderLeftActions={() =>
102
+ leftActionHandle(
103
+ item,
104
+ item.isPinned
105
+ ? leftPrimaryActionInActiveIcon
106
+ : leftPrimaryActionActiveIcon,
107
+ item.isPinned
108
+ ? leftPrimaryActionInActiveTitle
109
+ : leftPrimaryActionActiveTitle,
110
+ item.isRead
111
+ ? leftSecondaryActionInActiveIcon
112
+ : leftSecondaryActionActiveIcon,
113
+ item.isRead
114
+ ? leftSecondaryActionInActiveTitle
115
+ : leftSecondaryActionActiveTitle,
116
+ )
117
+ }
92
118
  renderRightActions={() => rightActionHandle(item)}
93
119
  containerStyle={styles.swippableContainer}>
94
120
  {props?.renderItem(item)}
@@ -143,6 +143,31 @@ export const DHRE_COLORS_BG = {
143
143
  DH_BG_GREY_900: '#6F7387',
144
144
  DH_BG_GREY: '#F2F3F8',
145
145
  };
146
+ export const DHRE_DEFAULT = {
147
+ DH_LINE_GREY_0: '#FAFAFA',
148
+ DH_LINE_GREY_100: '#F6F6F6',
149
+ DH_LINE_GREY_200: '#F1F1F1',
150
+ DH_LINE_GREY_300: '#EDEDED',
151
+ DH_LINE_GREY_400: '#EDEDED',
152
+ DH_LINE_GREY_500: '#CCCACA',
153
+ DH_LINE_GREY_600: '#B4B2B2',
154
+ DH_LINE_GREY_700: '#959494',
155
+ DH_LINE_GREY_800: '#727171',
156
+ DH_LINE_GREY_900: '#4D4C4C',
157
+ DH_BLUE: '#007AFF',
158
+
159
+ DH_BG_GREY_0: '#F5F7FF',
160
+ DH_BG_GREY_100: '#F2F4FD',
161
+ DH_BG_GREY_200: '#EDEFF9',
162
+ DH_BG_GREY_300: '#E5E7F2',
163
+ DH_BG_GREY_400: '#D9DCE9',
164
+ DH_BG_GREY_500: '#CACDDD',
165
+ DH_BG_GREY_600: '#B7BBCD',
166
+ DH_BG_GREY_700: '#A0A4B8',
167
+ DH_BG_GREY_800: '#878BA0',
168
+ DH_BG_GREY_900: '#6F7387',
169
+ DH_BG_GREY: '#F2F3F8',
170
+ };
146
171
 
147
172
  export const DHRE_COLORS_TEXT = {
148
173
  //Black
@@ -50,7 +50,7 @@ const theme = {
50
50
  },
51
51
  CONTENT_SECONDRY_STATIC: {
52
52
  light: '#CECECE',
53
- dark: '##CECECE',
53
+ dark: '#CECECE',
54
54
  },
55
55
 
56
56
  BORDER_PRIMARY: {