@aks-dev/easyui 1.0.139 → 1.0.142

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-26 17:26:14
5
+ * @LastEditTime: 2022-12-27 09:12:36
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, BackHandler } from 'react-native';
10
+ import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions, BackHandler, MeasureOnSuccessCallback } from 'react-native';
11
11
  import type { AnimationModalProps } from '.';
12
12
  import * as utils from '../../utils/lazy';
13
13
  // type State = {
@@ -17,6 +17,7 @@ import * as utils from '../../utils/lazy';
17
17
 
18
18
 
19
19
 
20
+
20
21
  export const AnimationModal: React.ForwardRefExoticComponent<
21
22
  React.PropsWithoutRef<AnimationModalProps>
22
23
  & React.RefAttributes<AnimationModalProps.RefAttributes>
@@ -49,24 +50,40 @@ export const AnimationModal: React.ForwardRefExoticComponent<
49
50
  });
50
51
  };
51
52
 
53
+
54
+ const viewRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>() as any
52
55
  const layoutRef = React.useRef<{
53
56
  /**:父容器的高度 */
54
57
  h0: number;
55
58
  /**:子容器的高度 */
56
59
  h1: number;
57
60
  }>({ h0: 0, h1: 0 })
61
+ const getLayoutPromise = () => {
62
+ return new Promise((resovle, reject) => {
63
+ viewRef.current?.measure((...args: any[]) => {
64
+ if (args.length == 6) {
65
+ layoutRef.current.h1 = args[3]
66
+ }
67
+ resovle(args)
68
+ })
69
+ })
70
+ }
58
71
 
59
72
  React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
60
73
  show,
61
74
  hide,
62
75
  target: targetRef.current
63
76
  }), [])
77
+
64
78
  const targetRef = React.useRef<any>()
65
79
 
66
80
 
81
+
82
+
67
83
  const show = async () => {
68
84
  setDisplay('flex', async () => {
69
85
  await utils.sleep(50)
86
+ await getLayoutPromise()
70
87
  timing(-layoutRef.current?.h1)
71
88
  })
72
89
  }
@@ -115,10 +132,12 @@ export const AnimationModal: React.ForwardRefExoticComponent<
115
132
  >
116
133
  <Animated.View
117
134
  style={Object.assign({}, styles.wrapper, { transform: [{ translateY: animatedValue }] })}
118
- onLayout={e => {
119
- let target: LayoutRectangle = e.nativeEvent.layout
120
- layoutRef.current.h1 = target.height
121
- }}
135
+ // onLayout={e => {
136
+ // let target: LayoutRectangle = e.nativeEvent.layout
137
+ // layoutRef.current.h1 = target.height
138
+ // }}
139
+
140
+ ref={viewRef}
122
141
  >
123
142
  {props.children}
124
143
  </Animated.View>
@@ -172,4 +191,4 @@ const useCallbackState = <T,>(od: T): [T, (d: T, callback?: Function) => void] =
172
191
  setData(d)
173
192
  }
174
193
  ]
175
- }
194
+ }
@@ -168,7 +168,7 @@ export default (props: MenuProps) => {
168
168
 
169
169
 
170
170
  const show = async () => {
171
- props.onContainerPress && props.onContainerPress()
171
+ props.onContainerClick && props.onContainerClick()
172
172
  if (props.data == undefined || props.data?.length == 0) return
173
173
  /**重新获取rootview的定位 */
174
174
  await getRootViewlayoutPromise()
@@ -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-26 18:00:33
5
+ * @LastEditTime: 2022-12-26 18:01:52
6
6
  * @FilePath: /@aks-dev/easyui/lib/MenuView/index.ts
7
7
  */
8
8
 
@@ -23,7 +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
+ onContainerClick?:Function;
27
27
  } & Readonly<{ children?: React.ReactNode | undefined }> & TouchableOpacityProps
28
28
 
29
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.139",
3
+ "version": "1.0.142",
4
4
  "description": "工具箱",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",