react-native-in-app-debugger 1.0.57 → 1.0.59
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 +2 -2
- package/package.json +1 -1
- package/useAnimation.ts +68 -16
package/Api/index.jsx
CHANGED
|
@@ -15,7 +15,7 @@ import getRandomBrightColor from "../utils/getRandomBrightColor";
|
|
|
15
15
|
import { MAX_URL_LENGTH } from "./Row";
|
|
16
16
|
let Clipboard;
|
|
17
17
|
try {
|
|
18
|
-
Clipboard = require("@react-native-clipboard/clipboard")
|
|
18
|
+
Clipboard = require("@react-native-clipboard/clipboard").default;
|
|
19
19
|
} catch (error) {
|
|
20
20
|
// console.error("Error importing Clipboard:", error);
|
|
21
21
|
}
|
|
@@ -223,7 +223,7 @@ export default (props) => {
|
|
|
223
223
|
{isExpand ? "Hide" : "Show"}
|
|
224
224
|
</Text>
|
|
225
225
|
</TouchableOpacity>
|
|
226
|
-
{!!Clipboard && (
|
|
226
|
+
{!!Clipboard?.setString && (
|
|
227
227
|
<TouchableOpacity
|
|
228
228
|
onPress={() => {
|
|
229
229
|
const content = { ...item };
|
package/package.json
CHANGED
package/useAnimation.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from
|
|
2
|
-
import {
|
|
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>(
|
|
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(
|
|
21
|
-
!isOpen &&
|
|
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(
|
|
24
|
-
!isOpen &&
|
|
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(
|
|
81
|
+
onPanResponderMove: Animated.event(
|
|
82
|
+
[null, { dx: position.x, dy: position.y }],
|
|
83
|
+
und
|
|
84
|
+
),
|
|
44
85
|
onPanResponderRelease: (_, g) => {
|
|
45
86
|
position.flattenOffset();
|
|
46
|
-
|
|
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, {
|
|
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, {
|
|
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, {
|
|
64
|
-
|
|
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 {
|