dhre-ui-kit 0.0.45 → 0.0.46

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