dhre-ui-kit 0.0.2 → 0.0.4
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 +4 -4
- package/src/assets/images/arrowLeft.svg +3 -0
- package/src/assets/images/caretDown.svg +3 -0
- package/src/assets/images/caretLeft.svg +3 -0
- package/src/assets/images/caretUp.svg +3 -0
- package/src/assets/images/circleTick.svg +3 -0
- package/src/assets/images/crossIcon.svg +3 -0
- package/src/assets/images/dotsThreeVertical.svg +5 -0
- package/src/assets/images/searchIcon.svg +4 -0
- package/src/assets/index.ts +20 -1
- package/src/components/accordion/Accordion.interface.ts +7 -0
- package/src/components/accordion/Accordion.styles.ts +28 -0
- package/src/components/accordion/Accordion.test.tsx +21 -0
- package/src/components/accordion/Accordion.tsx +64 -0
- package/src/components/accordion/index.ts +1 -0
- package/src/components/badge/Badge.test.tsx +12 -0
- package/src/components/badge/Badge.tsx +2 -1
- package/src/components/bottomDrawer/BottomDrawer.interface.ts +5 -0
- package/src/components/bottomDrawer/BottomDrawer.styles.ts +18 -10
- package/src/components/bottomDrawer/BottomDrawer.tsx +29 -12
- package/src/components/button/Button.interface.ts +0 -2
- package/src/components/button/Button.tsx +2 -7
- package/src/components/customHeader/CustomHeader.interface.tsx +10 -0
- package/src/components/customHeader/CustomHeader.styles.ts +24 -0
- package/src/components/customHeader/CustomHeader.test.tsx +14 -0
- package/src/components/customHeader/CustomHeader.tsx +46 -0
- package/src/components/customHeader/index.ts +1 -0
- package/src/components/customSearchBar/CustomSearchBar.interface.ts +9 -0
- package/src/components/customSearchBar/CustomSearchBar.styles.ts +23 -0
- package/src/components/customSearchBar/CustomSearchBar.test.tsx +19 -0
- package/src/components/customSearchBar/CustomSearchBar.tsx +55 -0
- package/src/components/customSearchBar/index.ts +1 -0
- package/src/components/customText/CustomText.tsx +3 -3
- package/src/components/customTypography/CustomTypography.test.tsx +12 -0
- package/src/components/customTypography/CustomTypography.tsx +5 -3
- package/src/components/swipableList/SwipableList.interface.ts +37 -0
- package/src/components/swipableList/SwipableList.styles.ts +24 -0
- package/src/components/{notification/Notification.test.tsx → swipableList/SwipableList.test.tsx} +20 -21
- package/src/components/swipableList/SwipableList.tsx +106 -0
- package/src/components/swipableList/index.ts +1 -0
- package/src/components/toast/Toast.interface.ts +8 -0
- package/src/components/toast/Toast.styles.ts +40 -0
- package/src/components/toast/Toast.test.tsx +21 -0
- package/src/components/toast/Toast.tsx +89 -0
- package/src/components/toast/index.ts +1 -0
- package/src/index.ts +5 -0
- package/src/theme/ThemeContext.tsx +6 -6
- package/src/theme/fonts.ts +8 -0
- package/src/utils/stylehelper.ts +1 -1
- package/src/components/notification/Notification.interface.ts +0 -61
- package/src/components/notification/Notification.styles.ts +0 -33
- package/src/components/notification/Notification.tsx +0 -156
|
@@ -9,17 +9,17 @@ interface CustomTextProps extends TextProps {
|
|
|
9
9
|
text: string;
|
|
10
10
|
variant: keyof typeof FONT_STYLES | string;
|
|
11
11
|
style?: TextStyle;
|
|
12
|
-
textColor?:string
|
|
12
|
+
textColor?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const CustomText: React.FC<CustomTextProps> = ({
|
|
16
16
|
text,
|
|
17
17
|
style,
|
|
18
18
|
variant,
|
|
19
|
-
textColor='SURFACE_STATIC',
|
|
19
|
+
textColor = 'SURFACE_STATIC',
|
|
20
20
|
...props
|
|
21
21
|
}) => {
|
|
22
|
-
const {
|
|
22
|
+
const {theme} = useTheme();
|
|
23
23
|
return (
|
|
24
24
|
<CustomTypography
|
|
25
25
|
variant={variant}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render} from '@testing-library/react-native';
|
|
3
|
+
import CustomTypography from './CustomTypography';
|
|
4
|
+
|
|
5
|
+
describe('CustomTypography Component', () => {
|
|
6
|
+
it('renders text correctly', () => {
|
|
7
|
+
const {getByTestId} = render(
|
|
8
|
+
<CustomTypography variant={'H1_BOLD'} text={'TESTING TEXT'} />,
|
|
9
|
+
);
|
|
10
|
+
expect(getByTestId('CUSTOM_TYPOGRAPHY')).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {FONT_STYLES} from '../../theme/fonts';
|
|
3
2
|
import {Text, TextProps} from 'react-native';
|
|
3
|
+
import {FONT_STYLES} from '../../theme/fonts';
|
|
4
4
|
|
|
5
5
|
interface TypoTextProps extends TextProps {
|
|
6
|
-
variant: keyof typeof FONT_STYLES
|
|
6
|
+
variant: keyof typeof FONT_STYLES;
|
|
7
7
|
text?: string;
|
|
8
|
+
testID?: string;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
const CustomTypography: React.FC<TypoTextProps> = ({
|
|
11
12
|
variant,
|
|
12
13
|
style,
|
|
13
14
|
text,
|
|
15
|
+
testID = 'CUSTOM_TYPOGRAPHY',
|
|
14
16
|
...props
|
|
15
17
|
}) => {
|
|
16
18
|
const textStyle = FONT_STYLES[variant];
|
|
17
19
|
|
|
18
20
|
return (
|
|
19
|
-
<Text testID=
|
|
21
|
+
<Text testID={testID} style={[textStyle, style]} {...props}>
|
|
20
22
|
{text}
|
|
21
23
|
</Text>
|
|
22
24
|
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {ReactNode} from 'react';
|
|
2
|
+
import {ViewStyle} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface ListItem {
|
|
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 SwipableListProps {
|
|
20
|
+
data: ListItem[];
|
|
21
|
+
testId?: string;
|
|
22
|
+
renderItem: (item: ListItem) => ReactNode;
|
|
23
|
+
leftPrimaryActionIcon?: ReactNode;
|
|
24
|
+
leftPrimaryActionTitle?: string;
|
|
25
|
+
leftPrimaryActionHandler?: (id: string) => void;
|
|
26
|
+
leftPrimaryActionStyle?: ViewStyle;
|
|
27
|
+
leftSecondaryActionIcon?: ReactNode;
|
|
28
|
+
leftSecondaryActionTitle?: string;
|
|
29
|
+
leftSecondaryActionHandler?: (id: string) => void;
|
|
30
|
+
leftSecondaryActionStyle?: ViewStyle;
|
|
31
|
+
rightPrimaryActionIcon?: ReactNode;
|
|
32
|
+
rightPrimaryActionTitle?: string;
|
|
33
|
+
rightPrimaryActionHandler?: (id: string) => void;
|
|
34
|
+
rightPrimaryActionStyle?: ViewStyle;
|
|
35
|
+
itemStyle?: ViewStyle;
|
|
36
|
+
titleStyle?: ViewStyle;
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {moderateScale, verticalScale} from '../../utils/stylehelper';
|
|
2
|
+
import {StyleSheet} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
},
|
|
8
|
+
actionButton: {
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
padding: moderateScale(24),
|
|
12
|
+
},
|
|
13
|
+
leftActions: {
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
justifyContent: 'flex-start',
|
|
16
|
+
},
|
|
17
|
+
rightActions: {
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
justifyContent: 'flex-end',
|
|
20
|
+
},
|
|
21
|
+
seprator: {
|
|
22
|
+
height: verticalScale(16),
|
|
23
|
+
},
|
|
24
|
+
});
|
package/src/components/{notification/Notification.test.tsx → swipableList/SwipableList.test.tsx}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {fireEvent, render} from '@testing-library/react-native';
|
|
3
|
-
import
|
|
3
|
+
import SwipableList from './SwipableList';
|
|
4
4
|
import {CalenderDots} from '../../assets';
|
|
5
|
+
import {Text} from 'react-native';
|
|
5
6
|
|
|
6
7
|
jest.mock('react-native-gesture-handler', () => {
|
|
7
8
|
const mockGestureHandler = {
|
|
@@ -51,7 +52,6 @@ describe('Notification Component', () => {
|
|
|
51
52
|
const mockLeftPrimaryActionHandler = jest.fn();
|
|
52
53
|
const mockRightPrimaryActionHandler = jest.fn();
|
|
53
54
|
const mockLeftSecondaryActionHandler = jest.fn();
|
|
54
|
-
const mockRightSecondaryActionHandler = jest.fn();
|
|
55
55
|
|
|
56
56
|
const commonProps = {
|
|
57
57
|
leftPrimaryActionIcon: <CalenderDots />,
|
|
@@ -63,54 +63,53 @@ describe('Notification Component', () => {
|
|
|
63
63
|
rightPrimaryActionIcon: <CalenderDots />,
|
|
64
64
|
rightPrimaryActionHandler: mockRightPrimaryActionHandler,
|
|
65
65
|
rightPrimaryActionStyle: {backgroundColor: 'green'},
|
|
66
|
-
rightSecondaryActionIcon: <CalenderDots />,
|
|
67
|
-
rightSecondaryActionHandler: mockRightSecondaryActionHandler,
|
|
68
|
-
rightSecondaryActionStyle: {backgroundColor: 'yellow'},
|
|
69
66
|
itemStyle: customStyle,
|
|
70
67
|
titleStyle: customStyle,
|
|
71
68
|
};
|
|
72
69
|
|
|
73
70
|
const props = {
|
|
74
71
|
...commonProps,
|
|
75
|
-
notifications,
|
|
72
|
+
data: notifications,
|
|
76
73
|
leftPrimaryActionTitle: 'Pin',
|
|
77
74
|
leftSecondaryActionTitle: 'Read',
|
|
78
75
|
rightPrimaryActionTitle: 'Delete',
|
|
79
|
-
rightSecondaryActionTitle: 'Archive',
|
|
80
76
|
};
|
|
81
77
|
const propsUnPinned = {
|
|
82
78
|
...commonProps,
|
|
83
|
-
|
|
79
|
+
data: notificationsUnPinned,
|
|
84
80
|
leftPrimaryActionTitle: 'Pin',
|
|
85
81
|
leftSecondaryActionTitle: 'Read',
|
|
86
82
|
rightPrimaryActionTitle: 'Delete',
|
|
87
|
-
rightSecondaryActionTitle: 'Archive',
|
|
88
83
|
};
|
|
89
84
|
|
|
90
85
|
const propsPinned = {
|
|
91
86
|
...commonProps,
|
|
92
|
-
|
|
87
|
+
data: notificationsPinned,
|
|
93
88
|
leftPrimaryActionTitle: '',
|
|
94
89
|
leftSecondaryActionTitle: '',
|
|
95
90
|
rightPrimaryActionTitle: '',
|
|
96
|
-
rightSecondaryActionTitle: '',
|
|
97
91
|
};
|
|
98
92
|
|
|
99
93
|
it('renders Notification component correctly', () => {
|
|
100
|
-
const {getByTestId} = render(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
fireEvent.press(getByTestId('
|
|
105
|
-
fireEvent.press(getByTestId('
|
|
94
|
+
const {getByTestId} = render(
|
|
95
|
+
<SwipableList {...props} renderItem={() => <Text>Title</Text>} />,
|
|
96
|
+
);
|
|
97
|
+
expect(getByTestId('SWIPABLE-LIST')).toBeTruthy();
|
|
98
|
+
fireEvent.press(getByTestId('SWIPABLE-LIST-LEFT-PRIMARY-1'));
|
|
99
|
+
fireEvent.press(getByTestId('SWIPABLE-LIST-LEFT-SECONDARY-1'));
|
|
100
|
+
fireEvent.press(getByTestId('SWIPABLE-LIST-RIGHT-PRIMARY-1'));
|
|
106
101
|
});
|
|
107
102
|
|
|
108
103
|
it('renders Notification component when pinned', () => {
|
|
109
|
-
const {getByTestId} = render(
|
|
110
|
-
|
|
104
|
+
const {getByTestId} = render(
|
|
105
|
+
<SwipableList {...propsPinned} renderItem={() => <Text>Title</Text>} />,
|
|
106
|
+
);
|
|
107
|
+
expect(getByTestId('SWIPABLE-LIST')).toBeTruthy();
|
|
111
108
|
});
|
|
112
109
|
it('renders Notification component when pinned', () => {
|
|
113
|
-
const {getByTestId} = render(
|
|
114
|
-
|
|
110
|
+
const {getByTestId} = render(
|
|
111
|
+
<SwipableList {...propsUnPinned} renderItem={() => <Text>Title</Text>} />,
|
|
112
|
+
);
|
|
113
|
+
expect(getByTestId('SWIPABLE-LIST')).toBeTruthy();
|
|
115
114
|
});
|
|
116
115
|
});
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
ListItem,
|
|
7
|
+
SwipableListProps,
|
|
8
|
+
} from './SwipableList.interface';
|
|
9
|
+
import {styles} from './SwipableList.styles';
|
|
10
|
+
import CustomTypography from '../customTypography/CustomTypography';
|
|
11
|
+
|
|
12
|
+
const SwipableList = (props: SwipableListProps) => {
|
|
13
|
+
const {
|
|
14
|
+
data,
|
|
15
|
+
testId = 'SWIPABLE-LIST',
|
|
16
|
+
leftPrimaryActionIcon,
|
|
17
|
+
leftPrimaryActionTitle,
|
|
18
|
+
leftPrimaryActionHandler,
|
|
19
|
+
leftPrimaryActionStyle,
|
|
20
|
+
leftSecondaryActionIcon,
|
|
21
|
+
leftSecondaryActionTitle,
|
|
22
|
+
leftSecondaryActionHandler,
|
|
23
|
+
leftSecondaryActionStyle,
|
|
24
|
+
rightPrimaryActionIcon,
|
|
25
|
+
rightPrimaryActionTitle,
|
|
26
|
+
rightPrimaryActionHandler,
|
|
27
|
+
rightPrimaryActionStyle,
|
|
28
|
+
titleStyle,
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const ActionButton = ({
|
|
32
|
+
icon,
|
|
33
|
+
title,
|
|
34
|
+
onPress,
|
|
35
|
+
style,
|
|
36
|
+
testID,
|
|
37
|
+
}: ActionButtonProps) => (
|
|
38
|
+
<Pressable
|
|
39
|
+
testID={testID}
|
|
40
|
+
onPress={onPress}
|
|
41
|
+
style={[styles.actionButton, style]}>
|
|
42
|
+
{icon}
|
|
43
|
+
<CustomTypography variant="L1_REGULAR" style={titleStyle} text={title} />
|
|
44
|
+
</Pressable>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const leftActionHandle = item => (
|
|
48
|
+
<View style={[styles.leftActions, leftPrimaryActionStyle]}>
|
|
49
|
+
{leftPrimaryActionIcon && (
|
|
50
|
+
<ActionButton
|
|
51
|
+
icon={leftPrimaryActionIcon}
|
|
52
|
+
title={leftPrimaryActionTitle || ''}
|
|
53
|
+
onPress={() => leftPrimaryActionHandler?.(item.id)}
|
|
54
|
+
style={leftPrimaryActionStyle}
|
|
55
|
+
testID={`${testId}-LEFT-PRIMARY-${item.id}`}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
{leftSecondaryActionIcon && (
|
|
59
|
+
<ActionButton
|
|
60
|
+
icon={leftSecondaryActionIcon}
|
|
61
|
+
title={leftSecondaryActionTitle || ''}
|
|
62
|
+
onPress={() => leftSecondaryActionHandler?.(item.id)}
|
|
63
|
+
style={leftSecondaryActionStyle}
|
|
64
|
+
testID={`${testId}-LEFT-SECONDARY-${item.id}`}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
</View>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const rightActionHandle = item => (
|
|
71
|
+
<View style={[styles.rightActions, rightPrimaryActionStyle]}>
|
|
72
|
+
{rightPrimaryActionIcon && (
|
|
73
|
+
<ActionButton
|
|
74
|
+
icon={rightPrimaryActionIcon}
|
|
75
|
+
title={rightPrimaryActionTitle || ''}
|
|
76
|
+
onPress={() => rightPrimaryActionHandler?.(item.id)}
|
|
77
|
+
style={rightPrimaryActionStyle}
|
|
78
|
+
testID={`${testId}-RIGHT-PRIMARY-${item.id}`}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const renderItem = ({item}: {item: ListItem}) => (
|
|
85
|
+
<GestureHandlerRootView testID={`${testId}-LIST`} style={styles.container}>
|
|
86
|
+
<Swipeable
|
|
87
|
+
renderLeftActions={() => leftActionHandle(item)}
|
|
88
|
+
renderRightActions={() => rightActionHandle(item)}>
|
|
89
|
+
{props?.renderItem(item)}
|
|
90
|
+
</Swipeable>
|
|
91
|
+
</GestureHandlerRootView>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<View testID={testId}>
|
|
96
|
+
<FlatList
|
|
97
|
+
data={data}
|
|
98
|
+
renderItem={renderItem}
|
|
99
|
+
keyExtractor={item => item.id}
|
|
100
|
+
ItemSeparatorComponent={() => <View style={styles.seprator} />}
|
|
101
|
+
/>
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default SwipableList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './SwipableList';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
horizontalScale,
|
|
4
|
+
moderateScale,
|
|
5
|
+
verticalScale,
|
|
6
|
+
width,
|
|
7
|
+
} from '../../utils/stylehelper';
|
|
8
|
+
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
height: verticalScale(72),
|
|
13
|
+
width: width - horizontalScale(48),
|
|
14
|
+
top: 56,
|
|
15
|
+
borderRadius: moderateScale(8),
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
},
|
|
18
|
+
toastContainer: {flex: 1, justifyContent: 'center'},
|
|
19
|
+
innerContainer: {
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
paddingHorizontal: horizontalScale(12),
|
|
23
|
+
},
|
|
24
|
+
icon: {
|
|
25
|
+
marginRight: 9,
|
|
26
|
+
},
|
|
27
|
+
messageText: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
color: '#fff',
|
|
30
|
+
},
|
|
31
|
+
button: {
|
|
32
|
+
marginLeft: 9,
|
|
33
|
+
},
|
|
34
|
+
buttonText: {
|
|
35
|
+
textDecorationLine: 'underline',
|
|
36
|
+
color: '#fff',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export default styles;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render} from '@testing-library/react-native';
|
|
3
|
+
import Toast from './Toast';
|
|
4
|
+
|
|
5
|
+
jest.mock('react-native-progress', () => ({
|
|
6
|
+
Bar: props => <div {...props} />,
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe('Toast Component', () => {
|
|
10
|
+
it('Component renders correctly', () => {
|
|
11
|
+
const {getByTestId} = render(
|
|
12
|
+
<Toast
|
|
13
|
+
message="Test message"
|
|
14
|
+
setToast={jest.fn()}
|
|
15
|
+
btnText="Undo"
|
|
16
|
+
onBtnPress={jest.fn()}
|
|
17
|
+
/>,
|
|
18
|
+
);
|
|
19
|
+
expect(getByTestId('TOAST')).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, {useEffect, useState} from 'react';
|
|
2
|
+
import {View, Animated, Pressable} from 'react-native';
|
|
3
|
+
import * as Progress from 'react-native-progress';
|
|
4
|
+
import {CrossIcon, CircleTick} from '../../assets';
|
|
5
|
+
import CustomTypography from '../customTypography/CustomTypography';
|
|
6
|
+
import {horizontalScale, moderateScale, width} from '../../utils/stylehelper';
|
|
7
|
+
import {ToastProps} from './Toast.interface';
|
|
8
|
+
import styles from './Toast.styles';
|
|
9
|
+
|
|
10
|
+
const Toast = ({
|
|
11
|
+
message,
|
|
12
|
+
testId = 'TOAST',
|
|
13
|
+
isSuccess = true,
|
|
14
|
+
btnText,
|
|
15
|
+
onBtnPress,
|
|
16
|
+
setToast,
|
|
17
|
+
}: ToastProps) => {
|
|
18
|
+
const [progress, setProgress] = useState(0);
|
|
19
|
+
const bottom = React.useRef(new Animated.Value(-80)).current;
|
|
20
|
+
|
|
21
|
+
function animate() {
|
|
22
|
+
Animated.timing(bottom, {
|
|
23
|
+
toValue: 20,
|
|
24
|
+
duration: 2000,
|
|
25
|
+
useNativeDriver: false,
|
|
26
|
+
}).start(() => {
|
|
27
|
+
setToast(false);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
animate();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
const simulateProgress = () => {
|
|
36
|
+
setProgress(prev => (prev + 0.1 > 1 ? 1 : prev + 0.1));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const interval = setInterval(simulateProgress, 180);
|
|
41
|
+
return () => clearInterval(interval);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Animated.View
|
|
46
|
+
style={[
|
|
47
|
+
styles.container,
|
|
48
|
+
{bottom},
|
|
49
|
+
{backgroundColor: isSuccess ? '#04743F' : '#DB3056'},
|
|
50
|
+
]}
|
|
51
|
+
testID={testId}>
|
|
52
|
+
<View style={styles.toastContainer}>
|
|
53
|
+
<View style={styles.innerContainer}>
|
|
54
|
+
{React.cloneElement(isSuccess ? <CircleTick /> : <CrossIcon />, {
|
|
55
|
+
width: moderateScale(20),
|
|
56
|
+
height: moderateScale(20),
|
|
57
|
+
style: styles.icon,
|
|
58
|
+
})}
|
|
59
|
+
<CustomTypography
|
|
60
|
+
variant={'L2_REGULAR'}
|
|
61
|
+
text={message}
|
|
62
|
+
style={styles.messageText}
|
|
63
|
+
/>
|
|
64
|
+
{btnText ? (
|
|
65
|
+
<Pressable
|
|
66
|
+
style={styles.button}
|
|
67
|
+
onPress={onBtnPress}
|
|
68
|
+
testID={`${testId}-BTN`}>
|
|
69
|
+
<CustomTypography
|
|
70
|
+
variant={'L2_BOLD'}
|
|
71
|
+
text={btnText}
|
|
72
|
+
style={styles.buttonText}
|
|
73
|
+
/>
|
|
74
|
+
</Pressable>
|
|
75
|
+
) : null}
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
78
|
+
<Progress.Bar
|
|
79
|
+
progress={progress}
|
|
80
|
+
width={width - horizontalScale(48)}
|
|
81
|
+
height={3}
|
|
82
|
+
color={isSuccess ? '#024324' : '#851D41'}
|
|
83
|
+
borderColor="transparent"
|
|
84
|
+
/>
|
|
85
|
+
</Animated.View>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default Toast;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './Toast';
|
package/src/index.ts
CHANGED
|
@@ -17,3 +17,8 @@ export {default as StarRating} from './components/rating';
|
|
|
17
17
|
export {default as Tabs} from './components/tabs';
|
|
18
18
|
export {default as Tags} from './components/tags';
|
|
19
19
|
export {default as ToggleButton} from './components/toggleButton';
|
|
20
|
+
export {default as Accordion} from './components/accordion';
|
|
21
|
+
export {default as Toast} from './components/toast';
|
|
22
|
+
export {default as CustomSearchBar} from './components/customSearchBar';
|
|
23
|
+
export {default as CustomHeader} from './components/customHeader';
|
|
24
|
+
export {default as SwipableList} from './components/swipableList';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {createContext, useContext, ReactNode} from 'react';
|
|
2
|
-
|
|
3
2
|
import {useSelector} from 'react-redux';
|
|
4
3
|
import theme from './themes';
|
|
5
4
|
|
|
@@ -13,9 +12,10 @@ interface ThemeProviderProps {
|
|
|
13
12
|
children: ReactNode;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export const ThemeProvider: React.FC<ThemeProviderProps> = ({
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const ThemeProvider: React.FC<ThemeProviderProps> = ({children}) => {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
const mode = useSelector((state: any) => state.theme.currentTheme);
|
|
18
|
+
// const mode = 'light'
|
|
19
19
|
// Filter the theme based on the mode (light or dark)
|
|
20
20
|
const filteredTheme = Object.keys(theme).reduce((acc, key) => {
|
|
21
21
|
acc[key] = theme[key][mode];
|
|
@@ -23,12 +23,12 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
|
|
|
23
23
|
}, {} as Record<string, string>);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<ThemeContext.Provider value={{
|
|
26
|
+
<ThemeContext.Provider value={{theme: filteredTheme}}>
|
|
27
27
|
{children}
|
|
28
28
|
</ThemeContext.Provider>
|
|
29
29
|
);
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
export const useTheme = (): ThemeContextType => {
|
|
33
33
|
const context = useContext(ThemeContext);
|
|
34
34
|
if (context === undefined) {
|
package/src/theme/fonts.ts
CHANGED
|
@@ -15,6 +15,14 @@ const createFontStyle = (
|
|
|
15
15
|
fontFamily,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
export const meraasActivFontfamily: TextStyle = {
|
|
19
|
+
fontFamily: 'MeraasAktiv_Rg',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const serifActivFontfamily: TextStyle = {
|
|
23
|
+
fontFamily: 'PT Serif',
|
|
24
|
+
};
|
|
25
|
+
|
|
18
26
|
export const FONT_STYLES: FontStyles = {
|
|
19
27
|
// Bold headding styles
|
|
20
28
|
H1_BOLD: createFontStyle('MeraasAktiv_Bd', 40, 56),
|
package/src/utils/stylehelper.ts
CHANGED
|
@@ -10,4 +10,4 @@ const verticalScale = (size: number) => (height / guidelineBaseHeight) * size;
|
|
|
10
10
|
const moderateScale = (size: number, factor = 0.5) =>
|
|
11
11
|
size + (horizontalScale(size) - size) * factor;
|
|
12
12
|
|
|
13
|
-
export {horizontalScale, verticalScale, moderateScale};
|
|
13
|
+
export {horizontalScale, verticalScale, moderateScale, width, height};
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
});
|