@aks-dev/easyui 1.0.132 → 1.0.134
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,12 +2,12 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-05-17 15:22:06
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-12-22 11:
|
|
5
|
+
* @LastEditTime: 2022-12-22 11:57:30
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions } from 'react-native';
|
|
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
13
|
type State = {
|
|
@@ -46,8 +46,6 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
49
|
const layoutRef = React.useRef<{
|
|
52
50
|
/**:父容器的高度 */
|
|
53
51
|
h0: number;
|
|
@@ -55,7 +53,6 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
55
53
|
h1: number;
|
|
56
54
|
}>({ h0: 0, h1: 0 })
|
|
57
55
|
|
|
58
|
-
|
|
59
56
|
React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
|
|
60
57
|
show,
|
|
61
58
|
hide,
|
|
@@ -63,8 +60,7 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
63
60
|
}), [])
|
|
64
61
|
const targetRef = React.useRef<any>()
|
|
65
62
|
|
|
66
|
-
const show = async (
|
|
67
|
-
targetRef.current = target
|
|
63
|
+
const show = async () => {
|
|
68
64
|
dispatch({ display: 'flex' })
|
|
69
65
|
await utils.sleep(50)
|
|
70
66
|
timing(-layoutRef.current?.h1)
|
|
@@ -75,6 +71,17 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
75
71
|
dispatch({ display: 'none' })
|
|
76
72
|
}
|
|
77
73
|
|
|
74
|
+
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
let addEventListener = BackHandler.addEventListener("hardwareBackPress", ()=>{
|
|
77
|
+
return state.display == 'flex'
|
|
78
|
+
})
|
|
79
|
+
return () => {
|
|
80
|
+
addEventListener.remove()
|
|
81
|
+
}
|
|
82
|
+
}, [state.display])
|
|
83
|
+
|
|
84
|
+
|
|
78
85
|
return (
|
|
79
86
|
<View
|
|
80
87
|
style={Object.assign({ display: state.display }, styles.container, props.style)}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Image, LayoutRectangle,
|
|
2
|
+
import { Image, LayoutRectangle, MeasureOnSuccessCallback, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import type { MenuProps } from '.';
|
|
4
4
|
import { deviceHeight, deviceWidth } from '../../screen/px2dp';
|
|
5
|
+
import * as utils from '../../utils/lazy';
|
|
5
6
|
import { hidePopoverView, showPopoverView } from '../Hud/Hud';
|
|
6
7
|
|
|
7
|
-
|
|
8
8
|
type State = {
|
|
9
9
|
target?: LayoutRectangle;
|
|
10
10
|
arrow?: Partial<{
|
|
@@ -24,7 +24,8 @@ export default (props: MenuProps) => {
|
|
|
24
24
|
|
|
25
25
|
const [state, dispatch] = React.useReducer<Reducer>((prevState, action) => Object.assign({}, prevState, action), {})
|
|
26
26
|
|
|
27
|
-
const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
|
|
27
|
+
// const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
|
|
28
|
+
const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
|
|
28
29
|
const _container = React.useRef<{
|
|
29
30
|
x: number;
|
|
30
31
|
y: number;
|
|
@@ -34,19 +35,21 @@ export default (props: MenuProps) => {
|
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
React.useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
;(async ()=>{
|
|
39
|
+
await utils.sleep()
|
|
40
|
+
containerRef.current?.measure((...args) => {
|
|
41
|
+
// console.log('containerRef', args)
|
|
42
|
+
if (args.length == 6) {
|
|
43
|
+
_container.current = {
|
|
44
|
+
x: args[4],
|
|
45
|
+
y: args[5],
|
|
46
|
+
width: args[2],
|
|
47
|
+
height: args[3],
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
+
})
|
|
51
|
+
})()
|
|
52
|
+
},[])
|
|
50
53
|
|
|
51
54
|
|
|
52
55
|
const getLayoutInfos: () => {
|
|
@@ -65,7 +68,8 @@ export default (props: MenuProps) => {
|
|
|
65
68
|
let width = _container.current.width
|
|
66
69
|
let height = _container.current.height
|
|
67
70
|
let x = _container.current.x
|
|
68
|
-
let y = (StatusBar.currentHeight || 0) + _container.current.y + height
|
|
71
|
+
// let y = (StatusBar.currentHeight || 0) + _container.current.y + height
|
|
72
|
+
let y = _container.current.y + height
|
|
69
73
|
if (x > Math.abs(deviceWidth - width - x)) {
|
|
70
74
|
alignHorizontal = 'right'
|
|
71
75
|
}
|
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-
|
|
5
|
+
* @LastEditTime: 2022-12-22 22:38:52
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/lib/MenuView/index.ts
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -18,6 +18,7 @@ export type MenuItem = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type MenuProps = {
|
|
21
|
+
activeOpacity?: number | undefined;
|
|
21
22
|
style?: StyleProp<ViewStyle> | undefined;
|
|
22
23
|
data?: MenuItem[];
|
|
23
24
|
onItemClick?: (index: number, extra?: any) => void;
|