@aks-dev/easyui 1.0.133 → 1.0.135

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.
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
- import { Image, LayoutRectangle, MeasureInWindowOnSuccessCallback, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native';
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;
@@ -33,20 +34,40 @@ export default (props: MenuProps) => {
33
34
  }>({ x: 0, y: 0, width: 0, height: 0 })
34
35
 
35
36
 
36
- React.useEffect(() => {
37
- containerRef.current?.measureInWindow((...args) => {
38
- // console.log('containerRef', args)
39
- if (args.length == 4) {
40
- _container.current = {
41
- x: args[0],
42
- y: args[1],
43
- width: args[2],
44
- height: args[3],
37
+ // React.useEffect(() => {
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
+ // }
49
+ // }
50
+ // })
51
+ // })()
52
+ // })
53
+
54
+
55
+ const getRootViewlayoutPromise = () => {
56
+ return new Promise((resovle, reject) => {
57
+ containerRef.current?.measure((...args) => {
58
+ // console.log('containerRef', args)
59
+ if (args.length == 6) {
60
+ _container.current = {
61
+ x: args[4],
62
+ y: args[5],
63
+ width: args[2],
64
+ height: args[3],
65
+ }
45
66
  }
46
- }
67
+ resovle(args)
68
+ })
47
69
  })
48
-
49
- })
70
+ }
50
71
 
51
72
 
52
73
  const getLayoutInfos: () => {
@@ -65,7 +86,8 @@ export default (props: MenuProps) => {
65
86
  let width = _container.current.width
66
87
  let height = _container.current.height
67
88
  let x = _container.current.x
68
- let y = (StatusBar.currentHeight || 0) + _container.current.y + height
89
+ // let y = (StatusBar.currentHeight || 0) + _container.current.y + height
90
+ let y = _container.current.y + height
69
91
  if (x > Math.abs(deviceWidth - width - x)) {
70
92
  alignHorizontal = 'right'
71
93
  }
@@ -140,9 +162,10 @@ export default (props: MenuProps) => {
140
162
  }
141
163
 
142
164
 
143
- const show = () => {
144
- // console.log('_container', _container.current, StatusBar.currentHeight)
165
+ const show = async () => {
145
166
  if (props.data == undefined || props.data?.length == 0) return
167
+ /**重新获取rootview的定位 */
168
+ await getRootViewlayoutPromise()
146
169
  showPopoverView({
147
170
  content: (
148
171
  <TouchableOpacity
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-07-14 18:09:02
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-21 16:08:43
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.133",
3
+ "version": "1.0.135",
4
4
  "description": "工具箱",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",