@hoddy-ui/core 2.5.24 → 2.5.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "2.5.24",
3
+ "version": "2.5.26",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -42,6 +42,7 @@ export const Popup: React.FC<PopupProps> = ({
42
42
  const theme = useTheme();
43
43
  const colors = useColors();
44
44
  const [modalVisible, setModalVisible] = useState(false);
45
+ const [modalOpen, setModalOpen] = useState(false);
45
46
  const [keyboardVisible, setKeyboardVisible] = useState(false);
46
47
  const { bottom } = useSafeAreaInsets();
47
48
 
@@ -74,25 +75,31 @@ export const Popup: React.FC<PopupProps> = ({
74
75
  };
75
76
  }, []);
76
77
 
78
+ const _onModalShow = () => {
79
+ setModalVisible(true);
80
+ onModalShow?.();
81
+ };
82
+ const _onModalHide = () => {
83
+ onModalHide?.();
84
+ setModalOpen(false);
85
+ };
86
+
77
87
  // Trigger animations when open prop changes
78
88
  useEffect(() => {
79
89
  if (open) {
80
- setModalVisible(true);
90
+ setModalOpen(true);
81
91
  // Opening animation
82
92
  backdropOpacity.value = withTiming(1, { duration: 300 });
83
93
  contentTranslateY.value = withTiming(0, { duration: 300 }, () => {
84
- if (onModalShow) {
85
- runOnJS(onModalShow)();
86
- }
94
+ runOnJS(_onModalShow)();
87
95
  });
88
96
  } else {
89
97
  // Closing animation
98
+ setModalVisible(false);
99
+
90
100
  backdropOpacity.value = withTiming(0, { duration: 200 });
91
101
  contentTranslateY.value = withTiming(1000, { duration: 200 }, () => {
92
- runOnJS(setModalVisible)(false);
93
- if (onModalHide) {
94
- runOnJS(onModalHide)();
95
- }
102
+ runOnJS(_onModalHide)();
96
103
  });
97
104
  }
98
105
  }, [open]);
@@ -167,7 +174,7 @@ export const Popup: React.FC<PopupProps> = ({
167
174
  transparent
168
175
  animationType="none"
169
176
  statusBarTranslucent
170
- visible={modalVisible}
177
+ visible={modalOpen}
171
178
  onRequestClose={closeAction}
172
179
  >
173
180
  <UIThemeProvider>
@@ -181,7 +188,7 @@ export const Popup: React.FC<PopupProps> = ({
181
188
  >
182
189
  <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
183
190
  <View style={styles.root}>
184
- {open && (
191
+ {modalOpen && (
185
192
  <Pressable
186
193
  style={[StyleSheet.absoluteFill, { zIndex: 1 }]}
187
194
  onPress={closeAction}
@@ -190,10 +197,14 @@ export const Popup: React.FC<PopupProps> = ({
190
197
 
191
198
  <Animated.View
192
199
  style={[styles.avoidingView, contentAnimatedStyle]}
193
- layout={LinearTransition.springify()
194
- .stiffness(200)
195
- .mass(0.5)
196
- .damping(100)}
200
+ layout={
201
+ modalVisible
202
+ ? LinearTransition.springify()
203
+ .stiffness(200)
204
+ .mass(0.5)
205
+ .damping(100)
206
+ : undefined
207
+ }
197
208
  >
198
209
  <View style={styles.container}>
199
210
  {!bare && (
package/src/hooks.ts CHANGED
@@ -3,6 +3,7 @@ import { Platform, useColorScheme } from "react-native";
3
3
  import { UIThemeContext } from "./theme";
4
4
  import colors from "./theme/colors";
5
5
  import { ThemeModes, ThemeTypes } from "./types";
6
+ import AsyncStorage from "@react-native-async-storage/async-storage";
6
7
 
7
8
  export const useColors = () => {
8
9
  const { themeState } = useContext(UIThemeContext);
@@ -21,8 +22,10 @@ export const useThemeContext = () => {
21
22
  const setTheme = (theme: ThemeModes) => {
22
23
  if (theme === "default") {
23
24
  themeDispatch?.({ type: "default", payload: colorScheme });
25
+ AsyncStorage.setItem("theme", "default");
24
26
  } else {
25
27
  themeDispatch?.({ type: theme });
28
+ AsyncStorage.setItem("theme", theme);
26
29
  }
27
30
  };
28
31
  return { theme, setTheme };