dhre-ui-kit 0.0.36 → 0.0.38

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.
@@ -19,3 +19,6 @@ jest.mock('react-native-webview', () => {
19
19
  jest.mock('react-redux', () => ({
20
20
  useSelector: jest.fn(),
21
21
  }));
22
+ jest.mock('react-native-gesture-handler', () => ({
23
+ PanGestureHandler: jest.fn(({children}) => children),
24
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhre-ui-kit",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -11,6 +11,7 @@ export interface BottomDrawerProps {
11
11
  modalContainerStyle?: ViewStyle;
12
12
  blurAmount?: number;
13
13
  blurViewStyle?: ViewStyle;
14
+ showBlurView?: boolean;
14
15
  leftIcon?: React.ReactElement;
15
16
  rightIcon?: React.ReactElement;
16
17
  showLeftIcon?: boolean;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import {View, Modal} from 'react-native';
3
+ import {PanGestureHandler} from 'react-native-gesture-handler';
3
4
  import {BlurView} from '@react-native-community/blur';
4
5
  import {BottomDrawerProps} from './BottomDrawer.interface';
5
6
  import styles from './BottomDrawer.styles';
@@ -17,6 +18,7 @@ const BottomDrawer: React.FC<BottomDrawerProps> = ({
17
18
  modalContainerStyle,
18
19
  blurAmount = 10,
19
20
  blurViewStyle,
21
+ showBlurView = true,
20
22
  showLeftIcon = false,
21
23
  showRightIcon = true,
22
24
  leftIcon = <ArrowLeft />,
@@ -25,44 +27,55 @@ const BottomDrawer: React.FC<BottomDrawerProps> = ({
25
27
  titleStyle,
26
28
  titleVariant = 'B2_REGULAR',
27
29
  }) => {
30
+ const onSwipDown = (event: {nativeEvent: {translationY: number}}) => {
31
+ const {translationY} = event.nativeEvent;
32
+ if (translationY > 50) {
33
+ toggleModal();
34
+ }
35
+ };
36
+
28
37
  return (
29
38
  <Modal
30
39
  animationType="slide"
31
40
  transparent={true}
32
41
  visible={isModalVisible}
33
42
  onRequestClose={toggleModal}>
34
- <View style={[styles.mainContainer, style]} testID={testID}>
35
- <BlurView
36
- style={[styles.blurView, blurViewStyle]}
37
- blurType="light"
38
- blurAmount={blurAmount}
39
- />
40
- <View style={[styles.modalContainer, modalContainerStyle]}>
41
- <View style={styles.separator} />
42
- <View style={styles.headerContainer}>
43
- {showLeftIcon &&
44
- React.cloneElement(leftIcon, {
45
- width: moderateScale(24),
46
- height: moderateScale(24),
47
- style: styles.leftIconStyle,
48
- onPress: onLeftIconPress,
49
- })}
50
- <CustomTypography
51
- variant={titleVariant}
52
- text={title}
53
- style={{...styles.title, ...titleStyle}}
43
+ <PanGestureHandler onGestureEvent={onSwipDown}>
44
+ <View style={[styles.mainContainer, style]} testID={testID}>
45
+ {showBlurView ? (
46
+ <BlurView
47
+ style={[styles.blurView, blurViewStyle]}
48
+ blurType="light"
49
+ blurAmount={blurAmount}
54
50
  />
55
- {showRightIcon &&
56
- React.cloneElement(rightIcon, {
57
- width: moderateScale(24),
58
- height: moderateScale(24),
59
- style: styles.rightIconStyle,
60
- onPress: toggleModal,
61
- })}
51
+ ) : null}
52
+ <View style={[styles.modalContainer, modalContainerStyle]}>
53
+ <View style={styles.separator} />
54
+ <View style={styles.headerContainer}>
55
+ {showLeftIcon &&
56
+ React.cloneElement(leftIcon, {
57
+ width: moderateScale(24),
58
+ height: moderateScale(24),
59
+ style: styles.leftIconStyle,
60
+ onPress: onLeftIconPress,
61
+ })}
62
+ <CustomTypography
63
+ variant={titleVariant}
64
+ text={title}
65
+ style={{...styles.title, ...titleStyle}}
66
+ />
67
+ {showRightIcon &&
68
+ React.cloneElement(rightIcon, {
69
+ width: moderateScale(24),
70
+ height: moderateScale(24),
71
+ style: styles.rightIconStyle,
72
+ onPress: toggleModal,
73
+ })}
74
+ </View>
75
+ {children}
62
76
  </View>
63
- {children}
64
77
  </View>
65
- </View>
78
+ </PanGestureHandler>
66
79
  </Modal>
67
80
  );
68
81
  };
@@ -1,18 +1,18 @@
1
1
  import {ReactElement} from 'react';
2
- import {FONT_STYLES} from '../../theme/fonts';
3
- import {ViewStyle} from 'react-native';
2
+ import {StyleProp, TextStyle, ViewStyle} from 'react-native';
4
3
  import {SvgProps} from 'react-native-svg';
5
4
 
6
- export interface ButtonProps {
7
- onPress: () => void;
5
+ export interface CustomButtonProps {
8
6
  title: string;
9
- buttonType: string;
10
- buttonStyle?: ViewStyle;
11
- titleStyle?: ViewStyle;
12
- iconShown?: boolean;
13
- iconStyles?: ViewStyle;
7
+ onPress: () => void;
8
+ containerStyle?: StyleProp<ViewStyle>;
9
+ textStyle?: TextStyle;
10
+ leftIcon?: ReactElement<SvgProps>;
11
+ rightIcon?: ReactElement<SvgProps>;
12
+ iconStyle?: ViewStyle;
13
+ titleColor?: string;
14
+ titleVariant?: string;
15
+ imagePosition?: 'left' | 'right';
14
16
  testID?: string;
15
- titleShown?: boolean;
16
- variant: keyof typeof FONT_STYLES | string;
17
- iconName?: ReactElement<SvgProps>;
17
+ disabled?: boolean;
18
18
  }
@@ -1,28 +1,9 @@
1
- import React, {ReactElement} from 'react';
2
- import {
3
- TouchableOpacity,
4
- StyleSheet,
5
- View,
6
- ViewStyle,
7
- StyleProp,
8
- TextStyle,
9
- } from 'react-native';
10
- import {SvgProps} from 'react-native-svg';
1
+ import React from 'react';
2
+ import {StyleSheet, View, Pressable} from 'react-native';
11
3
  import CustomText from '../customText';
12
-
13
- interface CustomButtonProps {
14
- title: string;
15
- onPress: () => void;
16
- containerStyle?: StyleProp<ViewStyle>;
17
- textStyle?: TextStyle;
18
- leftIcon?: ReactElement<SvgProps>;
19
- rightIcon?: ReactElement<SvgProps>;
20
- iconStyle?: ViewStyle;
21
- titleColor?: string;
22
- titleVariant?: string;
23
- imagePosition?: 'left' | 'right';
24
- testID?: string;
25
- }
4
+ import {useTheme} from '../../theme/ThemeContext';
5
+ import {withThemeProvider} from '../../theme/withThemeProvider';
6
+ import {CustomButtonProps} from './Button.interface';
26
7
 
27
8
  const CustomButton = ({
28
9
  title,
@@ -36,12 +17,19 @@ const CustomButton = ({
36
17
  titleColor,
37
18
  titleVariant = 'L2_REGULAR',
38
19
  imagePosition = 'right',
20
+ disabled = false,
39
21
  }: CustomButtonProps) => {
22
+ const {theme} = useTheme();
40
23
  return (
41
- <TouchableOpacity
24
+ <Pressable
42
25
  testID={testID}
43
- style={[styles.buttonContainer, containerStyle]}
44
- onPress={onPress}>
26
+ style={[
27
+ styles.buttonContainer,
28
+ containerStyle,
29
+ disabled ? {backgroundColor: theme.SURFACE_DISABLE} : {},
30
+ ]}
31
+ onPress={onPress}
32
+ disabled={disabled}>
45
33
  {imagePosition === 'left' && leftIcon && (
46
34
  <View style={iconStyle}>
47
35
  {React.cloneElement(leftIcon, {width: 20, height: 20})}
@@ -50,7 +38,11 @@ const CustomButton = ({
50
38
  <CustomText
51
39
  text={title}
52
40
  variant={titleVariant}
53
- style={[{color: '#A7A7A7'}, textStyle]}
41
+ style={[
42
+ {color: '#A7A7A7'},
43
+ textStyle,
44
+ disabled ? {color: theme.CONTENT_DISABLE} : {},
45
+ ]}
54
46
  textColor={titleColor}
55
47
  />
56
48
 
@@ -59,7 +51,7 @@ const CustomButton = ({
59
51
  {React.cloneElement(rightIcon, {width: 20, height: 20})}
60
52
  </View>
61
53
  )}
62
- </TouchableOpacity>
54
+ </Pressable>
63
55
  );
64
56
  };
65
57
 
@@ -74,4 +66,4 @@ const styles = StyleSheet.create({
74
66
  },
75
67
  });
76
68
 
77
- export default CustomButton;
69
+ export default withThemeProvider(CustomButton);
@@ -29,10 +29,7 @@ const Checkbox: React.FC<CheckBoxProps> = ({
29
29
  testID={'Checkbox-Press'}
30
30
  onPress={handlePress}
31
31
  disabled={disable}
32
- style={({pressed}) => [
33
- styles.directionStyle,
34
- {opacity: pressed ? 0.5 : 1},
35
- ]}>
32
+ style={styles.directionStyle}>
36
33
  <View style={styles.checkboxContainer}>
37
34
  {React.cloneElement(checked ? checkedIcon : uncheckedIcon)}
38
35
  </View>