@aks-dev/easyui 1.0.182 → 1.0.184
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.
Potentially problematic release.
This version of @aks-dev/easyui might be problematic. Click here for more details.
- package/dist/components/AnimationModal/AnimationModal.js +15 -19
- package/dist/components/Badge/Badge.js +13 -18
- package/dist/components/DottedLine/DottedLine.js +7 -10
- package/dist/components/Echarts/EchartsView.js +14 -18
- package/dist/components/Echarts/helper.js +2 -7
- package/dist/components/Hud/AlertBottomView/AlertBottomView.js +56 -61
- package/dist/components/Hud/AlertSheetView/AlertSheetView.js +42 -47
- package/dist/components/Hud/AlertView/AlertView.js +55 -60
- package/dist/components/Hud/Hud.js +17 -31
- package/dist/components/Hud/Loading/Loading.js +21 -27
- package/dist/components/Hud/PopoverView/PopoverView.js +16 -22
- package/dist/components/Hud/Scanner/Scanner.js +108 -114
- package/dist/components/Hud/Toast/Toast.js +22 -27
- package/dist/components/MenuView/MenuView.js +31 -34
- package/dist/components/Modal/Modal.js +1 -6
- package/dist/components/MutiPictureView/MutiPictureView.js +35 -38
- package/dist/components/PictureViewer/PictureViewer.js +12 -17
- package/dist/components/RefreshList/RefreshList.js +47 -51
- package/dist/components/RichText/RichText.js +17 -20
- package/dist/components/StickHeaderView/StickHeaderView.js +7 -10
- package/dist/components/TableCell/TableCell.js +29 -32
- package/dist/components/TextInputArea/TextInputArea.js +25 -28
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +20 -24
- package/dist/index.js +19 -51
- package/dist/jsbridge/RNEasyui.js +11 -18
- package/dist/jsbridge/UpgradeModule.js +8 -14
- package/dist/jsbridge/index.js +2 -5
- package/dist/screen/index.js +2 -5
- package/dist/screen/px2dp.js +14 -18
- package/dist/screen/px2sp.js +5 -9
- package/dist/screen/text-fit.js +7 -10
- package/dist/utils/index.js +2 -5
- package/dist/utils/lazy.js +25 -50
- package/dist/utils/mode.js +8 -13
- package/package.json +3 -3
- package/readme.md +1 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hideScanner = exports.showScanner = exports.scannerRef = exports.Scanner = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
1
|
/*
|
|
6
2
|
* @Author: shiguo
|
|
7
3
|
* @Date: 2022-04-24 14:27:02
|
|
@@ -9,49 +5,49 @@ const tslib_1 = require("tslib");
|
|
|
9
5
|
* @LastEditTime: 2023-03-23 15:04:18
|
|
10
6
|
* @FilePath: /@aks-dev/easyui/lib/Hud/Scanner/Scanner.tsx
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
import React, { useImperativeHandle, useState } from "react";
|
|
9
|
+
import { Animated, BackHandler, Easing, Image, StyleSheet, Text, TouchableOpacity, View, } from "react-native";
|
|
10
|
+
import { Camera, useCameraDevice, useCameraPermission, useCodeScanner, } from "react-native-vision-camera";
|
|
11
|
+
import { PERMISSIONS, requestMultiple } from "react-native-permissions";
|
|
12
|
+
import { navigationBarHeight, px2dp, statusBarHeight, } from "../../../screen/px2dp";
|
|
13
|
+
import { px2sp } from "../../../screen/px2sp";
|
|
14
|
+
import * as utils from "../../../utils/lazy";
|
|
15
|
+
import { showToast } from "../Toast/Toast";
|
|
20
16
|
// enum SCANNER_TYPE {
|
|
21
17
|
// DENIED = -1,//没有开始权限
|
|
22
18
|
// START = 0,//没有扫描结果,继续扫描
|
|
23
19
|
// SUCCESS = 1,//已有扫描结果,停止扫描
|
|
24
20
|
// }
|
|
25
|
-
|
|
26
|
-
const [show, setShow] =
|
|
27
|
-
const moveAnim =
|
|
28
|
-
const [pointStyle, setPointStyle] =
|
|
29
|
-
const cameraRef =
|
|
30
|
-
const _cbRef =
|
|
31
|
-
const _scanerResultRef =
|
|
32
|
-
const device =
|
|
33
|
-
const { hasPermission } =
|
|
34
|
-
|
|
21
|
+
export const Scanner = React.forwardRef((_, ref) => {
|
|
22
|
+
const [show, setShow] = useState(false);
|
|
23
|
+
const moveAnim = React.useRef(new Animated.Value(0)).current;
|
|
24
|
+
const [pointStyle, setPointStyle] = React.useState();
|
|
25
|
+
const cameraRef = React.useRef(null);
|
|
26
|
+
const _cbRef = React.useRef(null);
|
|
27
|
+
const _scanerResultRef = React.useRef(null);
|
|
28
|
+
const device = useCameraDevice("back");
|
|
29
|
+
const { hasPermission } = useCameraPermission();
|
|
30
|
+
React.useEffect(() => {
|
|
35
31
|
const onBackPress = () => {
|
|
36
32
|
if (show) {
|
|
37
33
|
_hideScanner();
|
|
38
34
|
}
|
|
39
35
|
return true;
|
|
40
36
|
};
|
|
41
|
-
|
|
37
|
+
BackHandler.addEventListener("hardwareBackPress", onBackPress);
|
|
42
38
|
// return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
|
|
43
39
|
}, [show]);
|
|
44
|
-
|
|
40
|
+
useImperativeHandle(ref, () => ({
|
|
45
41
|
showScanner: _showScanner,
|
|
46
42
|
hideScanner: _hideScanner,
|
|
47
43
|
}), [show]);
|
|
48
44
|
const _showScanner = async (cb) => {
|
|
49
|
-
let res = await
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
let res = await requestMultiple([
|
|
46
|
+
PERMISSIONS.IOS.CAMERA,
|
|
47
|
+
PERMISSIONS.ANDROID.CAMERA,
|
|
52
48
|
]);
|
|
53
|
-
if (res[
|
|
54
|
-
res[
|
|
49
|
+
if (res[PERMISSIONS.ANDROID.CAMERA] == "granted" ||
|
|
50
|
+
res[PERMISSIONS.IOS.CAMERA] == "granted") {
|
|
55
51
|
_scanerResultRef.current = null;
|
|
56
52
|
setShow(true);
|
|
57
53
|
setPointStyle({});
|
|
@@ -61,7 +57,7 @@ exports.Scanner = react_1.default.forwardRef((_, ref) => {
|
|
|
61
57
|
}
|
|
62
58
|
else {
|
|
63
59
|
_hideScanner();
|
|
64
|
-
|
|
60
|
+
showToast("您未开启相机权限,暂不能使用此功能");
|
|
65
61
|
}
|
|
66
62
|
};
|
|
67
63
|
const _hideScanner = async () => {
|
|
@@ -69,17 +65,17 @@ exports.Scanner = react_1.default.forwardRef((_, ref) => {
|
|
|
69
65
|
await utils.sleep();
|
|
70
66
|
setShow(false);
|
|
71
67
|
};
|
|
72
|
-
const animation =
|
|
73
|
-
|
|
74
|
-
toValue:
|
|
68
|
+
const animation = Animated.loop(Animated.sequence([
|
|
69
|
+
Animated.timing(moveAnim, {
|
|
70
|
+
toValue: px2dp(222),
|
|
75
71
|
duration: 3000,
|
|
76
|
-
easing:
|
|
72
|
+
easing: Easing.linear,
|
|
77
73
|
useNativeDriver: true,
|
|
78
74
|
}),
|
|
79
|
-
|
|
75
|
+
Animated.timing(moveAnim, {
|
|
80
76
|
toValue: 0,
|
|
81
77
|
duration: 3000,
|
|
82
|
-
easing:
|
|
78
|
+
easing: Easing.linear,
|
|
83
79
|
useNativeDriver: true,
|
|
84
80
|
}),
|
|
85
81
|
]));
|
|
@@ -97,7 +93,7 @@ exports.Scanner = react_1.default.forwardRef((_, ref) => {
|
|
|
97
93
|
cameraRef.current?.pausePreview();
|
|
98
94
|
animation.stop();
|
|
99
95
|
};
|
|
100
|
-
const codeScanner =
|
|
96
|
+
const codeScanner = useCodeScanner({
|
|
101
97
|
codeTypes: ["qr", "ean-13"],
|
|
102
98
|
onCodeScanned: (codes) => {
|
|
103
99
|
console.log(`Scanned ${codes.length} codes!`);
|
|
@@ -112,60 +108,60 @@ exports.Scanner = react_1.default.forwardRef((_, ref) => {
|
|
|
112
108
|
if (!show)
|
|
113
109
|
return null;
|
|
114
110
|
if (!hasPermission)
|
|
115
|
-
return <
|
|
111
|
+
return <Text>PermissionsPage</Text>;
|
|
116
112
|
if (device == null)
|
|
117
|
-
return <
|
|
118
|
-
return (<
|
|
119
|
-
<
|
|
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}>
|
|
120
116
|
{/* 导航栏 */}
|
|
121
|
-
<
|
|
117
|
+
<View style={{
|
|
122
118
|
display: "flex",
|
|
123
119
|
justifyContent: "center",
|
|
124
120
|
alignItems: "center",
|
|
125
|
-
height:
|
|
126
|
-
marginTop:
|
|
121
|
+
height: navigationBarHeight,
|
|
122
|
+
marginTop: statusBarHeight,
|
|
127
123
|
position: "relative",
|
|
128
124
|
}}>
|
|
129
|
-
<
|
|
130
|
-
height:
|
|
131
|
-
width:
|
|
132
|
-
paddingLeft:
|
|
125
|
+
<TouchableOpacity onPress={() => _hideScanner()} style={{
|
|
126
|
+
height: navigationBarHeight,
|
|
127
|
+
width: px2dp(50),
|
|
128
|
+
paddingLeft: px2dp(15),
|
|
133
129
|
position: "absolute",
|
|
134
130
|
left: 0,
|
|
135
131
|
display: "flex",
|
|
136
132
|
justifyContent: "center",
|
|
137
133
|
}}>
|
|
138
|
-
<
|
|
139
|
-
</
|
|
140
|
-
<
|
|
141
|
-
fontSize:
|
|
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),
|
|
142
138
|
color: "white",
|
|
143
139
|
fontWeight: "bold",
|
|
144
140
|
}}>
|
|
145
141
|
扫一扫
|
|
146
|
-
</
|
|
147
|
-
</
|
|
142
|
+
</Text>
|
|
143
|
+
</View>
|
|
148
144
|
|
|
149
145
|
{/* 动画框 */}
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
<
|
|
153
|
-
<
|
|
154
|
-
<
|
|
146
|
+
<View style={styles.scanContainer}>
|
|
147
|
+
<View style={styles.rectangle}>
|
|
148
|
+
<View style={styles.rectangleLeft}/>
|
|
149
|
+
<View style={styles.cameraBackground}>
|
|
150
|
+
<Animated.View style={[
|
|
155
151
|
styles.scanLine,
|
|
156
152
|
{ transform: [{ translateY: moveAnim }] },
|
|
157
153
|
]}/>
|
|
158
|
-
<
|
|
159
|
-
<
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
<
|
|
164
|
-
<
|
|
165
|
-
<
|
|
166
|
-
</
|
|
167
|
-
<
|
|
168
|
-
</
|
|
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>
|
|
169
165
|
|
|
170
166
|
{/* <TouchableOpacity onPress={() => setTorchOn(!torchOn)}>
|
|
171
167
|
<Image
|
|
@@ -177,20 +173,20 @@ exports.Scanner = react_1.default.forwardRef((_, ref) => {
|
|
|
177
173
|
style={styles.flashlight}
|
|
178
174
|
/>
|
|
179
175
|
</TouchableOpacity> */}
|
|
180
|
-
<
|
|
176
|
+
<Text style={styles.rectangleText}>
|
|
181
177
|
将二维码/条码放入框内,即可自动扫描
|
|
182
|
-
</
|
|
183
|
-
</
|
|
184
|
-
<
|
|
185
|
-
</
|
|
186
|
-
</
|
|
178
|
+
</Text>
|
|
179
|
+
</View>
|
|
180
|
+
<View style={pointStyle}/>
|
|
181
|
+
</Camera>
|
|
182
|
+
</TouchableOpacity>);
|
|
187
183
|
});
|
|
188
184
|
const transparent = "#00000000";
|
|
189
185
|
const lineColor = "#6ab3ff";
|
|
190
186
|
const scanW = 225;
|
|
191
187
|
const scanCornerLineLength = 15;
|
|
192
188
|
const scanCornerLineHeight = 3;
|
|
193
|
-
const styles =
|
|
189
|
+
const styles = StyleSheet.create({
|
|
194
190
|
camera: {
|
|
195
191
|
display: "flex",
|
|
196
192
|
flex: 1,
|
|
@@ -198,8 +194,8 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
198
194
|
backgroundColor: "red",
|
|
199
195
|
},
|
|
200
196
|
cameraBackground: {
|
|
201
|
-
width:
|
|
202
|
-
height:
|
|
197
|
+
width: px2dp(scanW),
|
|
198
|
+
height: px2dp(scanW),
|
|
203
199
|
backgroundColor: transparent,
|
|
204
200
|
},
|
|
205
201
|
scanContainer: {
|
|
@@ -211,97 +207,95 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
211
207
|
rectangle: { flexDirection: "row", overflow: "hidden" },
|
|
212
208
|
rectangleLeft: {
|
|
213
209
|
backgroundColor: transparent,
|
|
214
|
-
height:
|
|
215
|
-
width:
|
|
210
|
+
height: px2dp(scanW),
|
|
211
|
+
width: px2dp(scanW),
|
|
216
212
|
},
|
|
217
213
|
rectangleRight: {
|
|
218
214
|
backgroundColor: transparent,
|
|
219
|
-
height:
|
|
220
|
-
width:
|
|
215
|
+
height: px2dp(scanW),
|
|
216
|
+
width: px2dp(scanW),
|
|
221
217
|
},
|
|
222
|
-
rectangleText: { color: "#fff", lineHeight:
|
|
218
|
+
rectangleText: { color: "#fff", lineHeight: px2dp(15) },
|
|
223
219
|
scanLine: {
|
|
224
|
-
width:
|
|
225
|
-
height:
|
|
226
|
-
borderRadius:
|
|
220
|
+
width: px2dp(scanW),
|
|
221
|
+
height: px2dp(scanCornerLineHeight),
|
|
222
|
+
borderRadius: px2dp(25),
|
|
227
223
|
backgroundColor: lineColor,
|
|
228
224
|
},
|
|
229
225
|
reactLineTopLeftX: {
|
|
230
226
|
position: "absolute",
|
|
231
227
|
top: 0,
|
|
232
228
|
left: 0,
|
|
233
|
-
width:
|
|
234
|
-
height:
|
|
229
|
+
width: px2dp(scanCornerLineLength),
|
|
230
|
+
height: px2dp(scanCornerLineHeight),
|
|
235
231
|
backgroundColor: lineColor,
|
|
236
232
|
},
|
|
237
233
|
reactLineTopLeftY: {
|
|
238
234
|
position: "absolute",
|
|
239
235
|
top: 0,
|
|
240
236
|
left: 0,
|
|
241
|
-
width:
|
|
242
|
-
height:
|
|
237
|
+
width: px2dp(scanCornerLineHeight),
|
|
238
|
+
height: px2dp(scanCornerLineLength),
|
|
243
239
|
backgroundColor: lineColor,
|
|
244
240
|
},
|
|
245
241
|
reactLineTopRightX: {
|
|
246
242
|
position: "absolute",
|
|
247
243
|
top: 0,
|
|
248
244
|
right: 0,
|
|
249
|
-
width:
|
|
250
|
-
height:
|
|
245
|
+
width: px2dp(scanCornerLineLength),
|
|
246
|
+
height: px2dp(scanCornerLineHeight),
|
|
251
247
|
backgroundColor: lineColor,
|
|
252
248
|
},
|
|
253
249
|
reactLineTopRightY: {
|
|
254
250
|
position: "absolute",
|
|
255
251
|
top: 0,
|
|
256
252
|
right: 0,
|
|
257
|
-
width:
|
|
258
|
-
height:
|
|
253
|
+
width: px2dp(scanCornerLineHeight),
|
|
254
|
+
height: px2dp(scanCornerLineLength),
|
|
259
255
|
backgroundColor: lineColor,
|
|
260
256
|
},
|
|
261
257
|
reactLineBottomLeftX: {
|
|
262
258
|
position: "absolute",
|
|
263
259
|
bottom: 0,
|
|
264
260
|
left: 0,
|
|
265
|
-
width:
|
|
266
|
-
height:
|
|
261
|
+
width: px2dp(scanCornerLineLength),
|
|
262
|
+
height: px2dp(scanCornerLineHeight),
|
|
267
263
|
backgroundColor: lineColor,
|
|
268
264
|
},
|
|
269
265
|
reactLineBottomLeftY: {
|
|
270
266
|
position: "absolute",
|
|
271
267
|
bottom: 0,
|
|
272
268
|
left: 0,
|
|
273
|
-
width:
|
|
274
|
-
height:
|
|
269
|
+
width: px2dp(scanCornerLineHeight),
|
|
270
|
+
height: px2dp(scanCornerLineLength),
|
|
275
271
|
backgroundColor: lineColor,
|
|
276
272
|
},
|
|
277
273
|
reactLineBottomRightX: {
|
|
278
274
|
position: "absolute",
|
|
279
275
|
bottom: 0,
|
|
280
276
|
right: 0,
|
|
281
|
-
width:
|
|
282
|
-
height:
|
|
277
|
+
width: px2dp(scanCornerLineLength),
|
|
278
|
+
height: px2dp(scanCornerLineHeight),
|
|
283
279
|
backgroundColor: lineColor,
|
|
284
280
|
},
|
|
285
281
|
reactLineBottomRightY: {
|
|
286
282
|
position: "absolute",
|
|
287
283
|
bottom: 0,
|
|
288
284
|
right: 0,
|
|
289
|
-
width:
|
|
290
|
-
height:
|
|
285
|
+
width: px2dp(scanCornerLineHeight),
|
|
286
|
+
height: px2dp(scanCornerLineLength),
|
|
291
287
|
backgroundColor: lineColor,
|
|
292
288
|
},
|
|
293
289
|
flashlight: {
|
|
294
|
-
width:
|
|
295
|
-
height:
|
|
290
|
+
width: px2dp(30),
|
|
291
|
+
height: px2dp(30),
|
|
296
292
|
resizeMode: "contain",
|
|
297
|
-
marginTop:
|
|
298
|
-
marginBottom:
|
|
299
|
-
marginHorizontal:
|
|
293
|
+
marginTop: px2dp(50),
|
|
294
|
+
marginBottom: px2dp(15),
|
|
295
|
+
marginHorizontal: px2dp(15),
|
|
300
296
|
},
|
|
301
|
-
grantedText: { lineHeight:
|
|
297
|
+
grantedText: { lineHeight: px2dp(30), color: lineColor, fontWeight: "bold" },
|
|
302
298
|
});
|
|
303
|
-
|
|
304
|
-
const showScanner = (cb) =>
|
|
305
|
-
|
|
306
|
-
const hideScanner = () => exports.scannerRef.current?.hideScanner();
|
|
307
|
-
exports.hideScanner = hideScanner;
|
|
299
|
+
export const scannerRef = React.createRef();
|
|
300
|
+
export const showScanner = (cb) => scannerRef.current?.showScanner(cb);
|
|
301
|
+
export const hideScanner = () => scannerRef.current?.hideScanner();
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showToast = exports.toastRef = exports.Toast = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
1
|
/*
|
|
6
2
|
* @Author: shiguo
|
|
7
3
|
* @Date: 2021-04-27 10:38:04
|
|
@@ -9,47 +5,46 @@ const tslib_1 = require("tslib");
|
|
|
9
5
|
* @LastEditTime: 2022-09-09 10:58:34
|
|
10
6
|
* @FilePath: /@aks-dev/easyui/lib/Hud/Toast/Toast.tsx
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import React, { useImperativeHandle, useState, useRef } from "react";
|
|
9
|
+
import { View, StyleSheet, Text, Dimensions, Animated, Easing, } from "react-native";
|
|
14
10
|
const errorMsg = "(^_^)∠※ 送你一束小花";
|
|
15
|
-
|
|
16
|
-
const [tipText, setTipText] =
|
|
17
|
-
const fade =
|
|
18
|
-
const fadeAnimation =
|
|
19
|
-
|
|
11
|
+
export const Toast = React.forwardRef((_, ref) => {
|
|
12
|
+
const [tipText, setTipText] = useState(errorMsg);
|
|
13
|
+
const fade = useRef(new Animated.Value(0)).current;
|
|
14
|
+
const fadeAnimation = Animated.sequence([
|
|
15
|
+
Animated.timing(fade, {
|
|
20
16
|
toValue: 1,
|
|
21
17
|
duration: 750,
|
|
22
18
|
useNativeDriver: true,
|
|
23
|
-
easing:
|
|
19
|
+
easing: Easing.linear,
|
|
24
20
|
}),
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
Animated.delay(3000),
|
|
22
|
+
Animated.timing(fade, {
|
|
27
23
|
toValue: 0,
|
|
28
24
|
duration: 750,
|
|
29
25
|
useNativeDriver: true,
|
|
30
|
-
easing:
|
|
26
|
+
easing: Easing.linear,
|
|
31
27
|
}),
|
|
32
28
|
]);
|
|
33
|
-
|
|
29
|
+
useImperativeHandle(ref, () => ({
|
|
34
30
|
showToast: (content) => {
|
|
35
31
|
setTipText(content || errorMsg);
|
|
36
32
|
fadeAnimation.reset();
|
|
37
33
|
fadeAnimation.start();
|
|
38
34
|
},
|
|
39
35
|
}));
|
|
40
|
-
return (<
|
|
41
|
-
<
|
|
42
|
-
<
|
|
36
|
+
return (<Animated.View style={{ ...styles.toastContainer, opacity: fade }}>
|
|
37
|
+
<View style={styles.toastTipsContainer}>
|
|
38
|
+
<Text numberOfLines={5} style={{ ...styles.toastTitle }}>
|
|
43
39
|
{tipText}{" "}
|
|
44
|
-
</
|
|
45
|
-
</
|
|
46
|
-
</
|
|
40
|
+
</Text>
|
|
41
|
+
</View>
|
|
42
|
+
</Animated.View>);
|
|
47
43
|
});
|
|
48
|
-
|
|
49
|
-
const showToast = (content) =>
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const styles = react_native_1.StyleSheet.create({
|
|
44
|
+
export const toastRef = React.createRef();
|
|
45
|
+
export const showToast = (content) => toastRef.current?.showToast(content);
|
|
46
|
+
const SCREEN_WIDTH = Dimensions.get("window").width;
|
|
47
|
+
const styles = StyleSheet.create({
|
|
53
48
|
toastContainer: {
|
|
54
49
|
position: "absolute",
|
|
55
50
|
bottom: 100,
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_native_1 = require("react-native");
|
|
6
|
-
const px2dp_1 = require("../../screen/px2dp");
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Image, ScrollView, Text, TouchableOpacity, View, } from "react-native";
|
|
3
|
+
import { deviceHeight, deviceWidth } from "../../screen/px2dp";
|
|
7
4
|
// import * as utils from '../../utils/lazy';
|
|
8
|
-
|
|
5
|
+
import { hidePopoverView, showPopoverView } from "../Hud/Hud";
|
|
9
6
|
// type Reducer = (prevState: State, action: Partial<State>) => State
|
|
10
|
-
|
|
7
|
+
export default (props) => {
|
|
11
8
|
const { defaultAlignHorizontal = "left", defaultAlignVertical = "bottom" } = props;
|
|
12
|
-
const [state, dispatch] =
|
|
9
|
+
const [state, dispatch] = React.useReducer((prevState, action) => Object.assign({}, prevState, action), {});
|
|
13
10
|
// const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
|
|
14
|
-
const containerRef =
|
|
15
|
-
const rootView =
|
|
16
|
-
const sc =
|
|
11
|
+
const containerRef = React.useRef(null);
|
|
12
|
+
const rootView = React.useRef({ pageX: 0, pageY: 0, width: 0, height: 0 });
|
|
13
|
+
const sc = React.useRef({ x: 0, y: 0, width: 0, height: 0 });
|
|
17
14
|
// React.useEffect(() => {
|
|
18
15
|
// ; (async () => {
|
|
19
16
|
// await utils.sleep()
|
|
@@ -54,10 +51,10 @@ exports.default = (props) => {
|
|
|
54
51
|
let x = rootView.current.pageX;
|
|
55
52
|
// let y = (StatusBar.currentHeight || 0) + _container.current.y + height
|
|
56
53
|
let y = rootView.current.pageY + height;
|
|
57
|
-
if (x > Math.abs(
|
|
54
|
+
if (x > Math.abs(deviceWidth - width - x)) {
|
|
58
55
|
alignHorizontal = "right";
|
|
59
56
|
}
|
|
60
|
-
if (y >
|
|
57
|
+
if (y > deviceHeight * 0.5) {
|
|
61
58
|
alignVertical = "top";
|
|
62
59
|
}
|
|
63
60
|
/**todo: target_width的获取是延迟的,所以这里又问题 */
|
|
@@ -79,9 +76,9 @@ exports.default = (props) => {
|
|
|
79
76
|
// console.log({ getLayoutInfos: getLayoutInfos() })
|
|
80
77
|
const layout = () => {
|
|
81
78
|
if (alignHorizontal == "left") {
|
|
82
|
-
if (target_width + x >
|
|
79
|
+
if (target_width + x > deviceWidth) {
|
|
83
80
|
return {
|
|
84
|
-
left: Math.abs(
|
|
81
|
+
left: Math.abs(deviceWidth - target_width) * 0.7,
|
|
85
82
|
top: y,
|
|
86
83
|
};
|
|
87
84
|
}
|
|
@@ -91,10 +88,10 @@ exports.default = (props) => {
|
|
|
91
88
|
};
|
|
92
89
|
}
|
|
93
90
|
else {
|
|
94
|
-
let _x =
|
|
95
|
-
if (target_width + _x >
|
|
91
|
+
let _x = deviceWidth - x - width;
|
|
92
|
+
if (target_width + _x > deviceWidth) {
|
|
96
93
|
return {
|
|
97
|
-
right: Math.abs(
|
|
94
|
+
right: Math.abs(deviceWidth - target_width) * 0.7,
|
|
98
95
|
top: y,
|
|
99
96
|
};
|
|
100
97
|
}
|
|
@@ -123,11 +120,11 @@ exports.default = (props) => {
|
|
|
123
120
|
/**重新获取rootview的定位 */
|
|
124
121
|
await getRootViewlayoutPromise();
|
|
125
122
|
/**重新获取rootview的定位 */
|
|
126
|
-
|
|
127
|
-
content: (<
|
|
123
|
+
showPopoverView({
|
|
124
|
+
content: (<TouchableOpacity activeOpacity={1} style={{
|
|
128
125
|
position: "absolute",
|
|
129
|
-
minWidth:
|
|
130
|
-
maxWidth:
|
|
126
|
+
minWidth: deviceWidth * 0.36,
|
|
127
|
+
maxWidth: deviceWidth * 0.8,
|
|
131
128
|
minHeight: CELL_HEIGHT + PADDING * 2,
|
|
132
129
|
maxHeight: CELL_HEIGHT * 5 + PADDING * 2,
|
|
133
130
|
borderRadius: 6,
|
|
@@ -136,7 +133,7 @@ exports.default = (props) => {
|
|
|
136
133
|
padding: PADDING,
|
|
137
134
|
...reLayout(),
|
|
138
135
|
}}>
|
|
139
|
-
<
|
|
136
|
+
<View style={{
|
|
140
137
|
width: ARROW_HEIGHT,
|
|
141
138
|
height: ARROW_HEIGHT,
|
|
142
139
|
backgroundColor: "#000000ee",
|
|
@@ -157,13 +154,13 @@ exports.default = (props) => {
|
|
|
157
154
|
})(),
|
|
158
155
|
}}/>
|
|
159
156
|
|
|
160
|
-
<
|
|
157
|
+
<ScrollView onLayout={(e) => {
|
|
161
158
|
// console.log('target onLayout', e.nativeEvent.layout)
|
|
162
159
|
let _sc = e.nativeEvent.layout;
|
|
163
160
|
sc.current = _sc;
|
|
164
161
|
}}>
|
|
165
162
|
{props.data?.map((i, idx) => {
|
|
166
|
-
return (<
|
|
163
|
+
return (<TouchableOpacity activeOpacity={0.7} key={`sg-memnu-${idx}`} style={{
|
|
167
164
|
height: CELL_HEIGHT,
|
|
168
165
|
display: "flex",
|
|
169
166
|
flexDirection: "row",
|
|
@@ -171,17 +168,17 @@ exports.default = (props) => {
|
|
|
171
168
|
// ,backgroundColor:utils.randomcolor()
|
|
172
169
|
}} onPress={(e) => {
|
|
173
170
|
props.onItemClick && props.onItemClick(idx, i.extra);
|
|
174
|
-
|
|
171
|
+
hidePopoverView();
|
|
175
172
|
}}>
|
|
176
|
-
{i.icon && (<
|
|
177
|
-
<
|
|
173
|
+
{i.icon && (<Image style={{ width: 18, height: 18, marginRight: 4 }} source={i.icon}/>)}
|
|
174
|
+
<Text style={{ flexShrink: 1, fontSize: 14, color: "white" }}>
|
|
178
175
|
{i.text}
|
|
179
|
-
</
|
|
180
|
-
</
|
|
176
|
+
</Text>
|
|
177
|
+
</TouchableOpacity>);
|
|
181
178
|
})}
|
|
182
|
-
</
|
|
183
|
-
</
|
|
179
|
+
</ScrollView>
|
|
180
|
+
</TouchableOpacity>),
|
|
184
181
|
});
|
|
185
182
|
};
|
|
186
|
-
return (<
|
|
183
|
+
return (<TouchableOpacity ref={containerRef} onPress={(e) => show()} {...props}/>);
|
|
187
184
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* @Author: shiguo
|
|
4
3
|
* @Date: 2022-04-26 11:30:34
|
|
@@ -6,8 +5,4 @@
|
|
|
6
5
|
* @LastEditTime: 2022-10-27 16:37:32
|
|
7
6
|
* @FilePath: /@aks-dev/easyui/lib/Modal/Modal.tsx
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
exports.Modal = void 0;
|
|
11
|
-
const tslib_1 = require("tslib");
|
|
12
|
-
var react_native_modal_1 = require("react-native-modal");
|
|
13
|
-
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return tslib_1.__importDefault(react_native_modal_1).default; } });
|
|
8
|
+
export { default as Modal } from 'react-native-modal';
|