dhre-ui-kit 0.0.247 → 0.0.248

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/lib/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import React, { createContext, useContext, useRef, useEffect, useState, memo, useCallback } from 'react';
1
+ import React, { createContext, useContext, useState, useEffect, useRef, memo, useCallback } from 'react';
2
2
  import { useSelector } from 'react-redux';
3
- import { Dimensions, StyleSheet, Text, Pressable, View, Modal, KeyboardAvoidingView, Platform, Animated, Easing, TextInput, ScrollView, FlatList, TouchableOpacity, Alert, Linking, PanResponder } from 'react-native';
3
+ import { Dimensions, StyleSheet, Text, Pressable, View, Modal, KeyboardAvoidingView, Platform, TextInput, ScrollView, Animated, FlatList, TouchableOpacity, Alert, Linking, PanResponder } from 'react-native';
4
4
  import { PanGestureHandler, GestureHandlerRootView, Swipeable } from 'react-native-gesture-handler';
5
5
  import { BlurView } from '@react-native-community/blur';
6
- import Svg, { Defs, LinearGradient, Stop, Circle } from 'react-native-svg';
6
+ import LottieView from 'lottie-react-native';
7
7
  import Tooltip from 'react-native-walkthrough-tooltip';
8
8
  import Pdf from 'react-native-pdf';
9
9
  import * as Progress from 'react-native-progress';
@@ -15,6 +15,7 @@ import { Dropdown } from 'react-native-element-dropdown';
15
15
  import DocumentPicker from 'react-native-document-picker';
16
16
  import RNFS from 'react-native-fs';
17
17
  import OTPVerify, { removeListener, startOtpListener } from 'react-native-otp-verify';
18
+ import { verticalScale as verticalScale$1, moderateScale as moderateScale$1 } from 'src/utils/stylehelper';
18
19
  import Clipboard from '@react-native-clipboard/clipboard';
19
20
 
20
21
  var ShapeType = /* @__PURE__ */ ((ShapeType2) => {
@@ -710,6 +711,13 @@ const BottomDrawer = ({
710
711
 
711
712
  const createStyles$3 = (theme) => {
712
713
  return StyleSheet.create({
714
+ container: {
715
+ position: "absolute",
716
+ left: 0,
717
+ right: 0,
718
+ bottom: 0,
719
+ top: 0
720
+ },
713
721
  backdrop: {
714
722
  flex: 1,
715
723
  justifyContent: "center",
@@ -746,67 +754,20 @@ const createStyles$3 = (theme) => {
746
754
  };
747
755
 
748
756
  const CustomLoader = ({ loading, loadingText = "Loading..." }) => {
749
- const rotateAnim = useRef(new Animated.Value(0)).current;
750
757
  const { theme, mode } = useTheme();
751
758
  const styles = createStyles$3(theme);
752
- useEffect(() => {
753
- if (loading) {
754
- Animated.loop(
755
- Animated.timing(rotateAnim, {
756
- toValue: 1,
757
- duration: 1500,
758
- easing: Easing.linear,
759
- useNativeDriver: true
760
- })
761
- ).start();
762
- } else {
763
- rotateAnim.stopAnimation();
764
- rotateAnim.setValue(0);
765
- }
766
- return () => {
767
- rotateAnim.stopAnimation();
768
- };
769
- }, [loading, rotateAnim]);
770
759
  if (!loading) return null;
771
- const spin = rotateAnim.interpolate({
772
- inputRange: [0, 1],
773
- outputRange: ["0deg", "360deg"]
774
- });
775
- return /* @__PURE__ */ React.createElement(Modal, { transparent: true, visible: loading, animationType: "fade" }, /* @__PURE__ */ React.createElement(View, { style: styles.backdrop }, /* @__PURE__ */ React.createElement(View, { style: styles.box }, /* @__PURE__ */ React.createElement(Animated.View, { style: [styles.loader, { transform: [{ rotate: spin }] }] }, /* @__PURE__ */ React.createElement(Svg, { width: "100", height: "100", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement(Defs, null, /* @__PURE__ */ React.createElement(LinearGradient, { id: "grad", x1: "0%", y1: "0%", x2: "100%", y2: "100%" }, /* @__PURE__ */ React.createElement(Stop, { offset: "0%", stopColor: "#000000", stopOpacity: "2" }), /* @__PURE__ */ React.createElement(
776
- Stop,
777
- {
778
- offset: "40%",
779
- stopColor: mode === "dark" ? "#5A5A5A00" : "#686868",
780
- stopOpacity: "5"
781
- }
782
- ), /* @__PURE__ */ React.createElement(
783
- Stop,
784
- {
785
- offset: "100%",
786
- stopColor: mode === "dark" ? "#FFFFFF" : "#AAAAAA",
787
- stopOpacity: ".9"
788
- }
789
- ))), /* @__PURE__ */ React.createElement(
790
- Circle,
791
- {
792
- cx: "50",
793
- cy: "50",
794
- r: "40",
795
- stroke: "url(#grad)",
796
- strokeWidth: "8",
797
- fill: "none",
798
- strokeDasharray: "250",
799
- strokeLinecap: "round"
800
- }
801
- ))), /* @__PURE__ */ React.createElement(
802
- CustomText$1,
803
- {
804
- text: loadingText,
805
- style: styles.text,
806
- variant: FontStyle.B4_REGULAR,
807
- textColor: "#000000"
808
- }
809
- ))));
760
+ else {
761
+ return /* @__PURE__ */ React.createElement(View, { style: styles.container }, /* @__PURE__ */ React.createElement(View, { style: styles.backdrop }, /* @__PURE__ */ React.createElement(View, { style: styles.box }, /* @__PURE__ */ React.createElement(View, { style: styles.loader }, /* @__PURE__ */ React.createElement(LottieView, { style: styles.loader, source: require("../../assets/json/Loading.json"), autoPlay: true, loop: true })), /* @__PURE__ */ React.createElement(
762
+ CustomText$1,
763
+ {
764
+ text: loadingText,
765
+ style: styles.text,
766
+ variant: FontStyle.B4_REGULAR,
767
+ textColor: "#000000"
768
+ }
769
+ ))));
770
+ }
810
771
  };
811
772
  var CustomLoader$1 = withThemeProvider(CustomLoader);
812
773
 
@@ -4381,8 +4342,8 @@ const styles$3 = StyleSheet.create({
4381
4342
  alignItems: "center"
4382
4343
  },
4383
4344
  sliderContainer: {
4384
- height: verticalScale(48),
4385
- borderRadius: moderateScale(25),
4345
+ height: verticalScale$1(48),
4346
+ borderRadius: moderateScale$1(25),
4386
4347
  overflow: "hidden",
4387
4348
  justifyContent: "center"
4388
4349
  },
@@ -4393,11 +4354,11 @@ const styles$3 = StyleSheet.create({
4393
4354
  justifyContent: "center"
4394
4355
  },
4395
4356
  button: {
4396
- height: verticalScale(40),
4357
+ height: verticalScale$1(40),
4397
4358
  justifyContent: "center",
4398
4359
  alignItems: "center",
4399
- borderRadius: moderateScale(20),
4400
- margin: moderateScale(4)
4360
+ borderRadius: moderateScale$1(20),
4361
+ margin: 4
4401
4362
  },
4402
4363
  buttonTextContainer: {
4403
4364
  position: "absolute",
@@ -4406,7 +4367,8 @@ const styles$3 = StyleSheet.create({
4406
4367
  bottom: 0,
4407
4368
  top: 0,
4408
4369
  alignItems: "center",
4409
- justifyContent: "center"
4370
+ justifyContent: "center",
4371
+ borderRadius: 25
4410
4372
  }
4411
4373
  });
4412
4374
 
@@ -4415,30 +4377,25 @@ const CustomSlideButton = React.forwardRef(
4415
4377
  ({
4416
4378
  label,
4417
4379
  onComplete,
4380
+ onReset,
4418
4381
  icon,
4419
4382
  textStyle,
4420
4383
  containerStyle,
4421
4384
  sliderStyle,
4422
4385
  size = BUTTON_WIDTH,
4423
- slideButtonTail,
4424
- slideButtonTailColor = "#fff"
4386
+ sliderBackgroundColor = "#fff",
4387
+ sliderTextColor = "#000",
4388
+ resetTimer = 2e3
4425
4389
  }, ref) => {
4426
4390
  const value = useRef(0);
4427
4391
  const cardRef = useRef(null);
4428
4392
  const [translateX] = useState(new Animated.Value(0));
4429
- const slideTailCardRef = useRef(null);
4430
- slideTailCardRef?.current?.setNativeProps({
4431
- style: { width: 0 }
4432
- });
4393
+ const sliderConteinerRef = useRef(null);
4394
+ const [color, setColor] = useState(new Animated.Value(0));
4395
+ const [sliderBackgroundColorRef, setSliderBackgroundColorRef] = useState(new Animated.Value(0));
4433
4396
  React.useImperativeHandle(ref, () => ({
4434
4397
  reset() {
4435
- Animated.spring(translateX, {
4436
- toValue: 0,
4437
- useNativeDriver: false
4438
- }).start();
4439
- slideTailCardRef?.current?.setNativeProps({
4440
- style: { width: 0 }
4441
- });
4398
+ resetAll();
4442
4399
  }
4443
4400
  }));
4444
4401
  const handleLayout = (event) => {
@@ -4449,68 +4406,102 @@ const CustomSlideButton = React.forwardRef(
4449
4406
  // Change the width here
4450
4407
  });
4451
4408
  value.current = width;
4409
+ sliderConteinerRef?.current?.setNativeProps({
4410
+ style: { width }
4411
+ });
4452
4412
  }
4453
4413
  };
4414
+ const resetAll = () => {
4415
+ Animated.timing(translateX, {
4416
+ toValue: 0,
4417
+ useNativeDriver: false
4418
+ }).start();
4419
+ Animated.timing(sliderBackgroundColorRef, {
4420
+ toValue: 0,
4421
+ duration: 0,
4422
+ // no transition time, immediate change
4423
+ useNativeDriver: false
4424
+ // because we're animating the color, not layout
4425
+ }).start();
4426
+ Animated.timing(color, {
4427
+ toValue: 0,
4428
+ delay: 300,
4429
+ // no transition time, immediate change
4430
+ useNativeDriver: false
4431
+ // because we're animating the color, not layout
4432
+ }).start();
4433
+ onReset?.();
4434
+ };
4454
4435
  const panResponder = PanResponder.create({
4455
4436
  onMoveShouldSetPanResponder: (e, gestureState) => {
4456
4437
  return gestureState.dx !== 0;
4457
4438
  },
4458
4439
  onPanResponderMove: (evt, gestureState) => {
4459
- if (gestureState.dx > 0) {
4440
+ if (gestureState.dx > 0 && gestureState.dx <= value?.current - BUTTON_WIDTH - 8) {
4460
4441
  translateX.setValue(gestureState.dx);
4461
- slideTailCardRef?.current?.setNativeProps({
4462
- style: { width: gestureState.dx + BUTTON_WIDTH / 2 }
4463
- });
4442
+ let colorValue = gestureState.dx > value.current / 3 ? 1 : 0;
4443
+ Animated.timing(color, {
4444
+ toValue: colorValue,
4445
+ duration: 0,
4446
+ // no transition time, immediate change
4447
+ useNativeDriver: false
4448
+ // because we're animating the color, not layout
4449
+ }).start();
4464
4450
  }
4465
4451
  },
4466
4452
  onPanResponderRelease: (e, gestureState) => {
4467
- if (gestureState.dx >= value.current * 0.7) {
4453
+ if (gestureState.dx >= value.current * 0.8) {
4468
4454
  Animated.timing(translateX, {
4469
- toValue: value.current - BUTTON_WIDTH - 12,
4455
+ toValue: value?.current - (BUTTON_WIDTH + 8),
4470
4456
  // Slide to the end
4471
4457
  duration: 300,
4472
4458
  useNativeDriver: false
4473
- }).start(() => {
4474
- onComplete?.();
4475
- });
4476
- slideTailCardRef?.current?.setNativeProps({
4477
- style: { width: value.current + BUTTON_WIDTH }
4478
- // Change the width here
4479
- });
4480
- } else {
4481
- Animated.spring(translateX, {
4482
- toValue: 0,
4459
+ }).start();
4460
+ Animated.timing(sliderBackgroundColorRef, {
4461
+ toValue: 1,
4462
+ duration: 0,
4463
+ // no transition time, immediate change
4483
4464
  useNativeDriver: false
4465
+ // because we're animating the color, not layout
4484
4466
  }).start();
4485
- slideTailCardRef?.current?.setNativeProps({
4486
- style: { width: 0 }
4487
- });
4467
+ onComplete?.();
4468
+ setTimeout(() => {
4469
+ resetAll();
4470
+ }, resetTimer);
4471
+ } else {
4472
+ resetAll();
4488
4473
  }
4489
4474
  }
4490
4475
  });
4476
+ const textColor = color.interpolate({
4477
+ inputRange: [0, 1],
4478
+ outputRange: [sliderTextColor, "transparent"]
4479
+ });
4480
+ const backgroundColor = sliderBackgroundColorRef.interpolate({
4481
+ inputRange: [0, 1],
4482
+ outputRange: [sliderBackgroundColor, "transparent"]
4483
+ });
4491
4484
  const { theme } = useTheme();
4492
4485
  return /* @__PURE__ */ React.createElement(View, { style: {
4493
4486
  ...styles$3.sliderContainer,
4494
4487
  backgroundColor: theme.SURFACE_INVERTED,
4495
4488
  ...containerStyle
4496
- }, onLayout: handleLayout, ref: cardRef }, slideButtonTail && /* @__PURE__ */ React.createElement(
4489
+ }, onLayout: handleLayout, ref: cardRef }, /* @__PURE__ */ React.createElement(
4497
4490
  Animated.View,
4498
4491
  {
4499
- ref: slideTailCardRef,
4500
- style: [{ height: "100%", width: 0, backgroundColor: slideButtonTailColor }]
4492
+ style: [styles$3.buttonTextContainer, { backgroundColor, transform: [{ translateX }] }],
4493
+ ref: sliderConteinerRef
4501
4494
  }
4502
- ), /* @__PURE__ */ React.createElement(View, { style: styles$3.buttonTextContainer }, /* @__PURE__ */ React.createElement(
4503
- CustomTypography,
4495
+ ), /* @__PURE__ */ React.createElement(
4496
+ View,
4504
4497
  {
4505
- text: label,
4506
- variant: FontStyle.L1_REGULAR,
4507
- style: {
4508
- color: theme.CONTENT_INVERTED,
4509
- alignSelf: "center",
4510
- ...textStyle
4511
- }
4512
- }
4513
- )), /* @__PURE__ */ React.createElement(
4498
+ style: styles$3.buttonTextContainer
4499
+ },
4500
+ /* @__PURE__ */ React.createElement(Animated.Text, { style: [{
4501
+ alignSelf: "center",
4502
+ ...textStyle
4503
+ }, { color: textColor }] }, label)
4504
+ ), /* @__PURE__ */ React.createElement(
4514
4505
  Animated.View,
4515
4506
  {
4516
4507
  style: [styles$3.slider, { transform: [{ translateX }] }],