@aks-dev/easyui 1.0.196 → 1.0.197
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.
- package/dist/components/AnimationModal/AnimationModal.js +41 -23
- package/dist/components/Badge/Badge.js +16 -7
- package/dist/components/DottedLine/DottedLine.js +20 -15
- package/dist/components/Echarts/EchartsView.js +77 -40
- package/dist/components/Echarts/helper.js +16 -1
- package/dist/components/Hud/AlertBottomView/AlertBottomView.js +64 -49
- package/dist/components/Hud/AlertSheetView/AlertSheetView.js +34 -30
- package/dist/components/Hud/AlertView/AlertView.js +66 -52
- package/dist/components/Hud/Hud.js +19 -8
- package/dist/components/Hud/Loading/Loading.js +25 -7
- package/dist/components/Hud/PopoverView/PopoverView.js +20 -5
- package/dist/components/Hud/Scanner/Scanner.js +99 -71
- package/dist/components/Hud/Toast/Toast.js +16 -6
- package/dist/components/MenuView/MenuView.js +73 -32
- package/dist/components/Modal/Modal.js +7 -0
- package/dist/components/MutiPictureView/MutiPictureView.js +88 -78
- package/dist/components/PictureViewer/PictureViewer.js +32 -11
- package/dist/components/RefreshList/RefreshList.js +52 -43
- package/dist/components/RichText/RichText.js +23 -23
- package/dist/components/StickHeaderView/StickHeaderView.js +12 -2
- package/dist/components/TableCell/TableCell.js +53 -37
- package/dist/components/TextInputArea/TextInputArea.js +31 -22
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +31 -14
- package/dist/index.js +11 -0
- package/dist/jsbridge/RNEasyui.js +26 -1
- package/dist/jsbridge/UpgradeModule.js +21 -12
- package/dist/jsbridge/index.js +7 -0
- package/dist/screen/index.js +8 -0
- package/dist/screen/px2dp.js +25 -2
- package/dist/screen/px2sp.js +35 -5
- package/dist/screen/text-fit.js +21 -5
- package/dist/utils/index.js +7 -0
- package/dist/utils/lazy.js +71 -19
- package/dist/utils/mode.js +21 -0
- package/package.json +1 -2
- package/types/components/AnimationModal/AnimationModal.d.ts +8 -0
- package/types/components/AnimationModal/AnimationModal.d.ts.map +1 -1
- package/types/components/Echarts/helper.d.ts +5 -0
- package/types/components/Echarts/helper.d.ts.map +1 -1
- package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts +1 -1
- package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts.map +1 -1
- package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts +1 -1
- package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts.map +1 -1
- package/types/components/Hud/AlertView/AlertView.d.ts +1 -1
- package/types/components/Hud/AlertView/AlertView.d.ts.map +1 -1
- package/types/components/Hud/Loading/Loading.d.ts +3 -3
- package/types/components/Hud/Loading/Loading.d.ts.map +1 -1
- package/types/components/Hud/PopoverView/PopoverView.d.ts +3 -3
- package/types/components/Hud/PopoverView/PopoverView.d.ts.map +1 -1
- package/types/components/Hud/Scanner/Scanner.d.ts +3 -3
- package/types/components/Hud/Scanner/Scanner.d.ts.map +1 -1
- package/types/components/Hud/Toast/Toast.d.ts +2 -2
- package/types/components/Hud/Toast/Toast.d.ts.map +1 -1
- package/types/components/MutiPictureView/MutiPictureView.d.ts +9 -0
- package/types/components/MutiPictureView/MutiPictureView.d.ts.map +1 -1
- package/types/components/StickHeaderView/StickHeaderView.d.ts +6 -0
- package/types/components/StickHeaderView/StickHeaderView.d.ts.map +1 -1
- package/types/components/TextInputArea/TextInputArea.d.ts +1 -0
- package/types/components/TextInputArea/TextInputArea.d.ts.map +1 -1
- package/types/jsbridge/RNEasyui.d.ts +18 -0
- package/types/jsbridge/RNEasyui.d.ts.map +1 -1
- package/types/jsbridge/UpgradeModule.d.ts +15 -0
- package/types/jsbridge/UpgradeModule.d.ts.map +1 -1
- package/types/screen/px2dp.d.ts +11 -0
- package/types/screen/px2dp.d.ts.map +1 -1
- package/types/screen/text-fit.d.ts +3 -0
- package/types/screen/text-fit.d.ts.map +1 -1
- package/types/utils/lazy.d.ts +35 -2
- package/types/utils/lazy.d.ts.map +1 -1
- package/types/utils/mode.d.ts +14 -0
- package/types/utils/mode.d.ts.map +1 -1
- package/dist/components/Echarts/demo.js +0 -201
- package/dist/components/RefreshList/demo.js +0 -9
- package/dist/components/RefreshList/demo1.js +0 -27
- package/dist/components/RefreshList/demo2.js +0 -9
- package/dist/components/StickHeaderView/demo.js +0 -37
- package/types/components/Echarts/demo.d.ts +0 -4
- package/types/components/Echarts/demo.d.ts.map +0 -1
- package/types/components/RefreshList/demo.d.ts +0 -2
- package/types/components/RefreshList/demo.d.ts.map +0 -1
- package/types/components/RefreshList/demo1.d.ts +0 -2
- package/types/components/RefreshList/demo1.d.ts.map +0 -1
- package/types/components/RefreshList/demo2.d.ts +0 -2
- package/types/components/RefreshList/demo2.d.ts.map +0 -1
- package/types/components/StickHeaderView/demo.d.ts +0 -4
- package/types/components/StickHeaderView/demo.d.ts.map +0 -1
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* @Author: shiguo
|
|
3
|
+
* @Date: 2022-04-24 14:27:02
|
|
4
|
+
* @LastEditors: shiguo
|
|
5
|
+
* @LastEditTime: 2023-03-23 15:04:18
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/lib/Hud/Scanner/Scanner.tsx
|
|
7
|
+
*/
|
|
10
8
|
import React, { useImperativeHandle, useState } from "react";
|
|
11
9
|
import { Animated, BackHandler, Easing, Image, StyleSheet, Text, TouchableOpacity, View, } from "react-native";
|
|
12
10
|
import { Camera, useCameraDevice, useCameraPermission, useCodeScanner, } from "react-native-vision-camera";
|
|
@@ -15,6 +13,11 @@ import { navigationBarHeight, px2dp, statusBarHeight, } from "../../../screen/px
|
|
|
15
13
|
import { px2sp } from "../../../screen/px2sp";
|
|
16
14
|
import * as utils from "../../../utils/lazy";
|
|
17
15
|
import { showToast } from "../Toast/Toast";
|
|
16
|
+
// enum SCANNER_TYPE {
|
|
17
|
+
// DENIED = -1,//没有开始权限
|
|
18
|
+
// START = 0,//没有扫描结果,继续扫描
|
|
19
|
+
// SUCCESS = 1,//已有扫描结果,停止扫描
|
|
20
|
+
// }
|
|
18
21
|
export const Scanner = React.forwardRef((_, ref) => {
|
|
19
22
|
const [show, setShow] = useState(false);
|
|
20
23
|
const moveAnim = React.useRef(new Animated.Value(0)).current;
|
|
@@ -32,13 +35,14 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
32
35
|
return true;
|
|
33
36
|
};
|
|
34
37
|
BackHandler.addEventListener("hardwareBackPress", onBackPress);
|
|
38
|
+
// return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
|
|
35
39
|
}, [show]);
|
|
36
40
|
useImperativeHandle(ref, () => ({
|
|
37
41
|
showScanner: _showScanner,
|
|
38
42
|
hideScanner: _hideScanner,
|
|
39
43
|
}), [show]);
|
|
40
|
-
const _showScanner = (cb) =>
|
|
41
|
-
let res =
|
|
44
|
+
const _showScanner = async (cb) => {
|
|
45
|
+
let res = await requestMultiple([
|
|
42
46
|
PERMISSIONS.IOS.CAMERA,
|
|
43
47
|
PERMISSIONS.ANDROID.CAMERA,
|
|
44
48
|
]);
|
|
@@ -47,7 +51,7 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
47
51
|
_scanerResultRef.current = null;
|
|
48
52
|
setShow(true);
|
|
49
53
|
setPointStyle({});
|
|
50
|
-
|
|
54
|
+
await utils.sleep();
|
|
51
55
|
animationStart();
|
|
52
56
|
_cbRef.current = cb;
|
|
53
57
|
}
|
|
@@ -55,12 +59,12 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
55
59
|
_hideScanner();
|
|
56
60
|
showToast("您未开启相机权限,暂不能使用此功能");
|
|
57
61
|
}
|
|
58
|
-
}
|
|
59
|
-
const _hideScanner = () =>
|
|
62
|
+
};
|
|
63
|
+
const _hideScanner = async () => {
|
|
60
64
|
animationStop();
|
|
61
|
-
|
|
65
|
+
await utils.sleep();
|
|
62
66
|
setShow(false);
|
|
63
|
-
}
|
|
67
|
+
};
|
|
64
68
|
const animation = Animated.loop(Animated.sequence([
|
|
65
69
|
Animated.timing(moveAnim, {
|
|
66
70
|
toValue: px2dp(222),
|
|
@@ -75,19 +79,18 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
75
79
|
useNativeDriver: true,
|
|
76
80
|
}),
|
|
77
81
|
]));
|
|
78
|
-
const animationStart = () =>
|
|
79
|
-
|
|
80
|
-
(_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.resumePreview();
|
|
82
|
+
const animationStart = async () => {
|
|
83
|
+
cameraRef.current?.resumePreview();
|
|
81
84
|
animation.start(({ finished }) => {
|
|
85
|
+
// console.log('animationStart finished', finished)
|
|
82
86
|
if (finished) {
|
|
83
87
|
animation.reset();
|
|
84
88
|
animation.start();
|
|
85
89
|
}
|
|
86
90
|
});
|
|
87
|
-
}
|
|
91
|
+
};
|
|
88
92
|
const animationStop = (result) => {
|
|
89
|
-
|
|
90
|
-
(_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.pausePreview();
|
|
93
|
+
cameraRef.current?.pausePreview();
|
|
91
94
|
animation.stop();
|
|
92
95
|
};
|
|
93
96
|
const codeScanner = useCodeScanner({
|
|
@@ -95,7 +98,7 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
95
98
|
onCodeScanned: (codes) => {
|
|
96
99
|
console.log(`Scanned ${codes.length} codes!`);
|
|
97
100
|
let code = codes.find((i) => i.value);
|
|
98
|
-
if (
|
|
101
|
+
if (code?.value && _scanerResultRef.current == undefined) {
|
|
99
102
|
_scanerResultRef.current = code.value;
|
|
100
103
|
_cbRef.current(code.value);
|
|
101
104
|
_hideScanner();
|
|
@@ -105,53 +108,78 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
105
108
|
if (!show)
|
|
106
109
|
return null;
|
|
107
110
|
if (!hasPermission)
|
|
108
|
-
return
|
|
111
|
+
return <Text>PermissionsPage</Text>;
|
|
109
112
|
if (device == null)
|
|
110
|
-
return
|
|
111
|
-
return (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
113
|
+
return <Text>NoCameraDeviceError</Text>;
|
|
114
|
+
return (<TouchableOpacity disabled style={StyleSheet.absoluteFillObject}>
|
|
115
|
+
<Camera ref={cameraRef} style={styles.camera} device={device} codeScanner={codeScanner} isActive={true}>
|
|
116
|
+
{/* 导航栏 */}
|
|
117
|
+
<View style={{
|
|
118
|
+
display: "flex",
|
|
119
|
+
justifyContent: "center",
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
height: navigationBarHeight,
|
|
122
|
+
marginTop: statusBarHeight,
|
|
123
|
+
position: "relative",
|
|
124
|
+
}}>
|
|
125
|
+
<TouchableOpacity onPress={() => _hideScanner()} style={{
|
|
126
|
+
height: navigationBarHeight,
|
|
127
|
+
width: px2dp(50),
|
|
128
|
+
paddingLeft: px2dp(15),
|
|
129
|
+
position: "absolute",
|
|
130
|
+
left: 0,
|
|
131
|
+
display: "flex",
|
|
132
|
+
justifyContent: "center",
|
|
133
|
+
}}>
|
|
134
|
+
<Image source={require("./assets/icon_back_white.png")} style={{ width: px2dp(20), height: px2dp(20) }} resizeMode="contain"/>
|
|
135
|
+
</TouchableOpacity>
|
|
136
|
+
<Text style={{
|
|
137
|
+
fontSize: px2sp(16),
|
|
138
|
+
color: "white",
|
|
139
|
+
fontWeight: "bold",
|
|
140
|
+
}}>
|
|
141
|
+
扫一扫
|
|
142
|
+
</Text>
|
|
143
|
+
</View>
|
|
144
|
+
|
|
145
|
+
{/* 动画框 */}
|
|
146
|
+
<View style={styles.scanContainer}>
|
|
147
|
+
<View style={styles.rectangle}>
|
|
148
|
+
<View style={styles.rectangleLeft}/>
|
|
149
|
+
<View style={styles.cameraBackground}>
|
|
150
|
+
<Animated.View style={[
|
|
151
|
+
styles.scanLine,
|
|
152
|
+
{ transform: [{ translateY: moveAnim }] },
|
|
153
|
+
]}/>
|
|
154
|
+
<View style={styles.reactLineTopLeftX}/>
|
|
155
|
+
<View style={styles.reactLineTopLeftY}/>
|
|
156
|
+
<View style={styles.reactLineTopRightX}/>
|
|
157
|
+
<View style={styles.reactLineTopRightY}/>
|
|
158
|
+
<View style={styles.reactLineBottomLeftX}/>
|
|
159
|
+
<View style={styles.reactLineBottomLeftY}/>
|
|
160
|
+
<View style={styles.reactLineBottomRightX}/>
|
|
161
|
+
<View style={styles.reactLineBottomRightY}/>
|
|
162
|
+
</View>
|
|
163
|
+
<View style={styles.rectangleRight}/>
|
|
164
|
+
</View>
|
|
165
|
+
|
|
166
|
+
{/* <TouchableOpacity onPress={() => setTorchOn(!torchOn)}>
|
|
167
|
+
<Image
|
|
168
|
+
source={
|
|
169
|
+
torchOn
|
|
170
|
+
? require("./assets/flashlight-blue.png")
|
|
171
|
+
: require("./assets/flashlight-white.png")
|
|
172
|
+
}
|
|
173
|
+
style={styles.flashlight}
|
|
174
|
+
/>
|
|
175
|
+
</TouchableOpacity> */}
|
|
176
|
+
<Text style={styles.rectangleText}>
|
|
177
|
+
将二维码/条码放入框内,即可自动扫描
|
|
178
|
+
</Text>
|
|
179
|
+
</View>
|
|
180
|
+
<View style={pointStyle}/>
|
|
181
|
+
</Camera>
|
|
182
|
+
</TouchableOpacity>);
|
|
155
183
|
});
|
|
156
184
|
const transparent = "#00000000";
|
|
157
185
|
const lineColor = "#6ab3ff";
|
|
@@ -269,5 +297,5 @@ const styles = StyleSheet.create({
|
|
|
269
297
|
grantedText: { lineHeight: px2dp(30), color: lineColor, fontWeight: "bold" },
|
|
270
298
|
});
|
|
271
299
|
export const scannerRef = React.createRef();
|
|
272
|
-
export const showScanner = (cb) =>
|
|
273
|
-
export const hideScanner = () =>
|
|
300
|
+
export const showScanner = (cb) => scannerRef.current?.showScanner(cb);
|
|
301
|
+
export const hideScanner = () => scannerRef.current?.hideScanner();
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: shiguo
|
|
3
|
+
* @Date: 2021-04-27 10:38:04
|
|
4
|
+
* @LastEditors: shiguo
|
|
5
|
+
* @LastEditTime: 2022-09-09 10:58:34
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/lib/Hud/Toast/Toast.tsx
|
|
7
|
+
*/
|
|
1
8
|
import React, { useImperativeHandle, useState, useRef } from "react";
|
|
2
9
|
import { View, StyleSheet, Text, Dimensions, Animated, Easing, } from "react-native";
|
|
3
10
|
const errorMsg = "(^_^)∠※ 送你一束小花";
|
|
@@ -26,14 +33,16 @@ export const Toast = React.forwardRef((_, ref) => {
|
|
|
26
33
|
fadeAnimation.start();
|
|
27
34
|
},
|
|
28
35
|
}));
|
|
29
|
-
return (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
return (<Animated.View style={{ ...styles.toastContainer, opacity: fade }}>
|
|
37
|
+
<View style={styles.toastTipsContainer}>
|
|
38
|
+
<Text numberOfLines={5} style={{ ...styles.toastTitle }}>
|
|
39
|
+
{tipText}{" "}
|
|
40
|
+
</Text>
|
|
41
|
+
</View>
|
|
42
|
+
</Animated.View>);
|
|
34
43
|
});
|
|
35
44
|
export const toastRef = React.createRef();
|
|
36
|
-
export const showToast = (content) =>
|
|
45
|
+
export const showToast = (content) => toastRef.current?.showToast(content);
|
|
37
46
|
const SCREEN_WIDTH = Dimensions.get("window").width;
|
|
38
47
|
const styles = StyleSheet.create({
|
|
39
48
|
toastContainer: {
|
|
@@ -47,6 +56,7 @@ const styles = StyleSheet.create({
|
|
|
47
56
|
position: "absolute",
|
|
48
57
|
backgroundColor: "#00000088",
|
|
49
58
|
padding: 10,
|
|
59
|
+
// paddingVertical: 4,
|
|
50
60
|
borderRadius: 2,
|
|
51
61
|
justifyContent: "center",
|
|
52
62
|
alignItems: "center",
|
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import React from "react";
|
|
11
2
|
import { Image, ScrollView, Text, TouchableOpacity, View, } from "react-native";
|
|
12
3
|
import { deviceHeight, deviceWidth } from "../../screen/px2dp";
|
|
4
|
+
// import * as utils from '../../utils/lazy';
|
|
13
5
|
import { hidePopoverView, showPopoverView } from "../Hud/Hud";
|
|
6
|
+
// type Reducer = (prevState: State, action: Partial<State>) => State
|
|
14
7
|
export default (props) => {
|
|
15
8
|
const { defaultAlignHorizontal = "left", defaultAlignVertical = "bottom" } = props;
|
|
16
9
|
const [state, dispatch] = React.useReducer((prevState, action) => Object.assign({}, prevState, action), {});
|
|
10
|
+
// const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
|
|
17
11
|
const containerRef = React.useRef(null);
|
|
18
12
|
const rootView = React.useRef({ pageX: 0, pageY: 0, width: 0, height: 0 });
|
|
19
13
|
const sc = React.useRef({ x: 0, y: 0, width: 0, height: 0 });
|
|
14
|
+
// React.useEffect(() => {
|
|
15
|
+
// ; (async () => {
|
|
16
|
+
// await utils.sleep()
|
|
17
|
+
// containerRef.current?.measure((...args) => {
|
|
18
|
+
// console.log('containerRef', args)
|
|
19
|
+
// if (args.length == 6) {
|
|
20
|
+
// _container.current = {
|
|
21
|
+
// x: args[4],
|
|
22
|
+
// y: args[5],
|
|
23
|
+
// width: args[2],
|
|
24
|
+
// height: args[3],
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
// })
|
|
28
|
+
// })()
|
|
29
|
+
// })
|
|
20
30
|
const getRootViewlayoutPromise = () => {
|
|
21
31
|
return new Promise((resovle, reject) => {
|
|
22
|
-
|
|
23
|
-
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.measure((...args) => {
|
|
32
|
+
containerRef.current?.measure((...args) => {
|
|
24
33
|
if (args.length == 6) {
|
|
25
34
|
rootView.current = {
|
|
26
35
|
width: args[2],
|
|
@@ -29,17 +38,18 @@ export default (props) => {
|
|
|
29
38
|
pageY: args[5],
|
|
30
39
|
};
|
|
31
40
|
}
|
|
41
|
+
// console.log('RootView', rootView.current)
|
|
32
42
|
resovle(args);
|
|
33
43
|
});
|
|
34
44
|
});
|
|
35
45
|
};
|
|
36
46
|
const getLayoutInfos = () => {
|
|
37
|
-
var _a;
|
|
38
47
|
let alignVertical = defaultAlignVertical;
|
|
39
48
|
let alignHorizontal = defaultAlignHorizontal;
|
|
40
49
|
let width = rootView.current.width;
|
|
41
50
|
let height = rootView.current.height;
|
|
42
51
|
let x = rootView.current.pageX;
|
|
52
|
+
// let y = (StatusBar.currentHeight || 0) + _container.current.y + height
|
|
43
53
|
let y = rootView.current.pageY + height;
|
|
44
54
|
if (x > Math.abs(deviceWidth - width - x)) {
|
|
45
55
|
alignHorizontal = "right";
|
|
@@ -47,8 +57,9 @@ export default (props) => {
|
|
|
47
57
|
if (y > deviceHeight * 0.5) {
|
|
48
58
|
alignVertical = "top";
|
|
49
59
|
}
|
|
60
|
+
/**todo: target_width的获取是延迟的,所以这里又问题 */
|
|
50
61
|
const target_width = sc.current.width;
|
|
51
|
-
const target_height = CELL_HEIGHT * (Math.min(
|
|
62
|
+
const target_height = CELL_HEIGHT * (Math.min(props.data?.length || 0, 5) || 0);
|
|
52
63
|
return {
|
|
53
64
|
alignVertical,
|
|
54
65
|
alignHorizontal,
|
|
@@ -62,6 +73,7 @@ export default (props) => {
|
|
|
62
73
|
};
|
|
63
74
|
const reLayout = () => {
|
|
64
75
|
let { alignVertical, alignHorizontal, width, height, x, y, target_width, target_height, } = getLayoutInfos();
|
|
76
|
+
// console.log({ getLayoutInfos: getLayoutInfos() })
|
|
65
77
|
const layout = () => {
|
|
66
78
|
if (alignHorizontal == "left") {
|
|
67
79
|
if (target_width + x > deviceWidth) {
|
|
@@ -101,15 +113,34 @@ export default (props) => {
|
|
|
101
113
|
const PADDING = 10;
|
|
102
114
|
const ARROW_HEIGHT = 12;
|
|
103
115
|
const CELL_HEIGHT = 36;
|
|
104
|
-
const show = () =>
|
|
105
|
-
var _a, _b;
|
|
116
|
+
const show = async () => {
|
|
106
117
|
props.onContainerClick && props.onContainerClick();
|
|
107
|
-
if (props.data == undefined ||
|
|
118
|
+
if (props.data == undefined || props.data?.length == 0)
|
|
108
119
|
return;
|
|
109
|
-
|
|
120
|
+
/**重新获取rootview的定位 */
|
|
121
|
+
await getRootViewlayoutPromise();
|
|
122
|
+
/**重新获取rootview的定位 */
|
|
110
123
|
showPopoverView({
|
|
111
|
-
content: (
|
|
112
|
-
|
|
124
|
+
content: (<TouchableOpacity activeOpacity={1} style={{
|
|
125
|
+
position: "absolute",
|
|
126
|
+
minWidth: deviceWidth * 0.36,
|
|
127
|
+
maxWidth: deviceWidth * 0.8,
|
|
128
|
+
minHeight: CELL_HEIGHT + PADDING * 2,
|
|
129
|
+
maxHeight: CELL_HEIGHT * 5 + PADDING * 2,
|
|
130
|
+
borderRadius: 6,
|
|
131
|
+
backgroundColor: "#000000ee",
|
|
132
|
+
// overflow: 'hidden' ,
|
|
133
|
+
padding: PADDING,
|
|
134
|
+
...reLayout(),
|
|
135
|
+
}}>
|
|
136
|
+
<View style={{
|
|
137
|
+
width: ARROW_HEIGHT,
|
|
138
|
+
height: ARROW_HEIGHT,
|
|
139
|
+
backgroundColor: "#000000ee",
|
|
140
|
+
position: "absolute",
|
|
141
|
+
zIndex: 1,
|
|
142
|
+
transform: [{ rotateZ: "45deg" }],
|
|
143
|
+
...(() => {
|
|
113
144
|
const { alignVertical, alignHorizontal } = getLayoutInfos();
|
|
114
145
|
if (alignVertical == "bottom" && alignHorizontal == "left")
|
|
115
146
|
return { left: "20%", top: -5 };
|
|
@@ -120,24 +151,34 @@ export default (props) => {
|
|
|
120
151
|
if (alignVertical == "top" && alignHorizontal == "right")
|
|
121
152
|
return { right: "20%", bottom: -5 };
|
|
122
153
|
return {};
|
|
123
|
-
})()
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
154
|
+
})(),
|
|
155
|
+
}}/>
|
|
156
|
+
|
|
157
|
+
<ScrollView onLayout={(e) => {
|
|
158
|
+
// console.log('target onLayout', e.nativeEvent.layout)
|
|
159
|
+
let _sc = e.nativeEvent.layout;
|
|
160
|
+
sc.current = _sc;
|
|
161
|
+
}}>
|
|
162
|
+
{props.data?.map((i, idx) => {
|
|
163
|
+
return (<TouchableOpacity activeOpacity={0.7} key={`sg-memnu-${idx}`} style={{
|
|
129
164
|
height: CELL_HEIGHT,
|
|
130
165
|
display: "flex",
|
|
131
166
|
flexDirection: "row",
|
|
132
167
|
alignItems: "center",
|
|
133
|
-
|
|
168
|
+
// ,backgroundColor:utils.randomcolor()
|
|
169
|
+
}} onPress={(e) => {
|
|
134
170
|
props.onItemClick && props.onItemClick(idx, i.extra);
|
|
135
171
|
hidePopoverView();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
}}>
|
|
173
|
+
{i.icon && (<Image style={{ width: 18, height: 18, marginRight: 4 }} source={i.icon}/>)}
|
|
174
|
+
<Text style={{ flexShrink: 1, fontSize: 14, color: "white" }}>
|
|
175
|
+
{i.text}
|
|
176
|
+
</Text>
|
|
177
|
+
</TouchableOpacity>);
|
|
178
|
+
})}
|
|
179
|
+
</ScrollView>
|
|
180
|
+
</TouchableOpacity>),
|
|
140
181
|
});
|
|
141
|
-
}
|
|
142
|
-
return (
|
|
182
|
+
};
|
|
183
|
+
return (<TouchableOpacity ref={containerRef} onPress={(e) => show()} {...props}/>);
|
|
143
184
|
};
|