@hoddy-ui/core 2.5.9 → 2.5.10
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/next/dist/index.js +27 -6
- package/next/dist/index.js.map +1 -1
- package/next/dist/index.mjs +27 -6
- package/next/dist/index.mjs.map +1 -1
- package/next/package.json +1 -1
- package/package.json +1 -1
- package/src/Components/Popup.tsx +34 -6
package/next/package.json
CHANGED
package/package.json
CHANGED
package/src/Components/Popup.tsx
CHANGED
|
@@ -17,19 +17,19 @@ import Animated, {
|
|
|
17
17
|
useSharedValue,
|
|
18
18
|
withTiming,
|
|
19
19
|
} from "react-native-reanimated";
|
|
20
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
20
21
|
import { ms, ScaledSheet } from "react-native-size-matters";
|
|
21
22
|
import { useColors, useTheme } from "../hooks";
|
|
22
23
|
import { UIThemeProvider } from "../theme";
|
|
23
24
|
import { PopupProps } from "../types";
|
|
24
25
|
import { IconButton } from "./Button";
|
|
25
26
|
import Typography from "./Typography";
|
|
26
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
27
27
|
|
|
28
28
|
export const Popup: React.FC<PopupProps> = ({
|
|
29
29
|
title,
|
|
30
30
|
sheet,
|
|
31
31
|
bare = false,
|
|
32
|
-
keyboardVerticalOffset
|
|
32
|
+
keyboardVerticalOffset,
|
|
33
33
|
children,
|
|
34
34
|
open,
|
|
35
35
|
onClose = () => {},
|
|
@@ -40,12 +40,37 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
40
40
|
const theme = useTheme();
|
|
41
41
|
const colors = useColors();
|
|
42
42
|
const [modalVisible, setModalVisible] = useState(false);
|
|
43
|
+
const [keyboardVisible, setKeyboardVisible] = useState(false);
|
|
43
44
|
const { bottom } = useSafeAreaInsets();
|
|
44
45
|
|
|
45
46
|
// Animation values
|
|
46
47
|
const backdropOpacity = useSharedValue(0);
|
|
47
48
|
const contentTranslateY = useSharedValue(1000);
|
|
48
49
|
|
|
50
|
+
// Memoized keyboard vertical offset based on platform and keyboard state
|
|
51
|
+
const keyboardVerticalOffsetValue = Platform.OS === "ios" ? -10 : -bottom * 2;
|
|
52
|
+
|
|
53
|
+
// Keyboard event listeners
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const keyboardDidShowListener = Keyboard.addListener(
|
|
56
|
+
"keyboardDidShow",
|
|
57
|
+
() => {
|
|
58
|
+
setKeyboardVisible(true);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const keyboardDidHideListener = Keyboard.addListener(
|
|
62
|
+
"keyboardDidHide",
|
|
63
|
+
() => {
|
|
64
|
+
setKeyboardVisible(false);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
keyboardDidHideListener?.remove();
|
|
70
|
+
keyboardDidShowListener?.remove();
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
49
74
|
// Trigger animations when open prop changes
|
|
50
75
|
useEffect(() => {
|
|
51
76
|
if (open) {
|
|
@@ -94,6 +119,7 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
94
119
|
alignSelf: "center",
|
|
95
120
|
maxWidth: sheet ? undefined : "90%",
|
|
96
121
|
width: sheet ? "100%" : undefined,
|
|
122
|
+
marginBottom: Platform.OS === "android" && keyboardVisible ? bottom : 0,
|
|
97
123
|
},
|
|
98
124
|
container: {
|
|
99
125
|
paddingBottom: sheet && !bare ? bottom + ms(10) : undefined,
|
|
@@ -144,7 +170,9 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
144
170
|
<KeyboardAvoidingView
|
|
145
171
|
style={styles.keyboardView}
|
|
146
172
|
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
147
|
-
keyboardVerticalOffset={
|
|
173
|
+
keyboardVerticalOffset={
|
|
174
|
+
keyboardVerticalOffset || keyboardVerticalOffsetValue
|
|
175
|
+
}
|
|
148
176
|
>
|
|
149
177
|
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
|
150
178
|
<View style={styles.root}>
|
|
@@ -158,9 +186,9 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
158
186
|
|
|
159
187
|
<Animated.View
|
|
160
188
|
style={[styles.avoidingView, contentAnimatedStyle]}
|
|
161
|
-
layout={LinearTransition}
|
|
189
|
+
layout={LinearTransition.springify(1)}
|
|
162
190
|
>
|
|
163
|
-
<
|
|
191
|
+
<View
|
|
164
192
|
// layout={LinearTransition}
|
|
165
193
|
style={styles.container}
|
|
166
194
|
>
|
|
@@ -180,7 +208,7 @@ export const Popup: React.FC<PopupProps> = ({
|
|
|
180
208
|
)}
|
|
181
209
|
|
|
182
210
|
<View style={styles.content}>{children}</View>
|
|
183
|
-
</
|
|
211
|
+
</View>
|
|
184
212
|
</Animated.View>
|
|
185
213
|
</View>
|
|
186
214
|
</TouchableWithoutFeedback>
|