vpt-sebraeds 0.0.55 → 0.0.56

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.
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useRef, useEffect } from 'react';
2
- import { View, TouchableOpacity, StyleSheet, Dimensions } from 'react-native';
2
+ import { View, TouchableOpacity, StyleSheet, Dimensions, PanResponder } from 'react-native';
3
3
  import { SwipeRow } from 'react-native-swipe-list-view';
4
4
  import Icon from '../Icon';
5
5
  import SEText from '../SEText';
@@ -39,6 +39,26 @@ const ShuffleItem = ({
39
39
  const [isDragging, setIsDragging] = useState(false);
40
40
  const [isExpanded, setIsExpanded] = useState(variant === 'expanded');
41
41
  const rowRef = useRef(null);
42
+ const isSwipedLeftRef = useRef(false);
43
+
44
+ // Mantém ref sincronizado com state para o PanResponder
45
+ useEffect(() => {
46
+ isSwipedLeftRef.current = isSwipedLeft;
47
+ }, [isSwipedLeft]);
48
+
49
+ // PanResponder que intercepta gestos para a direita quando o row está fechado
50
+ const rightSwipeBlocker = useRef(
51
+ PanResponder.create({
52
+ onMoveShouldSetPanResponderCapture: (_evt, gestureState) => {
53
+ // Se o row está fechado e o gesto vai para a direita, captura o gesto
54
+ // para impedir que o SwipeRow receba
55
+ if (!isSwipedLeftRef.current && gestureState.dx > 2) {
56
+ return true;
57
+ }
58
+ return false;
59
+ },
60
+ })
61
+ ).current;
42
62
 
43
63
  // Efeito para fechar outros swipes
44
64
  useEffect(() => {
@@ -89,7 +109,7 @@ const ShuffleItem = ({
89
109
  const disableRowSwipe = !!showAddButton || !!disableSwipe;
90
110
  console.log("disableRowSwipe:", disableRowSwipe);
91
111
  return (
92
- <View style={styles.containerWrapper}>
112
+ <View style={styles.containerWrapper} {...(!disableRowSwipe ? rightSwipeBlocker.panHandlers : {})}>
93
113
  <SwipeRow
94
114
  ref={rowRef}
95
115
  rightOpenValue={disableRowSwipe ? 0 : -80}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/ShuffleItem/index.jsx"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA6ZC;kBArakD,OAAO"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/ShuffleItem/index.jsx"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAibC;kBAzbkD,OAAO"}
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useRef, useEffect } from 'react';
2
- import { View, TouchableOpacity, StyleSheet, Dimensions } from 'react-native';
2
+ import { View, TouchableOpacity, StyleSheet, Dimensions, PanResponder } from 'react-native';
3
3
  import { SwipeRow } from 'react-native-swipe-list-view';
4
4
  import Icon from '../Icon';
5
5
  import SEText from '../SEText';
@@ -9,6 +9,22 @@ const ShuffleItem = ({ title = 'Nome da Ferramenta', subtitle = 'Lorem Máxima L
9
9
  const [isDragging, setIsDragging] = useState(false);
10
10
  const [isExpanded, setIsExpanded] = useState(variant === 'expanded');
11
11
  const rowRef = useRef(null);
12
+ const isSwipedLeftRef = useRef(false);
13
+ // Mantém ref sincronizado com state para o PanResponder
14
+ useEffect(() => {
15
+ isSwipedLeftRef.current = isSwipedLeft;
16
+ }, [isSwipedLeft]);
17
+ // PanResponder que intercepta gestos para a direita quando o row está fechado
18
+ const rightSwipeBlocker = useRef(PanResponder.create({
19
+ onMoveShouldSetPanResponderCapture: (_evt, gestureState) => {
20
+ // Se o row está fechado e o gesto vai para a direita, captura o gesto
21
+ // para impedir que o SwipeRow receba
22
+ if (!isSwipedLeftRef.current && gestureState.dx > 2) {
23
+ return true;
24
+ }
25
+ return false;
26
+ },
27
+ })).current;
12
28
  // Efeito para fechar outros swipes
13
29
  useEffect(() => {
14
30
  // Fecha este item quando outro item é aberto
@@ -55,7 +71,7 @@ const ShuffleItem = ({ title = 'Nome da Ferramenta', subtitle = 'Lorem Máxima L
55
71
  };
56
72
  const disableRowSwipe = !!showAddButton || !!disableSwipe;
57
73
  console.log("disableRowSwipe:", disableRowSwipe);
58
- return (<View style={styles.containerWrapper}>
74
+ return (<View style={styles.containerWrapper} {...(!disableRowSwipe ? rightSwipeBlocker.panHandlers : {})}>
59
75
  <SwipeRow ref={rowRef} rightOpenValue={disableRowSwipe ? 0 : -80} leftOpenValue={0} stopLeftSwipe={disableRowSwipe ? 0 : -80} stopRightSwipe={0} disableRightSwipe={true} disableLeftSwipe={disableRowSwipe} swipeToOpenPercent={disableRowSwipe ? 100 : 50} swipeToClosePercent={disableRowSwipe ? 100 : 30} useNativeDriver={true} friction={disableRowSwipe ? 0 : 8} tension={disableRowSwipe ? 0 : 40} directionalDistanceChangeThreshold={3} swipeGestureBegan={() => {
60
76
  if (!disableRowSwipe) {
61
77
  setIsDragging(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpt-sebraeds",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "description": "Biblioteca de componentes React Native do Sebrae",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",