react-native-auto-positioned-popup 1.0.5 → 1.0.7

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.
@@ -0,0 +1,82 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { Keyboard, EmitterSubscription, Platform } from 'react-native';
3
+
4
+ const debounce = (func: Function, delay: number) => {
5
+ let timer: NodeJS.Timeout;
6
+ return (...args: any[]) => {
7
+ clearTimeout(timer);
8
+ timer = setTimeout(() => func(...args), delay);
9
+ };
10
+ };
11
+
12
+ export const useKeyboardStatus = () => {
13
+ const [isKeyboardFullyShown, setIsKeyboardFullyShown] = useState(false);
14
+
15
+ // 使用防抖包裝狀態更新函數
16
+ const debouncedSetKeyboardShown = useRef(
17
+ debounce((value: boolean) => {
18
+ console.log('KeyboardManager: Setting keyboard status to', value);
19
+ setIsKeyboardFullyShown(value);
20
+ }, 300)
21
+ ).current;
22
+
23
+ useEffect(() => {
24
+ let keyboardWillShowListener: EmitterSubscription;
25
+ let keyboardDidShowListener: EmitterSubscription;
26
+ let keyboardWillHideListener: EmitterSubscription;
27
+ let keyboardDidHideListener: EmitterSubscription;
28
+
29
+ if (Platform.OS === 'ios') {
30
+ keyboardWillShowListener = Keyboard.addListener(
31
+ 'keyboardWillShow',
32
+ () => {
33
+ debouncedSetKeyboardShown(false);
34
+ }
35
+ );
36
+ keyboardDidShowListener = Keyboard.addListener(
37
+ 'keyboardDidShow',
38
+ () => {
39
+ debouncedSetKeyboardShown(true);
40
+ }
41
+ );
42
+ keyboardWillHideListener = Keyboard.addListener(
43
+ 'keyboardWillHide',
44
+ () => {
45
+ debouncedSetKeyboardShown(false);
46
+ }
47
+ );
48
+ keyboardDidHideListener = Keyboard.addListener(
49
+ 'keyboardDidHide',
50
+ () => {
51
+ debouncedSetKeyboardShown(false);
52
+ }
53
+ );
54
+ } else {
55
+ keyboardDidShowListener = Keyboard.addListener(
56
+ 'keyboardDidShow',
57
+ () => {
58
+ debouncedSetKeyboardShown(true);
59
+ }
60
+ );
61
+ keyboardDidHideListener = Keyboard.addListener(
62
+ 'keyboardDidHide',
63
+ () => {
64
+ debouncedSetKeyboardShown(false);
65
+ }
66
+ );
67
+ }
68
+
69
+ return () => {
70
+ if (Platform.OS === 'ios') {
71
+ keyboardWillShowListener?.remove();
72
+ }
73
+ keyboardDidShowListener?.remove();
74
+ if (Platform.OS === 'ios') {
75
+ keyboardWillHideListener?.remove();
76
+ }
77
+ keyboardDidHideListener?.remove();
78
+ };
79
+ }, []);
80
+
81
+ return isKeyboardFullyShown;
82
+ };
@@ -34,7 +34,6 @@ export const RootViewProvider: React.FC<RootViewProviderProps> = ({ children })
34
34
  const [rootViews, setRootViews] = useState<DynamicViewBase[]>([]);
35
35
  const [searchQuery, setSearchQuery] = useState<string>('');
36
36
  const viewRefs = useRef<Record<string, View>>({});
37
- //監聽 rootViews
38
37
  useEffect(() => {
39
38
  console.log('RootViewProvider rootViews changed:', rootViews);
40
39
  }, [rootViews]);
@@ -0,0 +1,19 @@
1
+ declare module 'react-native-advanced-flatlist' {
2
+ import { ComponentType } from 'react';
3
+ import { FlatListProps, ListRenderItem } from 'react-native';
4
+
5
+ export interface AdvancedFlatListProps<ItemT = any> extends FlatListProps<ItemT> {
6
+ renderItem?: ListRenderItem<ItemT>;
7
+ }
8
+
9
+ export const AdvancedFlatList: ComponentType<AdvancedFlatListProps>;
10
+ export default AdvancedFlatList;
11
+ }
12
+
13
+ declare module 'react-native-advanced-flatlist/src/AdvancedFlatList.tsx' {
14
+ import { ComponentType } from 'react';
15
+ import { FlatListProps } from 'react-native';
16
+
17
+ const AdvancedFlatListSource: ComponentType<FlatListProps<any>>;
18
+ export default AdvancedFlatListSource;
19
+ }