dhre-ui-kit 0.0.46 → 0.0.48

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.46",
3
+ "version": "0.0.48",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -1,3 +1,5 @@
1
+ import {TextStyle, ViewStyle} from 'react-native';
2
+
1
3
  export interface CustomSwitchBtnProps {
2
4
  value: boolean;
3
5
  onValueChange: (value: boolean) => void;
@@ -5,4 +7,7 @@ export interface CustomSwitchBtnProps {
5
7
  activeTextVariant?: string;
6
8
  inActiveText: string;
7
9
  inActiveTextVariant?: string;
10
+ containerStyle?: ViewStyle;
11
+ activeTextStyle?: TextStyle;
12
+ inActiveTextStyle?: TextStyle;
8
13
  }
@@ -13,20 +13,18 @@ const styles = StyleSheet.create({
13
13
  width: horizontalScale(75),
14
14
  height: verticalScale(32),
15
15
  borderRadius: moderateScale(25),
16
- backgroundColor: '#FFFFFF33',
17
16
  padding: moderateScale(4),
18
17
  },
19
18
  circle: {
20
19
  width: horizontalScale(38),
21
20
  height: verticalScale(24),
22
- backgroundColor: '#FFF',
23
21
  borderRadius: moderateScale(25),
24
22
  },
25
- textEN: {
23
+ activeText: {
26
24
  position: 'absolute',
27
25
  left: horizontalScale(12),
28
26
  },
29
- textAR: {
27
+ inActiveText: {
30
28
  position: 'absolute',
31
29
  top: verticalScale(2),
32
30
  right: horizontalScale(18),
@@ -1,4 +1,4 @@
1
- import React, {useState} from 'react';
1
+ import React, {useEffect, useState} from 'react';
2
2
  import {Pressable, Animated} from 'react-native';
3
3
  import CustomTypography from '../customTypography';
4
4
  import {FontStyle} from '../../utils/appEnum';
@@ -12,6 +12,9 @@ const CustomSwitchBtn = ({
12
12
  activeTextVariant = FontStyle.L2_BOLD,
13
13
  inActiveText,
14
14
  inActiveTextVariant = FontStyle.B3_REGULAR,
15
+ containerStyle,
16
+ activeTextStyle,
17
+ inActiveTextStyle,
15
18
  }: CustomSwitchBtnProps) => {
16
19
  const [animatedValue] = useState(new Animated.Value(value ? 1 : 0));
17
20
 
@@ -19,27 +22,34 @@ const CustomSwitchBtn = ({
19
22
  inputRange: [0, 1],
20
23
  outputRange: [0, 28],
21
24
  });
22
-
23
- const toggleSwitch = () => {
24
- const newValue = !value;
25
+ useEffect(() => {
25
26
  Animated.timing(animatedValue, {
26
27
  toValue: value ? 1 : 0,
27
28
  duration: 300,
28
29
  useNativeDriver: false,
29
30
  }).start();
31
+ }, [value]);
32
+
33
+ const toggleSwitch = () => {
34
+ const newValue = !value;
35
+
30
36
  onValueChange(newValue);
31
37
  };
32
-
33
38
  return (
34
- <Pressable onPress={toggleSwitch} style={styles.mainContainer}>
39
+ <Pressable
40
+ onPress={toggleSwitch}
41
+ style={{...styles.mainContainer, ...containerStyle}}>
35
42
  <Animated.View style={[styles.circle, {transform: [{translateX}]}]} />
36
43
  <CustomTypography
37
- style={styles.textEN}
44
+ style={[styles.activeText, value ? inActiveTextStyle : activeTextStyle]}
38
45
  text={activeText}
39
46
  variant={activeTextVariant}
40
47
  />
41
48
  <CustomTypography
42
- style={styles.textAR}
49
+ style={[
50
+ styles.inActiveText,
51
+ value ? activeTextStyle : inActiveTextStyle,
52
+ ]}
43
53
  text={inActiveText}
44
54
  variant={inActiveTextVariant}
45
55
  />
@@ -1,3 +1 @@
1
- import CustomSwitchBtn from './customSwitchBtn';
2
-
3
- export default {CustomSwitchBtn};
1
+ export {default} from './customSwitchBtn';