dhre-ui-kit 0.0.1
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/README.md +1 -0
- package/package.json +104 -0
- package/src/App.tsx +146 -0
- package/src/assets/images/calenderDots.svg +1 -0
- package/src/assets/index.ts +2 -0
- package/src/components/autoOtpReader/AutoOtpReader.test.tsx +56 -0
- package/src/components/autoOtpReader/AutoOtpReader.tsx +79 -0
- package/src/components/autoOtpReader/index.ts +1 -0
- package/src/components/badge/Badge.styles.ts +20 -0
- package/src/components/badge/Badge.test.tsx +45 -0
- package/src/components/badge/Badge.tsx +47 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/bottomDrawer/BottomDrawer.interface.ts +12 -0
- package/src/components/bottomDrawer/BottomDrawer.styles.ts +31 -0
- package/src/components/bottomDrawer/BottomDrawer.test.tsx +19 -0
- package/src/components/bottomDrawer/BottomDrawer.tsx +43 -0
- package/src/components/bottomDrawer/index.ts +1 -0
- package/src/components/button/Button.interface.ts +18 -0
- package/src/components/button/Button.styles.ts +78 -0
- package/src/components/button/Button.test.tsx +43 -0
- package/src/components/button/Button.tsx +53 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/cards/Cards.interface.ts +13 -0
- package/src/components/cards/Cards.styles.ts +59 -0
- package/src/components/cards/Cards.test.tsx +41 -0
- package/src/components/cards/Cards.tsx +69 -0
- package/src/components/cards/index.ts +1 -0
- package/src/components/checkBox/CheckBox.interface.ts +10 -0
- package/src/components/checkBox/CheckBox.styles.ts +36 -0
- package/src/components/checkBox/CheckBox.test.tsx +46 -0
- package/src/components/checkBox/CheckBox.tsx +42 -0
- package/src/components/checkBox/index.ts +1 -0
- package/src/components/customDropdown/CustomDropdown.interface.ts +15 -0
- package/src/components/customDropdown/CustomDropdown.styles.tsx +46 -0
- package/src/components/customDropdown/CustomDropdown.test.tsx +30 -0
- package/src/components/customDropdown/CustomDropdown.tsx +106 -0
- package/src/components/customDropdown/index.ts +1 -0
- package/src/components/customInputText/CustomInputText.interface.ts +20 -0
- package/src/components/customInputText/CustomInputText.styles.ts +56 -0
- package/src/components/customInputText/CustomInputText.test.tsx +37 -0
- package/src/components/customInputText/CustomInputText.tsx +120 -0
- package/src/components/customInputText/index.ts +1 -0
- package/src/components/customText/CustomText.tsx +31 -0
- package/src/components/customText/index.ts +1 -0
- package/src/components/customTooltip/CustomTooltip.interface.ts +14 -0
- package/src/components/customTooltip/CustomTooltip.styles.ts +23 -0
- package/src/components/customTooltip/CustomTooltip.test.tsx +18 -0
- package/src/components/customTooltip/CustomTooltip.tsx +46 -0
- package/src/components/customTooltip/index.ts +1 -0
- package/src/components/customTypography/CustomTypography.tsx +25 -0
- package/src/components/fileUpload/FileUpload.styles.ts +41 -0
- package/src/components/fileUpload/FileUpload.test.tsx +39 -0
- package/src/components/fileUpload/FileUpload.tsx +65 -0
- package/src/components/fileUpload/index.ts +1 -0
- package/src/components/notification/Notification.interface.ts +61 -0
- package/src/components/notification/Notification.styles.ts +33 -0
- package/src/components/notification/Notification.test.tsx +116 -0
- package/src/components/notification/Notification.tsx +156 -0
- package/src/components/pdfView/PdfView.test.tsx +10 -0
- package/src/components/pdfView/PdfView.tsx +18 -0
- package/src/components/pdfView/index.ts +1 -0
- package/src/components/popup/PopUp.interface.ts +9 -0
- package/src/components/popup/PopUp.styles.ts +52 -0
- package/src/components/popup/PopUp.test.tsx +35 -0
- package/src/components/popup/PopUp.tsx +60 -0
- package/src/components/popup/index.ts +1 -0
- package/src/components/progressBar/ProgressBar.test.tsx +78 -0
- package/src/components/progressBar/ProgressBar.tsx +93 -0
- package/src/components/progressBar/index.ts +1 -0
- package/src/components/property360View/Property360View.test.tsx +24 -0
- package/src/components/property360View/Property360View.tsx +19 -0
- package/src/components/property360View/index.ts +1 -0
- package/src/components/rating/Rating.styles.ts +13 -0
- package/src/components/rating/Rating.test.tsx +61 -0
- package/src/components/rating/Rating.tsx +96 -0
- package/src/components/rating/index.ts +1 -0
- package/src/components/tabs/Tabs.interface.ts +13 -0
- package/src/components/tabs/Tabs.styles.ts +36 -0
- package/src/components/tabs/Tabs.test.tsx +20 -0
- package/src/components/tabs/Tabs.tsx +65 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tags/Tags.interface.ts +12 -0
- package/src/components/tags/Tags.styles.ts +36 -0
- package/src/components/tags/Tags.test.tsx +22 -0
- package/src/components/tags/Tags.tsx +76 -0
- package/src/components/tags/index.ts +1 -0
- package/src/components/toggleButton/ToggleButton.styles.ts +40 -0
- package/src/components/toggleButton/ToggleButton.test.tsx +33 -0
- package/src/components/toggleButton/ToggleButton.tsx +78 -0
- package/src/components/toggleButton/index.ts +1 -0
- package/src/index.ts +19 -0
- package/src/theme/ThemeContext.tsx +32 -0
- package/src/theme/colors.ts +156 -0
- package/src/theme/fonts.ts +303 -0
- package/src/theme/themes.ts +20 -0
- package/src/theme/withThemeProvider.tsx +14 -0
- package/src/utils/appEnum.ts +17 -0
- package/src/utils/commonStyles.ts +17 -0
- package/src/utils/constants.ts +17 -0
- package/src/utils/deviceUtils.ts +9 -0
- package/src/utils/regex.ts +1 -0
- package/src/utils/stylehelper.ts +13 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {ReactNode} from 'react';
|
|
2
|
+
import {ViewStyle} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface NotificationItem {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
isPinned: boolean;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ActionButtonProps {
|
|
12
|
+
icon: ReactNode;
|
|
13
|
+
title: string;
|
|
14
|
+
onPress: () => void;
|
|
15
|
+
style?: object;
|
|
16
|
+
testID: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ListItemProps {
|
|
20
|
+
item: NotificationItem;
|
|
21
|
+
leftPrimaryActionIcon?: ReactNode;
|
|
22
|
+
leftPrimaryActionTitle?: string;
|
|
23
|
+
leftPrimaryActionHandler?: (id: string) => void;
|
|
24
|
+
leftPrimaryActionStyle?: ViewStyle;
|
|
25
|
+
leftSecondaryActionIcon?: ReactNode;
|
|
26
|
+
leftSecondaryActionTitle?: string;
|
|
27
|
+
leftSecondaryActionHandler?: (id: string) => void;
|
|
28
|
+
leftSecondaryActionStyle?: ViewStyle;
|
|
29
|
+
rightPrimaryActionIcon?: ReactNode;
|
|
30
|
+
rightPrimaryActionTitle?: string;
|
|
31
|
+
rightPrimaryActionHandler?: (id: string) => void;
|
|
32
|
+
rightPrimaryActionStyle?: ViewStyle;
|
|
33
|
+
rightSecondaryActionIcon?: ReactNode;
|
|
34
|
+
rightSecondaryActionTitle?: string;
|
|
35
|
+
rightSecondaryActionHandler?: (id: string) => void;
|
|
36
|
+
rightSecondaryActionStyle?: ViewStyle;
|
|
37
|
+
itemStyle?: ViewStyle;
|
|
38
|
+
titleStyle?: ViewStyle;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface NotificationProps {
|
|
42
|
+
notifications: NotificationItem[];
|
|
43
|
+
leftPrimaryActionIcon?: ReactNode;
|
|
44
|
+
leftPrimaryActionTitle?: string;
|
|
45
|
+
leftPrimaryActionHandler?: (id: string) => void;
|
|
46
|
+
leftPrimaryActionStyle?: ViewStyle;
|
|
47
|
+
leftSecondaryActionIcon?: ReactNode;
|
|
48
|
+
leftSecondaryActionTitle?: string;
|
|
49
|
+
leftSecondaryActionHandler?: (id: string) => void;
|
|
50
|
+
leftSecondaryActionStyle?: ViewStyle;
|
|
51
|
+
rightPrimaryActionIcon?: ReactNode;
|
|
52
|
+
rightPrimaryActionTitle?: string;
|
|
53
|
+
rightPrimaryActionHandler?: (id: string) => void;
|
|
54
|
+
rightPrimaryActionStyle?: ViewStyle;
|
|
55
|
+
rightSecondaryActionIcon?: ReactNode;
|
|
56
|
+
rightSecondaryActionTitle?: string;
|
|
57
|
+
rightSecondaryActionHandler?: (id: string) => void;
|
|
58
|
+
rightSecondaryActionStyle?: ViewStyle;
|
|
59
|
+
itemStyle?: ViewStyle;
|
|
60
|
+
titleStyle?: ViewStyle;
|
|
61
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {DHRE_COLORS_ALERT} from '../../theme/colors';
|
|
2
|
+
import {horizontalScale, verticalScale} from '../../utils/stylehelper';
|
|
3
|
+
import {StyleSheet} from 'react-native';
|
|
4
|
+
|
|
5
|
+
export const styles = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
},
|
|
9
|
+
item: {
|
|
10
|
+
backgroundColor: DHRE_COLORS_ALERT.DH_ALERT_ORANGE_0,
|
|
11
|
+
padding: horizontalScale(20),
|
|
12
|
+
marginHorizontal: horizontalScale(8),
|
|
13
|
+
},
|
|
14
|
+
actionButton: {
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
padding: horizontalScale(12),
|
|
17
|
+
marginVertical: verticalScale(8),
|
|
18
|
+
},
|
|
19
|
+
leftActions: {
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
justifyContent: 'flex-start',
|
|
22
|
+
},
|
|
23
|
+
rightActions: {
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
justifyContent: 'flex-end',
|
|
26
|
+
},
|
|
27
|
+
sepratorView: {
|
|
28
|
+
marginVertical: verticalScale(8),
|
|
29
|
+
},
|
|
30
|
+
itemIconAlign: {
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {fireEvent, render} from '@testing-library/react-native';
|
|
3
|
+
import Notification from './Notification';
|
|
4
|
+
import {CalenderDots} from '../../assets';
|
|
5
|
+
|
|
6
|
+
jest.mock('react-native-gesture-handler', () => {
|
|
7
|
+
const mockGestureHandler = {
|
|
8
|
+
swipeable: jest.fn(),
|
|
9
|
+
gestureHandlerRootHOC: jest.fn(),
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
PanGestureHandler: mockGestureHandler,
|
|
13
|
+
TapGestureHandler: mockGestureHandler,
|
|
14
|
+
LongPressGestureHandler: mockGestureHandler,
|
|
15
|
+
State: {},
|
|
16
|
+
Directions: {},
|
|
17
|
+
Swipeable: jest
|
|
18
|
+
.fn()
|
|
19
|
+
.mockImplementation(
|
|
20
|
+
({children, renderLeftActions, renderRightActions}) => (
|
|
21
|
+
<div>
|
|
22
|
+
{renderLeftActions && renderLeftActions()}
|
|
23
|
+
{children}
|
|
24
|
+
{renderRightActions && renderRightActions()}
|
|
25
|
+
</div>
|
|
26
|
+
),
|
|
27
|
+
),
|
|
28
|
+
GestureHandlerRootView: jest
|
|
29
|
+
.fn()
|
|
30
|
+
.mockImplementation(({children}) => <div>{children}</div>),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const customStyle = {backgroundColor: 'red', padding: 20};
|
|
34
|
+
|
|
35
|
+
describe('Notification Component', () => {
|
|
36
|
+
const notifications = [
|
|
37
|
+
{id: '1', title: 'Notification 1', isPinned: false, isRead: true},
|
|
38
|
+
{id: '2', title: 'Notification 2', isPinned: true, isRead: false},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const notificationsPinned = [
|
|
42
|
+
{id: '1', title: 'Notification 1', isPinned: true, isRead: true},
|
|
43
|
+
{id: '2', title: 'Notification 2', isPinned: false, isRead: false},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const notificationsUnPinned = [
|
|
47
|
+
{id: '1', title: 'Notification 1', isPinned: false, isRead: false},
|
|
48
|
+
{id: '2', title: 'Notification 2', isPinned: false, isRead: false},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const mockLeftPrimaryActionHandler = jest.fn();
|
|
52
|
+
const mockRightPrimaryActionHandler = jest.fn();
|
|
53
|
+
const mockLeftSecondaryActionHandler = jest.fn();
|
|
54
|
+
const mockRightSecondaryActionHandler = jest.fn();
|
|
55
|
+
|
|
56
|
+
const commonProps = {
|
|
57
|
+
leftPrimaryActionIcon: <CalenderDots />,
|
|
58
|
+
leftPrimaryActionHandler: mockLeftPrimaryActionHandler,
|
|
59
|
+
leftPrimaryActionStyle: {backgroundColor: 'red'},
|
|
60
|
+
leftSecondaryActionIcon: <CalenderDots />,
|
|
61
|
+
leftSecondaryActionHandler: mockLeftSecondaryActionHandler,
|
|
62
|
+
leftSecondaryActionStyle: {backgroundColor: 'blue'},
|
|
63
|
+
rightPrimaryActionIcon: <CalenderDots />,
|
|
64
|
+
rightPrimaryActionHandler: mockRightPrimaryActionHandler,
|
|
65
|
+
rightPrimaryActionStyle: {backgroundColor: 'green'},
|
|
66
|
+
rightSecondaryActionIcon: <CalenderDots />,
|
|
67
|
+
rightSecondaryActionHandler: mockRightSecondaryActionHandler,
|
|
68
|
+
rightSecondaryActionStyle: {backgroundColor: 'yellow'},
|
|
69
|
+
itemStyle: customStyle,
|
|
70
|
+
titleStyle: customStyle,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const props = {
|
|
74
|
+
...commonProps,
|
|
75
|
+
notifications,
|
|
76
|
+
leftPrimaryActionTitle: 'Pin',
|
|
77
|
+
leftSecondaryActionTitle: 'Read',
|
|
78
|
+
rightPrimaryActionTitle: 'Delete',
|
|
79
|
+
rightSecondaryActionTitle: 'Archive',
|
|
80
|
+
};
|
|
81
|
+
const propsUnPinned = {
|
|
82
|
+
...commonProps,
|
|
83
|
+
notifications: notificationsUnPinned,
|
|
84
|
+
leftPrimaryActionTitle: 'Pin',
|
|
85
|
+
leftSecondaryActionTitle: 'Read',
|
|
86
|
+
rightPrimaryActionTitle: 'Delete',
|
|
87
|
+
rightSecondaryActionTitle: 'Archive',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const propsPinned = {
|
|
91
|
+
...commonProps,
|
|
92
|
+
notifications: notificationsPinned,
|
|
93
|
+
leftPrimaryActionTitle: '',
|
|
94
|
+
leftSecondaryActionTitle: '',
|
|
95
|
+
rightPrimaryActionTitle: '',
|
|
96
|
+
rightSecondaryActionTitle: '',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
it('renders Notification component correctly', () => {
|
|
100
|
+
const {getByTestId} = render(<Notification {...props} />);
|
|
101
|
+
expect(getByTestId('NOTIFICATION')).toBeTruthy();
|
|
102
|
+
fireEvent.press(getByTestId('leftPrimary-1'));
|
|
103
|
+
fireEvent.press(getByTestId('leftSecondary-1'));
|
|
104
|
+
fireEvent.press(getByTestId('rightPrimary-1'));
|
|
105
|
+
fireEvent.press(getByTestId('rightSecondary-1'));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('renders Notification component when pinned', () => {
|
|
109
|
+
const {getByTestId} = render(<Notification {...propsPinned} />);
|
|
110
|
+
expect(getByTestId('NOTIFICATION')).toBeTruthy();
|
|
111
|
+
});
|
|
112
|
+
it('renders Notification component when pinned', () => {
|
|
113
|
+
const {getByTestId} = render(<Notification {...propsUnPinned} />);
|
|
114
|
+
expect(getByTestId('NOTIFICATION')).toBeTruthy();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FlatList, View, Pressable} from 'react-native';
|
|
3
|
+
import {GestureHandlerRootView, Swipeable} from 'react-native-gesture-handler';
|
|
4
|
+
import {
|
|
5
|
+
ActionButtonProps,
|
|
6
|
+
ListItemProps,
|
|
7
|
+
NotificationItem,
|
|
8
|
+
NotificationProps,
|
|
9
|
+
} from './Notification.interface';
|
|
10
|
+
import {styles} from './Notification.styles';
|
|
11
|
+
import CustomTypography from '../customTypography/CustomTypography';
|
|
12
|
+
|
|
13
|
+
const Notification = ({
|
|
14
|
+
notifications,
|
|
15
|
+
leftPrimaryActionIcon,
|
|
16
|
+
leftPrimaryActionTitle,
|
|
17
|
+
leftPrimaryActionHandler,
|
|
18
|
+
leftPrimaryActionStyle,
|
|
19
|
+
leftSecondaryActionIcon,
|
|
20
|
+
leftSecondaryActionTitle,
|
|
21
|
+
leftSecondaryActionHandler,
|
|
22
|
+
leftSecondaryActionStyle,
|
|
23
|
+
rightPrimaryActionIcon,
|
|
24
|
+
rightPrimaryActionTitle,
|
|
25
|
+
rightPrimaryActionHandler,
|
|
26
|
+
rightPrimaryActionStyle,
|
|
27
|
+
rightSecondaryActionIcon,
|
|
28
|
+
rightSecondaryActionTitle,
|
|
29
|
+
rightSecondaryActionHandler,
|
|
30
|
+
rightSecondaryActionStyle,
|
|
31
|
+
itemStyle,
|
|
32
|
+
titleStyle,
|
|
33
|
+
}: NotificationProps) => {
|
|
34
|
+
const ActionButton = ({
|
|
35
|
+
icon,
|
|
36
|
+
title,
|
|
37
|
+
onPress,
|
|
38
|
+
style,
|
|
39
|
+
testID,
|
|
40
|
+
}: ActionButtonProps) => (
|
|
41
|
+
<Pressable
|
|
42
|
+
testID={testID}
|
|
43
|
+
onPress={onPress}
|
|
44
|
+
style={[styles.actionButton, style, styles.itemIconAlign]}>
|
|
45
|
+
{icon}
|
|
46
|
+
<CustomTypography variant="H9medium" style={titleStyle} text={title} />
|
|
47
|
+
</Pressable>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const leftActionHandle = item => (
|
|
51
|
+
<View style={[styles.leftActions, leftPrimaryActionStyle]}>
|
|
52
|
+
{leftPrimaryActionIcon && leftPrimaryActionHandler && (
|
|
53
|
+
<ActionButton
|
|
54
|
+
icon={leftPrimaryActionIcon}
|
|
55
|
+
title={leftPrimaryActionTitle || ''}
|
|
56
|
+
onPress={() => leftPrimaryActionHandler(item.id)}
|
|
57
|
+
style={leftPrimaryActionStyle}
|
|
58
|
+
testID={`leftPrimary-${item.id}`}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
{leftSecondaryActionIcon && leftSecondaryActionHandler && (
|
|
62
|
+
<ActionButton
|
|
63
|
+
icon={leftSecondaryActionIcon}
|
|
64
|
+
title={leftSecondaryActionTitle || ''}
|
|
65
|
+
onPress={() => leftSecondaryActionHandler(item.id)}
|
|
66
|
+
style={leftSecondaryActionStyle}
|
|
67
|
+
testID={`leftSecondary-${item.id}`}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const rightActionHandle = item => (
|
|
74
|
+
<View style={[styles.rightActions, rightPrimaryActionStyle]}>
|
|
75
|
+
{rightPrimaryActionIcon && rightPrimaryActionHandler && (
|
|
76
|
+
<ActionButton
|
|
77
|
+
icon={rightPrimaryActionIcon}
|
|
78
|
+
title={rightPrimaryActionTitle || ''}
|
|
79
|
+
onPress={() => rightPrimaryActionHandler(item.id)}
|
|
80
|
+
style={rightPrimaryActionStyle}
|
|
81
|
+
testID={`rightPrimary-${item.id}`}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
{rightSecondaryActionIcon && rightSecondaryActionHandler && (
|
|
85
|
+
<ActionButton
|
|
86
|
+
icon={rightSecondaryActionIcon}
|
|
87
|
+
title={rightSecondaryActionTitle || ''}
|
|
88
|
+
onPress={() => rightSecondaryActionHandler(item.id)}
|
|
89
|
+
style={rightSecondaryActionStyle}
|
|
90
|
+
testID={`rightSecondary-${item.id}`}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const ListItem = ({item, itemStyle, titleStyle}: ListItemProps) => (
|
|
97
|
+
<GestureHandlerRootView testID="LIST" style={styles.container}>
|
|
98
|
+
<Swipeable
|
|
99
|
+
renderLeftActions={() => leftActionHandle(item)}
|
|
100
|
+
renderRightActions={() => rightActionHandle(item)}>
|
|
101
|
+
<View style={[styles.item, itemStyle]}>
|
|
102
|
+
<CustomTypography
|
|
103
|
+
variant="H7medium"
|
|
104
|
+
style={titleStyle}
|
|
105
|
+
text={item?.title}
|
|
106
|
+
/>
|
|
107
|
+
</View>
|
|
108
|
+
</Swipeable>
|
|
109
|
+
</GestureHandlerRootView>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const sortData = (data: NotificationItem[]) => {
|
|
113
|
+
return data?.sort((a, b) => {
|
|
114
|
+
if (a.isPinned && !b.isPinned) return -1;
|
|
115
|
+
if (!a.isPinned && b.isPinned) return 1;
|
|
116
|
+
return 0;
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const renderItem = ({item}: {item: NotificationItem}) => (
|
|
121
|
+
<ListItem
|
|
122
|
+
item={item}
|
|
123
|
+
leftPrimaryActionIcon={leftPrimaryActionIcon}
|
|
124
|
+
leftPrimaryActionTitle={leftPrimaryActionTitle}
|
|
125
|
+
leftPrimaryActionHandler={leftPrimaryActionHandler}
|
|
126
|
+
leftPrimaryActionStyle={leftPrimaryActionStyle}
|
|
127
|
+
leftSecondaryActionIcon={leftSecondaryActionIcon}
|
|
128
|
+
leftSecondaryActionTitle={leftSecondaryActionTitle}
|
|
129
|
+
leftSecondaryActionHandler={leftSecondaryActionHandler}
|
|
130
|
+
leftSecondaryActionStyle={leftSecondaryActionStyle}
|
|
131
|
+
rightPrimaryActionIcon={rightPrimaryActionIcon}
|
|
132
|
+
rightPrimaryActionTitle={rightPrimaryActionTitle}
|
|
133
|
+
rightPrimaryActionHandler={rightPrimaryActionHandler}
|
|
134
|
+
rightPrimaryActionStyle={rightPrimaryActionStyle}
|
|
135
|
+
rightSecondaryActionIcon={rightSecondaryActionIcon}
|
|
136
|
+
rightSecondaryActionTitle={rightSecondaryActionTitle}
|
|
137
|
+
rightSecondaryActionHandler={rightSecondaryActionHandler}
|
|
138
|
+
rightSecondaryActionStyle={rightSecondaryActionStyle}
|
|
139
|
+
itemStyle={itemStyle}
|
|
140
|
+
titleStyle={titleStyle}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<View testID="NOTIFICATION">
|
|
146
|
+
<FlatList
|
|
147
|
+
data={sortData(notifications)}
|
|
148
|
+
renderItem={renderItem}
|
|
149
|
+
keyExtractor={item => item.id}
|
|
150
|
+
ItemSeparatorComponent={() => <View style={styles.sepratorView} />}
|
|
151
|
+
/>
|
|
152
|
+
</View>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default Notification;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render} from '@testing-library/react-native';
|
|
3
|
+
import PdfView from './PdfView';
|
|
4
|
+
|
|
5
|
+
describe('PdfView', () => {
|
|
6
|
+
it('renders the Pdf component with the correct source URI', () => {
|
|
7
|
+
const pdfResponse = 'base64encodedstring';
|
|
8
|
+
render(<PdfView pdfResponse={pdfResponse} />);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Pdf from 'react-native-pdf';
|
|
3
|
+
import commonStyles from '../../utils/commonStyles';
|
|
4
|
+
|
|
5
|
+
interface PDFViewProps {
|
|
6
|
+
pdfResponse: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const PdfView: React.FC<PDFViewProps> = ({pdfResponse}) => {
|
|
10
|
+
return (
|
|
11
|
+
<Pdf
|
|
12
|
+
source={{uri: `data:application/pdf;base64,${pdfResponse}`}}
|
|
13
|
+
style={commonStyles.flexOne}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default PdfView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './PdfView';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {DHRE_COLORS_BG, DHRE_COLORS_TEXT} from '../../theme/colors';
|
|
2
|
+
import {horizontalScale, verticalScale} from '../../utils/stylehelper';
|
|
3
|
+
import {StyleSheet} from 'react-native';
|
|
4
|
+
|
|
5
|
+
const styles = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
padding: horizontalScale(20),
|
|
8
|
+
marginHorizontal: horizontalScale(16),
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
|
|
11
|
+
},
|
|
12
|
+
subTitleBelow: {
|
|
13
|
+
color: DHRE_COLORS_TEXT.DH_TEXTDARK,
|
|
14
|
+
},
|
|
15
|
+
subtitle: {
|
|
16
|
+
letterSpacing: 0.5,
|
|
17
|
+
marginTop: verticalScale(8),
|
|
18
|
+
color: DHRE_COLORS_TEXT.DH_TEXTLIGHT,
|
|
19
|
+
marginBottom: verticalScale(24),
|
|
20
|
+
},
|
|
21
|
+
button: {
|
|
22
|
+
backgroundColor: DHRE_COLORS_TEXT.DH_BLACK,
|
|
23
|
+
paddingVertical: verticalScale(14),
|
|
24
|
+
paddingHorizontal: horizontalScale(34),
|
|
25
|
+
borderRadius: 50,
|
|
26
|
+
flex: 1,
|
|
27
|
+
},
|
|
28
|
+
buttonText: {
|
|
29
|
+
color: DHRE_COLORS_TEXT.DH_WHITE,
|
|
30
|
+
textAlign: 'center',
|
|
31
|
+
},
|
|
32
|
+
buttonLeft: {
|
|
33
|
+
backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
|
|
34
|
+
paddingVertical: verticalScale(14),
|
|
35
|
+
paddingHorizontal: horizontalScale(34),
|
|
36
|
+
borderRadius: 50,
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
flex: 1,
|
|
39
|
+
borderColor: DHRE_COLORS_BG.DH_GREY1,
|
|
40
|
+
},
|
|
41
|
+
buttonLeftText: {
|
|
42
|
+
color: DHRE_COLORS_TEXT.DH_BLACK,
|
|
43
|
+
textAlign: 'center',
|
|
44
|
+
},
|
|
45
|
+
buttonContainer: {
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
gap: horizontalScale(16),
|
|
48
|
+
justifyContent: 'space-between',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default styles;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {it} from '@jest/globals';
|
|
3
|
+
import {fireEvent, render} from '@testing-library/react-native';
|
|
4
|
+
import PopUp from './PopUp';
|
|
5
|
+
|
|
6
|
+
const mockProps = {
|
|
7
|
+
subtitle: 'SubTitle',
|
|
8
|
+
buttonText: 'Button',
|
|
9
|
+
title: 'Title',
|
|
10
|
+
leftButtonShown: true,
|
|
11
|
+
rightButtonShown: true,
|
|
12
|
+
testID: 'POPUP-COMPONENT',
|
|
13
|
+
onButtonPress: jest.fn(),
|
|
14
|
+
};
|
|
15
|
+
const mockWithoutDataProps = {
|
|
16
|
+
subtitle: undefined,
|
|
17
|
+
buttonText: undefined,
|
|
18
|
+
title: undefined,
|
|
19
|
+
leftButtonShown: false,
|
|
20
|
+
rightButtonShown: false,
|
|
21
|
+
testID: 'POPUP-COMPONENT',
|
|
22
|
+
onButtonPress: jest.fn(),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('PopUp Component', () => {
|
|
26
|
+
it('Component renders correctly', () => {
|
|
27
|
+
const {getByTestId} = render(<PopUp {...mockProps} />);
|
|
28
|
+
expect(getByTestId('POPUP-COMPONENT')).toBeTruthy();
|
|
29
|
+
fireEvent.press(getByTestId('Left-Button-Press'));
|
|
30
|
+
});
|
|
31
|
+
it('Component renders correctly when props data is not passed', () => {
|
|
32
|
+
const {getByTestId} = render(<PopUp {...mockWithoutDataProps} />);
|
|
33
|
+
expect(getByTestId('POPUP-COMPONENT')).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {View, Pressable} from 'react-native';
|
|
3
|
+
import styles from './PopUp.styles';
|
|
4
|
+
import {PopUpProps} from './PopUp.interface';
|
|
5
|
+
import CustomTypography from '../customTypography/CustomTypography';
|
|
6
|
+
|
|
7
|
+
const PopUp: React.FC<PopUpProps> = ({
|
|
8
|
+
subtitle,
|
|
9
|
+
title,
|
|
10
|
+
buttonText,
|
|
11
|
+
onButtonPress,
|
|
12
|
+
testID,
|
|
13
|
+
leftButtonShown = false,
|
|
14
|
+
rightButtonShown = false,
|
|
15
|
+
}: PopUpProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<View testID={testID} style={styles.container}>
|
|
18
|
+
{title ? (
|
|
19
|
+
<CustomTypography
|
|
20
|
+
style={styles.subTitleBelow}
|
|
21
|
+
variant="H6semiBold"
|
|
22
|
+
text={title}
|
|
23
|
+
/>
|
|
24
|
+
) : null}
|
|
25
|
+
{subtitle ? (
|
|
26
|
+
<CustomTypography
|
|
27
|
+
style={styles.subtitle}
|
|
28
|
+
variant="P3regular"
|
|
29
|
+
text={subtitle}
|
|
30
|
+
/>
|
|
31
|
+
) : null}
|
|
32
|
+
|
|
33
|
+
<View style={styles.buttonContainer}>
|
|
34
|
+
{leftButtonShown ? (
|
|
35
|
+
<Pressable
|
|
36
|
+
testID="Left-Button-Press"
|
|
37
|
+
style={styles.buttonLeft}
|
|
38
|
+
onPress={onButtonPress}>
|
|
39
|
+
<CustomTypography
|
|
40
|
+
style={styles.buttonLeftText}
|
|
41
|
+
variant="B2semiBold"
|
|
42
|
+
text={buttonText}
|
|
43
|
+
/>
|
|
44
|
+
</Pressable>
|
|
45
|
+
) : null}
|
|
46
|
+
{rightButtonShown ? (
|
|
47
|
+
<Pressable style={styles.button} onPress={onButtonPress}>
|
|
48
|
+
<CustomTypography
|
|
49
|
+
style={styles.buttonText}
|
|
50
|
+
variant="B2semiBold"
|
|
51
|
+
text={buttonText}
|
|
52
|
+
/>
|
|
53
|
+
</Pressable>
|
|
54
|
+
) : null}
|
|
55
|
+
</View>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default PopUp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './PopUp';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render, act} from '@testing-library/react-native';
|
|
3
|
+
import CustomProgressBar from './ProgressBar';
|
|
4
|
+
import {ShapeType} from '../../utils/appEnum';
|
|
5
|
+
|
|
6
|
+
jest.mock('react-native-progress', () => ({
|
|
7
|
+
Bar: jest.fn(),
|
|
8
|
+
Circle: jest.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
12
|
+
|
|
13
|
+
describe('CustomProgressBar', () => {
|
|
14
|
+
it('updates progress correctly', () => {
|
|
15
|
+
jest.useFakeTimers();
|
|
16
|
+
|
|
17
|
+
const {getByTestId} = render(
|
|
18
|
+
<CustomProgressBar
|
|
19
|
+
value={50}
|
|
20
|
+
type={ShapeType.LINE}
|
|
21
|
+
width={0}
|
|
22
|
+
fillColor={''}
|
|
23
|
+
unfilledColor={''}
|
|
24
|
+
progress={0}
|
|
25
|
+
setProgress={function (): void {}}
|
|
26
|
+
/>,
|
|
27
|
+
);
|
|
28
|
+
const lineProgressBar = getByTestId('custom-progress-bar');
|
|
29
|
+
for (let i = 0; i < 5; i++) {
|
|
30
|
+
act(() => {
|
|
31
|
+
jest.advanceTimersByTime(100);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
expect(lineProgressBar.props.progress).toBeUndefined();
|
|
36
|
+
while (lineProgressBar.props.progress < 1) {
|
|
37
|
+
act(() => {
|
|
38
|
+
jest.advanceTimersByTime(100);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (typeof lineProgressBar.props.progress === 'number') {
|
|
42
|
+
expect(lineProgressBar.props.progress).toBeCloseTo(1);
|
|
43
|
+
}
|
|
44
|
+
jest.useRealTimers();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('CustomProgressBar', () => {
|
|
48
|
+
it('renders a line progress bar with initial progress and color', () => {
|
|
49
|
+
const {getByTestId} = render(
|
|
50
|
+
<CustomProgressBar
|
|
51
|
+
value={50}
|
|
52
|
+
type={ShapeType.LINE}
|
|
53
|
+
width={0}
|
|
54
|
+
fillColor={''}
|
|
55
|
+
unfilledColor={''}
|
|
56
|
+
progress={0}
|
|
57
|
+
setProgress={function (): void {}}
|
|
58
|
+
/>,
|
|
59
|
+
);
|
|
60
|
+
const lineProgressBar = getByTestId('custom-progress-bar');
|
|
61
|
+
expect(lineProgressBar).toBeTruthy();
|
|
62
|
+
});
|
|
63
|
+
it('renders a line progress bar with initial progress and color', () => {
|
|
64
|
+
const {getByTestId} = render(
|
|
65
|
+
<CustomProgressBar
|
|
66
|
+
value={50}
|
|
67
|
+
type={ShapeType.CIRCLE}
|
|
68
|
+
width={0}
|
|
69
|
+
fillColor={''}
|
|
70
|
+
unfilledColor={''}
|
|
71
|
+
progress={0}
|
|
72
|
+
setProgress={function (): void {}}
|
|
73
|
+
/>,
|
|
74
|
+
);
|
|
75
|
+
const lineProgressBar = getByTestId('custom-progress-bar');
|
|
76
|
+
expect(lineProgressBar).toBeTruthy();
|
|
77
|
+
});
|
|
78
|
+
});
|