react-native-in-app-debugger 1.0.58 → 1.0.60

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/Api/index.jsx CHANGED
@@ -229,8 +229,9 @@ export default (props) => {
229
229
  const content = { ...item };
230
230
  delete content.id;
231
231
  Clipboard.setString(
232
- JSON.stringify(content, undefined, 4)
232
+ JSON.stringify(content, undefined, 3)
233
233
  );
234
+ Alert.alert('Copied');
234
235
  }}
235
236
  style={styles.actionButton}
236
237
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "This library's main usage is to be used by Non-Technical testers during UAT, SIT or any testing phase.",
5
5
  "main": "index.jsx",
6
6
  "scripts": {
package/useAnimation.ts CHANGED
@@ -1,5 +1,18 @@
1
- import { useEffect, useRef, useState } from 'react';
2
- import { Animated, Keyboard, PanResponder, useWindowDimensions } from 'react-native';
1
+ import { useEffect, useRef, useState } from "react";
2
+ import {
3
+ Animated,
4
+ Keyboard,
5
+ PanResponder,
6
+ useWindowDimensions,
7
+ } from "react-native";
8
+
9
+ let LocalStorage;
10
+ try {
11
+ LocalStorage =
12
+ require("@react-native-async-storage/async-storage/src").default;
13
+ } catch (error) {
14
+ // console.error("Error importing LocalStorage:", error);
15
+ }
3
16
 
4
17
  const defaultBadgeWidth = 110;
5
18
  const defaultBorderRadius = 10;
@@ -8,7 +21,10 @@ const touchThreshold = 10;
8
21
 
9
22
  export default (defaultBadgeHeight) => {
10
23
  const cachePosition = useRef({ x: 0, y: 50 });
11
- const position = useRef<any>(new Animated.ValueXY(cachePosition.current)).current;
24
+ const position = useRef<any>(
25
+ new Animated.ValueXY(cachePosition.current)
26
+ ).current;
27
+ // initially I want to animate border radius, but user dont really notice, therefore I removed unnecessary animation
12
28
  // const borderRadius = useRef(new Animated.Value(defaultBorderRadius)).current;
13
29
  const badgeHeight = useRef(new Animated.Value(defaultBadgeHeight)).current;
14
30
  const badgeWidth = useRef(new Animated.Value(defaultBadgeWidth)).current;
@@ -16,12 +32,34 @@ export default (defaultBadgeHeight) => {
16
32
  const [isOpen, setIsOpen] = useState(false);
17
33
  const [shouldShowDetails, setShouldShowDetails] = useState(false);
18
34
 
35
+ const move = (toValue) => {
36
+ cachePosition.current = toValue;
37
+ Animated.spring(position, { ...und, toValue }).start();
38
+ LocalStorage?.setItem("in-app-debugger-position", JSON.stringify(toValue));
39
+ };
40
+
41
+ if (LocalStorage) {
42
+ useEffect(() => {
43
+ LocalStorage.getItem("in-app-debugger-position").then((d) => {
44
+ if (d) move(JSON.parse(d));
45
+ });
46
+ }, []);
47
+ }
48
+
19
49
  useEffect(() => {
20
- const showSubscription = Keyboard.addListener('keyboardDidShow', () => {
21
- !isOpen && Animated.spring(position, { ...und, toValue: { x: cachePosition.current.x, y: 0 } }).start();
50
+ const showSubscription = Keyboard.addListener("keyboardDidShow", () => {
51
+ !isOpen &&
52
+ Animated.spring(position, {
53
+ ...und,
54
+ toValue: { x: cachePosition.current.x, y: 0 },
55
+ }).start();
22
56
  });
23
- const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {
24
- !isOpen && Animated.spring(position, { ...und, toValue: cachePosition.current }).start();
57
+ const hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
58
+ !isOpen &&
59
+ Animated.spring(position, {
60
+ ...und,
61
+ toValue: cachePosition.current,
62
+ }).start();
25
63
  });
26
64
 
27
65
  return () => {
@@ -40,28 +78,42 @@ export default (defaultBadgeHeight) => {
40
78
  onPanResponderGrant: () => {
41
79
  position.setOffset({ x: position.x._value, y: position.y._value });
42
80
  },
43
- onPanResponderMove: Animated.event([null, { dx: position.x, dy: position.y }], und),
81
+ onPanResponderMove: Animated.event(
82
+ [null, { dx: position.x, dy: position.y }],
83
+ und
84
+ ),
44
85
  onPanResponderRelease: (_, g) => {
45
86
  position.flattenOffset();
46
- cachePosition.current = {
87
+ move({
47
88
  x: g.moveX > width / 2 ? width - defaultBadgeWidth : 0,
48
89
  y: Math.min(g.moveY, height - defaultBadgeHeight),
49
- };
50
- Animated.spring(position, { ...und, toValue: cachePosition.current }).start();
90
+ });
51
91
  },
52
- }),
92
+ })
53
93
  ).current;
54
94
 
55
95
  useEffect(() => {
56
- Animated.spring(badgeHeight, { toValue: isOpen ? height : defaultBadgeHeight, ...und }).start();
96
+ Animated.spring(badgeHeight, {
97
+ toValue: isOpen ? height : defaultBadgeHeight,
98
+ ...und,
99
+ }).start();
57
100
  }, [defaultBadgeHeight]);
58
101
 
59
102
  useEffect(() => {
60
103
  setTimeout(() => setShouldShowDetails(isOpen), isOpen ? 200 : 0);
61
- Animated.spring(position, { toValue: isOpen ? { x: 0, y: 0 } : cachePosition.current, ...und }).start();
104
+ Animated.spring(position, {
105
+ toValue: isOpen ? { x: 0, y: 0 } : cachePosition.current,
106
+ ...und,
107
+ }).start();
62
108
  // Animated.spring(borderRadius, { toValue: isOpen ? 0 : defaultBorderRadius, ...und }).start();
63
- Animated.spring(badgeHeight, { toValue: isOpen ? height : defaultBadgeHeight, ...und }).start();
64
- Animated.spring(badgeWidth, { toValue: isOpen ? width : defaultBadgeWidth, ...und }).start();
109
+ Animated.spring(badgeHeight, {
110
+ toValue: isOpen ? height : defaultBadgeHeight,
111
+ ...und,
112
+ }).start();
113
+ Animated.spring(badgeWidth, {
114
+ toValue: isOpen ? width : defaultBadgeWidth,
115
+ ...und,
116
+ }).start();
65
117
  }, [isOpen]);
66
118
 
67
119
  return {