@aks-dev/easyui 1.0.137 → 1.0.139
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-05-17 15:22:06
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-12-
|
|
5
|
+
* @LastEditTime: 2022-12-26 17:26:14
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -10,10 +10,11 @@ import * as React from "react";
|
|
|
10
10
|
import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions, BackHandler } from 'react-native';
|
|
11
11
|
import type { AnimationModalProps } from '.';
|
|
12
12
|
import * as utils from '../../utils/lazy';
|
|
13
|
-
type State = {
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
type StateReducerProps = (state: State, action: Partial<State>) => State
|
|
13
|
+
// type State = {
|
|
14
|
+
// display: 'flex' | 'none';
|
|
15
|
+
// }
|
|
16
|
+
// type StateReducerProps = (state: State, action: Partial<State>) => State
|
|
17
|
+
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
export const AnimationModal: React.ForwardRefExoticComponent<
|
|
@@ -28,11 +29,13 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
28
29
|
|
|
29
30
|
const { height } = useWindowDimensions()
|
|
30
31
|
|
|
31
|
-
const [state, dispatch] = React.useReducer<StateReducerProps>(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// const [state, dispatch] = React.useReducer<StateReducerProps>(
|
|
33
|
+
// (state, action) => ({ ...state, ...action }),
|
|
34
|
+
// {
|
|
35
|
+
// display: 'none'
|
|
36
|
+
// })
|
|
37
|
+
|
|
38
|
+
const [display, setDisplay] = useCallbackState<'flex' | 'none'>('none')
|
|
36
39
|
|
|
37
40
|
const animatedValue = React.useRef(new Animated.Value(0)).current;
|
|
38
41
|
const timing = (value: number) => {
|
|
@@ -60,31 +63,36 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
60
63
|
}), [])
|
|
61
64
|
const targetRef = React.useRef<any>()
|
|
62
65
|
|
|
66
|
+
|
|
63
67
|
const show = async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
setDisplay('flex', async () => {
|
|
69
|
+
await utils.sleep(50)
|
|
70
|
+
timing(-layoutRef.current?.h1)
|
|
71
|
+
})
|
|
67
72
|
}
|
|
68
73
|
const hide = async () => {
|
|
69
74
|
timing(0)
|
|
70
75
|
await utils.sleep(300)
|
|
71
|
-
|
|
76
|
+
setDisplay('none')
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
|
|
75
80
|
React.useEffect(() => {
|
|
76
|
-
let addEventListener = BackHandler.addEventListener("hardwareBackPress", ()=>{
|
|
77
|
-
return
|
|
81
|
+
let addEventListener = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
82
|
+
return display == 'flex'
|
|
78
83
|
})
|
|
79
84
|
return () => {
|
|
80
85
|
addEventListener.remove()
|
|
81
86
|
}
|
|
82
|
-
}, [
|
|
87
|
+
}, [display])
|
|
88
|
+
|
|
83
89
|
|
|
84
90
|
|
|
85
91
|
return (
|
|
86
92
|
<View
|
|
87
|
-
style={Object.assign({
|
|
93
|
+
style={Object.assign({
|
|
94
|
+
display: display
|
|
95
|
+
}, styles.container, props.style)}
|
|
88
96
|
{...PanResponder.create({
|
|
89
97
|
onStartShouldSetPanResponder: (e, gestureState) => {
|
|
90
98
|
let pageY = e.nativeEvent.pageY
|
|
@@ -146,3 +154,22 @@ const styles = StyleSheet.create({
|
|
|
146
154
|
// backgroundColor: 'cyan'
|
|
147
155
|
}
|
|
148
156
|
})
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
const useCallbackState = <T,>(od: T): [T, (d: T, callback?: Function) => void] => {
|
|
162
|
+
const cbRef = React.useRef<Function>()
|
|
163
|
+
const [data, setData] = React.useState<T>(od)
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
cbRef.current && cbRef.current(data)
|
|
166
|
+
}, [data])
|
|
167
|
+
|
|
168
|
+
return [
|
|
169
|
+
data,
|
|
170
|
+
(d: T, callback?: Function) => {
|
|
171
|
+
cbRef.current = callback;
|
|
172
|
+
setData(d)
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
@@ -168,6 +168,7 @@ export default (props: MenuProps) => {
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
const show = async () => {
|
|
171
|
+
props.onContainerPress && props.onContainerPress()
|
|
171
172
|
if (props.data == undefined || props.data?.length == 0) return
|
|
172
173
|
/**重新获取rootview的定位 */
|
|
173
174
|
await getRootViewlayoutPromise()
|
package/lib/MenuView/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-07-14 18:09:02
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-12-
|
|
5
|
+
* @LastEditTime: 2022-12-26 18:00:33
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/lib/MenuView/index.ts
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -23,6 +23,7 @@ export type MenuProps = {
|
|
|
23
23
|
style?: StyleProp<ViewStyle> | undefined;
|
|
24
24
|
data?: MenuItem[];
|
|
25
25
|
onItemClick?: (index: number, extra?: any) => void;
|
|
26
|
+
onContainerPress?:Function;
|
|
26
27
|
} & Readonly<{ children?: React.ReactNode | undefined }> & TouchableOpacityProps
|
|
27
28
|
|
|
28
29
|
|