@hoddy-ui/core 2.5.8 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/next",
3
- "version": "2.0.49",
3
+ "version": "2.0.52",
4
4
  "description": "Core rich react native components written in typescript, with support for expo-router",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "2.5.8",
3
+ "version": "2.5.10",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -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 = -10,
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,
@@ -143,8 +169,10 @@ export const Popup: React.FC<PopupProps> = ({
143
169
  <UIThemeProvider>
144
170
  <KeyboardAvoidingView
145
171
  style={styles.keyboardView}
146
- behavior={Platform.OS === "ios" ? "padding" : undefined}
147
- keyboardVerticalOffset={keyboardVerticalOffset}
172
+ behavior={Platform.OS === "ios" ? "padding" : "height"}
173
+ keyboardVerticalOffset={
174
+ keyboardVerticalOffset || keyboardVerticalOffsetValue
175
+ }
148
176
  >
149
177
  <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
150
178
  <View style={styles.root}>
@@ -158,10 +186,10 @@ 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
- <Animated.View
164
- layout={LinearTransition}
191
+ <View
192
+ // layout={LinearTransition}
165
193
  style={styles.container}
166
194
  >
167
195
  {!bare && (
@@ -180,7 +208,7 @@ export const Popup: React.FC<PopupProps> = ({
180
208
  )}
181
209
 
182
210
  <View style={styles.content}>{children}</View>
183
- </Animated.View>
211
+ </View>
184
212
  </Animated.View>
185
213
  </View>
186
214
  </TouchableWithoutFeedback>