@aks-dev/easyui 1.0.163 → 1.1.5

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.
Files changed (176) hide show
  1. package/dist/components/AnimationModal/AnimationModal.d.ts +27 -0
  2. package/dist/components/AnimationModal/AnimationModal.d.ts.map +1 -0
  3. package/dist/components/AnimationModal/AnimationModal.js +151 -0
  4. package/dist/components/Badge/Badge.d.ts +8 -0
  5. package/dist/components/Badge/Badge.d.ts.map +1 -0
  6. package/dist/components/Badge/Badge.js +35 -0
  7. package/dist/components/DottedLine/DottedLine.d.ts +10 -0
  8. package/dist/components/DottedLine/DottedLine.d.ts.map +1 -0
  9. package/dist/components/DottedLine/DottedLine.js +50 -0
  10. package/dist/components/EchartsView/EchartsView.d.ts +10 -0
  11. package/dist/components/EchartsView/EchartsView.d.ts.map +1 -0
  12. package/{lib/Echarts/EchartsView.tsx → dist/components/EchartsView/EchartsView.js} +74 -113
  13. package/dist/components/EchartsView/helper.d.ts +10 -0
  14. package/dist/components/EchartsView/helper.d.ts.map +1 -0
  15. package/{lib/Echarts/helper.tsx → dist/components/EchartsView/helper.js} +17 -24
  16. package/dist/components/Hud/AlertBottomView/AlertBottomView.d.ts +25 -0
  17. package/dist/components/Hud/AlertBottomView/AlertBottomView.d.ts.map +1 -0
  18. package/dist/components/Hud/AlertBottomView/AlertBottomView.js +174 -0
  19. package/dist/components/Hud/AlertSheetView/AlertSheetView.d.ts +19 -0
  20. package/dist/components/Hud/AlertSheetView/AlertSheetView.d.ts.map +1 -0
  21. package/dist/components/Hud/AlertSheetView/AlertSheetView.js +117 -0
  22. package/dist/components/Hud/AlertView/AlertView.d.ts +25 -0
  23. package/dist/components/Hud/AlertView/AlertView.d.ts.map +1 -0
  24. package/dist/components/Hud/AlertView/AlertView.js +184 -0
  25. package/dist/components/Hud/Hud.d.ts +11 -0
  26. package/dist/components/Hud/Hud.d.ts.map +1 -0
  27. package/dist/components/Hud/Hud.js +29 -0
  28. package/dist/components/Hud/Loading/Loading.d.ts +11 -0
  29. package/dist/components/Hud/Loading/Loading.d.ts.map +1 -0
  30. package/dist/components/Hud/Loading/Loading.js +66 -0
  31. package/dist/components/Hud/PopoverView/PopoverView.d.ts +17 -0
  32. package/dist/components/Hud/PopoverView/PopoverView.d.ts.map +1 -0
  33. package/dist/components/Hud/PopoverView/PopoverView.js +47 -0
  34. package/dist/components/Hud/Scanner/Scanner.d.ts +12 -0
  35. package/dist/components/Hud/Scanner/Scanner.d.ts.map +1 -0
  36. package/dist/components/Hud/Scanner/Scanner.js +301 -0
  37. package/dist/components/Hud/Toast/Toast.d.ts +9 -0
  38. package/dist/components/Hud/Toast/Toast.d.ts.map +1 -0
  39. package/dist/components/Hud/Toast/Toast.js +71 -0
  40. package/dist/components/MenuView/MenuView.d.ts +21 -0
  41. package/dist/components/MenuView/MenuView.d.ts.map +1 -0
  42. package/dist/components/MenuView/MenuView.js +184 -0
  43. package/dist/components/Modal/Modal.d.ts +2 -0
  44. package/dist/components/Modal/Modal.d.ts.map +1 -0
  45. package/{lib/Modal/Modal.tsx → dist/components/Modal/Modal.js} +1 -4
  46. package/{lib/MutiPictureView/index.ts → dist/components/MutiPictureView/MutiPictureView.d.ts} +18 -31
  47. package/dist/components/MutiPictureView/MutiPictureView.d.ts.map +1 -0
  48. package/dist/components/MutiPictureView/MutiPictureView.js +243 -0
  49. package/dist/components/PictureViewer/PictureViewer.d.ts +17 -0
  50. package/dist/components/PictureViewer/PictureViewer.d.ts.map +1 -0
  51. package/dist/components/PictureViewer/PictureViewer.js +54 -0
  52. package/dist/components/RefreshList/RefreshList.d.ts +45 -0
  53. package/dist/components/RefreshList/RefreshList.d.ts.map +1 -0
  54. package/dist/components/RefreshList/RefreshList.js +155 -0
  55. package/dist/components/RichText/RichText.d.ts +12 -0
  56. package/dist/components/RichText/RichText.d.ts.map +1 -0
  57. package/dist/components/RichText/RichText.js +56 -0
  58. package/dist/components/StickHeaderView/StickHeaderView.d.ts +15 -0
  59. package/dist/components/StickHeaderView/StickHeaderView.d.ts.map +1 -0
  60. package/dist/components/StickHeaderView/StickHeaderView.js +37 -0
  61. package/{lib/TableCell/index.ts → dist/components/TableCell/TableCell.d.ts} +8 -30
  62. package/dist/components/TableCell/TableCell.d.ts.map +1 -0
  63. package/dist/components/TableCell/TableCell.js +97 -0
  64. package/dist/components/TextInputArea/TextInputArea.d.ts +17 -0
  65. package/dist/components/TextInputArea/TextInputArea.d.ts.map +1 -0
  66. package/dist/components/TextInputArea/TextInputArea.js +65 -0
  67. package/dist/components/WithLoadingContainer/WithLoadingContainer.d.ts +23 -0
  68. package/dist/components/WithLoadingContainer/WithLoadingContainer.d.ts.map +1 -0
  69. package/dist/components/WithLoadingContainer/WithLoadingContainer.js +77 -0
  70. package/dist/index.d.ts +23 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +32 -0
  73. package/dist/jsbridge/RNEasyui.d.ts +23 -0
  74. package/dist/jsbridge/RNEasyui.d.ts.map +1 -0
  75. package/dist/jsbridge/RNEasyui.js +46 -0
  76. package/dist/jsbridge/UpgradeModule.d.ts +26 -0
  77. package/dist/jsbridge/UpgradeModule.d.ts.map +1 -0
  78. package/{jsbridge/UpgradeModule.ts → dist/jsbridge/UpgradeModule.js} +25 -23
  79. package/dist/jsbridge/index.d.ts +3 -0
  80. package/dist/jsbridge/index.d.ts.map +1 -0
  81. package/{jsbridge/index.ts → dist/jsbridge/index.js} +2 -2
  82. package/dist/screen/index.d.ts +3 -0
  83. package/dist/screen/index.d.ts.map +1 -0
  84. package/{screen/index.ts → dist/screen/index.js} +2 -2
  85. package/{screen/index.d.ts → dist/screen/px2dp.d.ts} +6 -12
  86. package/dist/screen/px2dp.d.ts.map +1 -0
  87. package/dist/screen/px2dp.js +45 -0
  88. package/dist/screen/px2sp.d.ts +2 -0
  89. package/dist/screen/px2sp.d.ts.map +1 -0
  90. package/{screen/px2sp.ts → dist/screen/px2sp.js} +13 -20
  91. package/dist/screen/text-fit.d.ts +5 -0
  92. package/dist/screen/text-fit.d.ts.map +1 -0
  93. package/{screen/text-fit.ts → dist/screen/text-fit.js} +10 -20
  94. package/dist/utils/index.d.ts +3 -0
  95. package/dist/utils/index.d.ts.map +1 -0
  96. package/{utils/index.ts → dist/utils/index.js} +2 -2
  97. package/{utils/index.d.ts → dist/utils/lazy.d.ts} +15 -53
  98. package/dist/utils/lazy.d.ts.map +1 -0
  99. package/{utils/lazy.ts → dist/utils/lazy.js} +164 -165
  100. package/dist/utils/mode.d.ts +24 -0
  101. package/dist/utils/mode.d.ts.map +1 -0
  102. package/dist/utils/mode.js +50 -0
  103. package/package.json +32 -22
  104. package/readme.md +3 -3
  105. package/android/.DS_Store +0 -0
  106. package/android/src/.DS_Store +0 -0
  107. package/android/src/main/.DS_Store +0 -0
  108. package/android/src/main/java/.DS_Store +0 -0
  109. package/android/src/main/java/com/.DS_Store +0 -0
  110. package/android/src/main/java/com/easyui/.DS_Store +0 -0
  111. package/i.sh +0 -23
  112. package/ios/.DS_Store +0 -0
  113. package/ios/assets/.DS_Store +0 -0
  114. package/ios/views/.DS_Store +0 -0
  115. package/jsbridge/RNEasyui.ts +0 -42
  116. package/jsbridge/index.d.ts +0 -67
  117. package/lib/.DS_Store +0 -0
  118. package/lib/AnimationModal/AnimationModal.tsx +0 -201
  119. package/lib/AnimationModal/index.d.ts +0 -41
  120. package/lib/Badge/Badge.tsx +0 -40
  121. package/lib/Badge/index.ts +0 -21
  122. package/lib/DottedLine/DottedLine.tsx +0 -66
  123. package/lib/DottedLine/index.ts +0 -18
  124. package/lib/Echarts/demo.tsx +0 -235
  125. package/lib/Echarts/index.ts +0 -29
  126. package/lib/Hud/.DS_Store +0 -0
  127. package/lib/Hud/AlertBottomView/AlertBottomView.tsx +0 -228
  128. package/lib/Hud/AlertBottomView/index.d.ts +0 -42
  129. package/lib/Hud/AlertSheetView/AlertSheetView.tsx +0 -179
  130. package/lib/Hud/AlertSheetView/index.d.ts +0 -35
  131. package/lib/Hud/AlertView/AlertView.tsx +0 -234
  132. package/lib/Hud/AlertView/index.d.ts +0 -46
  133. package/lib/Hud/Hud.tsx +0 -67
  134. package/lib/Hud/Loading/Loading.tsx +0 -87
  135. package/lib/Hud/Loading/index.d.ts +0 -38
  136. package/lib/Hud/PopoverView/PopoverView.tsx +0 -66
  137. package/lib/Hud/PopoverView/index.d.ts +0 -39
  138. package/lib/Hud/Scanner/Scanner.tsx +0 -250
  139. package/lib/Hud/Scanner/index.d.ts +0 -42
  140. package/lib/Hud/Toast/Toast.tsx +0 -86
  141. package/lib/Hud/Toast/index.d.ts +0 -22
  142. package/lib/Hud/index.ts +0 -20
  143. package/lib/MenuView/MenuView.tsx +0 -252
  144. package/lib/MenuView/index.ts +0 -31
  145. package/lib/Modal/index.ts +0 -10
  146. package/lib/MutiPictureView/MutiPictureView.tsx +0 -259
  147. package/lib/PictureViewer/PictureViewer.tsx +0 -80
  148. package/lib/PictureViewer/index.ts +0 -26
  149. package/lib/RefreshList/RefreshList.tsx +0 -235
  150. package/lib/RefreshList/demo.tsx +0 -30
  151. package/lib/RefreshList/demo1.tsx +0 -60
  152. package/lib/RefreshList/demo2.tsx +0 -46
  153. package/lib/RefreshList/index.ts +0 -84
  154. package/lib/RichText/RichText.tsx +0 -82
  155. package/lib/RichText/index.ts +0 -21
  156. package/lib/StickHeaderView/StickHeaderView.tsx +0 -65
  157. package/lib/StickHeaderView/demo.tsx +0 -104
  158. package/lib/StickHeaderView/index.ts +0 -26
  159. package/lib/TableCell/TableCell.tsx +0 -118
  160. package/lib/TextInputArea/TextInputArea.tsx +0 -89
  161. package/lib/TextInputArea/index.d.ts +0 -33
  162. package/lib/WithLoadingContainer/WithLoadingContainer.tsx +0 -93
  163. package/lib/WithLoadingContainer/index.ts +0 -36
  164. package/screen/px2dp.ts +0 -51
  165. package/src/index.d.ts +0 -42
  166. package/src/index.ts +0 -54
  167. package/utils/mode.ts +0 -48
  168. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-blue.png +0 -0
  169. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-white.png +0 -0
  170. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/icon_back_white.png +0 -0
  171. /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_add_image.png +0 -0
  172. /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_del_image.png +0 -0
  173. /package/{lib/TableCell → dist/components/TableCell/assets}/back.png +0 -0
  174. /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading.gif +0 -0
  175. /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading3.gif +0 -0
  176. /package/{lib → dist/components}/index.md +0 -0
@@ -1,250 +0,0 @@
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
- */
8
- import React, { useImperativeHandle, useState } from 'react';
9
- import {
10
- Animated, BackHandler, Easing, Image, StyleProp, StyleSheet, Text, TouchableOpacity, View, ViewStyle
11
- } from 'react-native';
12
- import { RNCamera, BarCodeReadEvent } from 'react-native-camera';
13
- import { PERMISSIONS, requestMultiple } from 'react-native-permissions';
14
- import { navigationBarHeight, px2dp, statusBarHeight } from '../../../screen/px2dp';
15
- import { px2sp } from '../../../screen/px2sp';
16
- import * as utils from '../../../utils/lazy';
17
- import { showToast } from '../Toast/Toast';
18
- import { ScannerOptions } from './index';
19
-
20
-
21
-
22
-
23
-
24
-
25
- // enum SCANNER_TYPE {
26
- // DENIED = -1,//没有开始权限
27
- // START = 0,//没有扫描结果,继续扫描
28
- // SUCCESS = 1,//已有扫描结果,停止扫描
29
- // }
30
-
31
- export const Scanner = React.forwardRef<ScannerOptions.RefAttributes, {}>((_, ref) => {
32
- const [show, setShow] = useState<boolean>(false);
33
- const [torchOn, setTorchOn] = React.useState<boolean>(false)
34
- const moveAnim = React.useRef(new Animated.Value(0)).current
35
- const [pointStyle, setPointStyle] = React.useState<StyleProp<ViewStyle>>()
36
- const cameraRef: React.MutableRefObject<RNCamera> = React.useRef() as any
37
- const _cbRef: React.MutableRefObject<ScannerOptions.CallBack> = React.useRef() as any
38
- const _scanerResultRef = React.useRef<any>()
39
- React.useEffect(() => {
40
- const onBackPress = () => {
41
- if (show) {
42
- _hideScanner()
43
- }
44
- return true
45
- }
46
- BackHandler.addEventListener('hardwareBackPress', onBackPress);
47
- return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
48
- }, [show])
49
-
50
-
51
-
52
-
53
- useImperativeHandle<unknown, ScannerOptions.RefAttributes>(ref, () => ({
54
- showScanner: _showScanner,
55
- hideScanner: _hideScanner
56
- }), [show])
57
-
58
-
59
-
60
- const _showScanner = async (cb: ScannerOptions.CallBack) => {
61
- let res = await requestMultiple([PERMISSIONS.IOS.CAMERA, PERMISSIONS.ANDROID.CAMERA])
62
- if (res[PERMISSIONS.ANDROID.CAMERA] == "granted" || res[PERMISSIONS.IOS.CAMERA] == "granted") {
63
- _scanerResultRef.current = undefined;
64
- setShow(true);
65
- setPointStyle({})
66
- await utils.sleep()
67
- animationStart()
68
- _cbRef.current = cb;
69
- } else {
70
- _hideScanner()
71
- showToast('您未开启相机权限,暂不能使用此功能')
72
- }
73
-
74
-
75
- }
76
-
77
- const _hideScanner = async () => {
78
- animationStop()
79
- await utils.sleep()
80
- setShow(false);
81
- }
82
-
83
-
84
-
85
- const animation = Animated.loop(Animated.sequence([
86
- Animated.timing(
87
- moveAnim,
88
- {
89
- toValue: px2dp(222),
90
- duration: 3000,
91
- easing: Easing.linear,
92
- useNativeDriver: true,
93
- }
94
- ),
95
- Animated.timing(
96
- moveAnim,
97
- {
98
- toValue: 0,
99
- duration: 3000,
100
- easing: Easing.linear,
101
- useNativeDriver: true,
102
- }
103
- )
104
- ]))
105
-
106
-
107
-
108
- const animationStart = async () => {
109
-
110
- cameraRef.current?.resumePreview()
111
- animation.start(({ finished }) => {
112
- // console.log('animationStart finished', finished)
113
- if (finished) {
114
- animation.reset()
115
- animation.start()
116
- }
117
- })
118
- }
119
- const animationStop = (result?: any) => {
120
- cameraRef.current?.pausePreview()
121
- animation.stop()
122
- }
123
-
124
-
125
- // const getPointFromBounds = (bounds) => {
126
- // let x = 0
127
- // let y = 0
128
-
129
- // if (Platform.OS == 'android') {
130
- // bounds.origin.forEach(i => {
131
- // x = Math.max(x, parseFloat(i.x))
132
- // y = Math.max(y, parseFloat(i.y))
133
- // })
134
-
135
- // y = y * DeviceHeight / bounds.width
136
- // x = x * DeviceWidth / bounds.height
137
- // }
138
-
139
- // if(Platform.OS == 'ios'){
140
- // x=parseFloat(bounds.origin.x)
141
- // y=parseFloat(bounds.origin.y)
142
- // }
143
-
144
- // return { x, y }
145
- // }
146
-
147
-
148
- const onBarCodeRead = (e: BarCodeReadEvent) => {
149
- // console.log('ss onBarCodeRead: ', JSON.stringify(e))
150
- if (e?.data?.length > 0 && _scanerResultRef.current == undefined) {
151
- _scanerResultRef.current = e?.data
152
- _cbRef.current(e?.data)
153
- _hideScanner()
154
- }
155
- }
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
- if (!show) return null;
164
- return (
165
- <TouchableOpacity disabled style={StyleSheet.absoluteFillObject}>
166
- <RNCamera
167
- ref={cameraRef}
168
- captureAudio={false}
169
- autoFocus={RNCamera.Constants.AutoFocus.on}/*自动对焦*/
170
- style={styles.camera}
171
- type={RNCamera.Constants.Type.back}/*切换前后摄像头 front前back后*/
172
- flashMode={torchOn ? RNCamera.Constants.FlashMode.torch : RNCamera.Constants.FlashMode.off}/*相机闪光模式*/
173
- onBarCodeRead={onBarCodeRead}
174
-
175
-
176
- >
177
- {/* 导航栏 */}
178
- <View style={{ display: 'flex', justifyContent: "center", alignItems: "center", height: navigationBarHeight, marginTop: statusBarHeight, position: 'relative' }}>
179
- <TouchableOpacity onPress={() => _hideScanner()} style={{ height: navigationBarHeight, width: px2dp(50), paddingLeft: px2dp(15), position: 'absolute', left: 0, display: 'flex', justifyContent: 'center' }} >
180
- <Image source={require('./icon_back_white.png')} style={{ width: px2dp(20), height: px2dp(20) }} resizeMode='contain' />
181
- </TouchableOpacity>
182
- <Text style={{ fontSize: px2sp(16), color: 'white', fontWeight: 'bold' }}>扫一扫</Text>
183
- </View>
184
-
185
- {/* 动画框 */}
186
- <View style={styles.scanContainer}>
187
- <View style={styles.rectangle}>
188
- <View style={styles.rectangleLeft} />
189
- <View style={styles.cameraBackground}>
190
- <Animated.View style={[styles.scanLine, { transform: [{ translateY: moveAnim }] }]} />
191
- <View style={styles.reactLineTopLeftX} />
192
- <View style={styles.reactLineTopLeftY} />
193
- <View style={styles.reactLineTopRightX} />
194
- <View style={styles.reactLineTopRightY} />
195
- <View style={styles.reactLineBottomLeftX} />
196
- <View style={styles.reactLineBottomLeftY} />
197
- <View style={styles.reactLineBottomRightX} />
198
- <View style={styles.reactLineBottomRightY} />
199
- </View>
200
- <View style={styles.rectangleRight} />
201
- </View>
202
-
203
- <TouchableOpacity onPress={() => setTorchOn(!torchOn)}>
204
- <Image
205
- source={torchOn ? require('./flashlight-blue.png') : require('./flashlight-white.png')}
206
- style={styles.flashlight} />
207
- </TouchableOpacity>
208
- <Text style={styles.rectangleText}>将二维码/条码放入框内,即可自动扫描</Text>
209
- </View>
210
- <View style={pointStyle} />
211
- </RNCamera>
212
-
213
- </TouchableOpacity>
214
- )
215
- })
216
-
217
-
218
-
219
- const transparent = '#00000000'
220
- const lineColor = '#6ab3ff'
221
- const scanW = 225
222
- const scanCornerLineLength = 15;
223
- const scanCornerLineHeight = 3
224
- const styles = StyleSheet.create({
225
- camera: { display: 'flex', flex: 1, flexDirection: 'column', backgroundColor: "red" },
226
- cameraBackground: { width: px2dp(scanW), height: px2dp(scanW), backgroundColor: transparent },
227
- scanContainer: { display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center' },
228
- rectangle: { flexDirection: 'row', overflow: 'hidden', },
229
- rectangleLeft: { backgroundColor: transparent, height: px2dp(scanW), width: px2dp(scanW) },
230
- rectangleRight: { backgroundColor: transparent, height: px2dp(scanW), width: px2dp(scanW) },
231
- rectangleText: { color: '#fff', lineHeight: px2dp(15), },
232
- scanLine: { width: px2dp(scanW), height: px2dp(scanCornerLineHeight), borderRadius: px2dp(25), backgroundColor: lineColor, },
233
- reactLineTopLeftX: { position: 'absolute', top: 0, left: 0, width: px2dp(scanCornerLineLength), height: px2dp(scanCornerLineHeight), backgroundColor: lineColor },
234
- reactLineTopLeftY: { position: 'absolute', top: 0, left: 0, width: px2dp(scanCornerLineHeight), height: px2dp(scanCornerLineLength), backgroundColor: lineColor },
235
- reactLineTopRightX: { position: 'absolute', top: 0, right: 0, width: px2dp(scanCornerLineLength), height: px2dp(scanCornerLineHeight), backgroundColor: lineColor },
236
- reactLineTopRightY: { position: 'absolute', top: 0, right: 0, width: px2dp(scanCornerLineHeight), height: px2dp(scanCornerLineLength), backgroundColor: lineColor },
237
- reactLineBottomLeftX: { position: 'absolute', bottom: 0, left: 0, width: px2dp(scanCornerLineLength), height: px2dp(scanCornerLineHeight), backgroundColor: lineColor },
238
- reactLineBottomLeftY: { position: 'absolute', bottom: 0, left: 0, width: px2dp(scanCornerLineHeight), height: px2dp(scanCornerLineLength), backgroundColor: lineColor },
239
- reactLineBottomRightX: { position: 'absolute', bottom: 0, right: 0, width: px2dp(scanCornerLineLength), height: px2dp(scanCornerLineHeight), backgroundColor: lineColor },
240
- reactLineBottomRightY: { position: 'absolute', bottom: 0, right: 0, width: px2dp(scanCornerLineHeight), height: px2dp(scanCornerLineLength), backgroundColor: lineColor },
241
- flashlight: { width: px2dp(30), height: px2dp(30), resizeMode: 'contain', marginTop: px2dp(50), marginBottom: px2dp(15), marginHorizontal: px2dp(15) },
242
- grantedText: { lineHeight: px2dp(30), color: lineColor, fontWeight: 'bold' }
243
- })
244
-
245
-
246
-
247
-
248
- export const scannerRef = React.createRef<ScannerOptions.RefAttributes>();
249
- export const showScanner = (cb: ScannerOptions.CallBack) => scannerRef.current?.showScanner(cb)
250
- export const hideScanner = () => scannerRef.current?.hideScanner()
@@ -1,42 +0,0 @@
1
-
2
- /*
3
- * @Author: shiguo
4
- * @Date: 2022-04-24 14:27:02
5
- * @LastEditors: shiguo
6
- * @LastEditTime: 2023-03-23 12:36:02
7
- * @FilePath: /@aks-dev/easyui/lib/Hud/Scanner/index.d.ts
8
- */
9
- import * as React from 'react'
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- declare namespace ScannerOptions {
21
-
22
- type CallBack = (e: string) => void;
23
-
24
-
25
- type RefAttributes = {
26
- showScanner: (cb: CallBack) => void;
27
- hideScanner: () => void;
28
- }
29
- }
30
-
31
-
32
-
33
- export declare const showScanner: (cb: ScannerOptions.CallBack) => void;
34
-
35
-
36
- export declare const hideScanner: () => void;
37
-
38
-
39
- export declare const scannerRef: React.RefObject<ScannerOptions.RefAttributes>;
40
-
41
- export declare const Scanner: React.ForwardRefExoticComponent<React.PropsWithoutRef<{}> & React.RefAttributes<ScannerOptions.RefAttributes>>
42
-
@@ -1,86 +0,0 @@
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
- */
8
- import React, { useImperativeHandle, useState, useRef } from 'react';
9
- import { View, StyleSheet, Text, Dimensions, Animated, Easing } from 'react-native';
10
-
11
-
12
- import type { ToastOptions } from '.'
13
-
14
- const errorMsg = '(^_^)∠※ 送你一束小花'
15
-
16
- export const Toast = React.forwardRef<ToastOptions.RefAttributes, {}>((_, ref) => {
17
- const [tipText, setTipText] = useState(errorMsg);
18
- const fade = useRef(new Animated.Value(0)).current;
19
-
20
- const fadeAnimation = Animated.sequence([
21
- Animated.timing(fade, {
22
- toValue: 1,
23
- duration: 750,
24
- useNativeDriver: true,
25
- easing: Easing.linear,
26
- }),
27
- Animated.delay(3000),
28
- Animated.timing(fade, {
29
- toValue: 0,
30
- duration: 750,
31
- useNativeDriver: true,
32
- easing: Easing.linear,
33
- })
34
- ])
35
-
36
- useImperativeHandle<unknown, ToastOptions.RefAttributes>(ref, () => ({
37
- showToast: (content: string) => {
38
- setTipText(content || errorMsg)
39
- fadeAnimation.reset()
40
- fadeAnimation.start()
41
- },
42
- }))
43
-
44
- return (
45
- <Animated.View style={{ ...styles.toastContainer, opacity: fade }}>
46
- <View style={styles.toastTipsContainer}>
47
- <Text numberOfLines={5} style={{ ...styles.toastTitle, }}>{tipText} </Text>
48
- </View>
49
- </Animated.View>
50
-
51
- )
52
- })
53
-
54
- export const toastRef = React.createRef<ToastOptions.RefAttributes>();
55
-
56
- export const showToast = (content: string) => toastRef.current?.showToast(content)
57
-
58
-
59
-
60
- const SCREEN_WIDTH = Dimensions.get('window').width;
61
- const styles = StyleSheet.create({
62
- toastContainer: {
63
- position: 'absolute',
64
- bottom: 100,
65
- width: '100%',
66
- justifyContent: 'center',
67
- alignItems: 'center'
68
- },
69
-
70
- toastTipsContainer: {
71
- position: 'absolute',
72
- backgroundColor: '#00000088',
73
- padding: 10,
74
- // paddingVertical: 4,
75
- borderRadius: 2,
76
- justifyContent: 'center',
77
- alignItems: 'center',
78
- minWidth: 120
79
- },
80
- toastTitle: {
81
- fontSize: 13,
82
- lineHeight: 20,
83
- color: 'white',
84
- maxWidth: SCREEN_WIDTH * 0.8
85
- }
86
- })
@@ -1,22 +0,0 @@
1
- /*
2
- * @Author: shiguo
3
- * @Date: 2022-04-18 19:18:03
4
- * @LastEditors: shiguo
5
- * @LastEditTime: 2022-09-09 10:58:11
6
- * @FilePath: /@aks-dev/easyui/lib/Hud/Toast/index.ts
7
- */
8
- import * as React from 'react'
9
-
10
-
11
- declare namespace ToastOptions {
12
- type RefAttributes = {
13
- showToast: (content: string) => void;
14
- }
15
- }
16
-
17
- export declare const showToast: (content: string) => void;
18
-
19
-
20
- export declare const toastRef: React.RefObject<ToastOptions.RefAttributes>;
21
-
22
- export declare const Toast: React.ForwardRefExoticComponent<React.PropsWithoutRef<{}> & React.RefAttributes<ToastOptions.RefAttributes>>;
package/lib/Hud/index.ts DELETED
@@ -1,20 +0,0 @@
1
- /*
2
- * @Author: shiguo
3
- * @Date: 2022-04-24 14:14:42
4
- * @LastEditors: shiguo
5
- * @LastEditTime: 2023-03-23 11:05:22
6
- * @FilePath: /aks-fire-app/node_modules/@aks-dev/easyui/lib/Hud/index.ts
7
- */
8
-
9
-
10
- import * as React from 'react'
11
-
12
-
13
- export * from './AlertView'
14
- export * from './Loading'
15
- export * from './Toast'
16
- export * from './AlertBottomView'
17
- export * from './AlertSheetView'
18
- export * from './PopoverView'
19
- export * from './Scanner'
20
- export declare const Hud: React.FC<{}>
@@ -1,252 +0,0 @@
1
- import React from "react";
2
- import { Image, LayoutRectangle, MeasureOnSuccessCallback, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native';
3
- import type { MenuProps } from '.';
4
- import { deviceHeight, deviceWidth } from '../../screen/px2dp';
5
- // import * as utils from '../../utils/lazy';
6
- import { hidePopoverView, showPopoverView } from '../Hud/Hud';
7
-
8
- type State = {
9
- }
10
-
11
-
12
- type Reducer = (prevState: State, action: Partial<State>) => State
13
-
14
-
15
-
16
- export default (props: MenuProps) => {
17
-
18
- const {
19
- defaultAlignHorizontal = 'left',
20
- defaultAlignVertical = 'bottom'
21
- } = props
22
-
23
- const [state, dispatch] = React.useReducer<Reducer>((prevState, action) => Object.assign({}, prevState, action), {})
24
-
25
- // const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
26
- const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
27
- const rootView = React.useRef<{
28
- pageX: number;
29
- pageY: number;
30
- height: number;
31
- width: number;
32
- }>({ pageX: 0, pageY: 0, width: 0, height: 0 })
33
- const sc = React.useRef<LayoutRectangle>({ x: 0, y: 0, width: 0, height: 0 })
34
-
35
- // React.useEffect(() => {
36
- // ; (async () => {
37
- // await utils.sleep()
38
- // containerRef.current?.measure((...args) => {
39
- // console.log('containerRef', args)
40
- // if (args.length == 6) {
41
- // _container.current = {
42
- // x: args[4],
43
- // y: args[5],
44
- // width: args[2],
45
- // height: args[3],
46
- // }
47
- // }
48
- // })
49
- // })()
50
- // })
51
-
52
-
53
- const getRootViewlayoutPromise = () => {
54
- return new Promise((resovle, reject) => {
55
- containerRef.current?.measure((...args) => {
56
- if (args.length == 6) {
57
- rootView.current = {
58
- width: args[2],
59
- height: args[3],
60
- pageX: args[4],
61
- pageY: args[5],
62
- }
63
- }
64
- // console.log('RootView', rootView.current)
65
- resovle(args)
66
- })
67
- })
68
- }
69
-
70
-
71
- const getLayoutInfos: () => {
72
- alignVertical: 'bottom' | 'top';
73
- alignHorizontal: 'left' | 'right';
74
- width: number;
75
- height: number;
76
- x: number;
77
- y: number;
78
- target_width: number;
79
- target_height: number;
80
- }
81
- = () => {
82
- let alignVertical: 'bottom' | 'top' = defaultAlignVertical
83
- let alignHorizontal: 'left' | 'right' = defaultAlignHorizontal
84
- let width = rootView.current.width
85
- let height = rootView.current.height
86
- let x = rootView.current.pageX
87
- // let y = (StatusBar.currentHeight || 0) + _container.current.y + height
88
- let y = rootView.current.pageY + height
89
- if (x > Math.abs(deviceWidth - width - x)) {
90
- alignHorizontal = 'right'
91
- }
92
- if (y > deviceHeight * .5) {
93
- alignVertical = 'top'
94
- }
95
- /**todo: target_width的获取是延迟的,所以这里又问题 */
96
- const target_width = sc.current.width
97
- const target_height = CELL_HEIGHT * (Math.min(props.data?.length || 0, 5) || 0)
98
- return {
99
- alignVertical,
100
- alignHorizontal,
101
- width,
102
- height,
103
- x,
104
- y,
105
- target_width,
106
- target_height,
107
- }
108
- }
109
-
110
-
111
- const reLayout = (): Partial<{
112
- left: number;
113
- right: number;
114
- top: number;
115
- botttom: number;
116
- }> => {
117
- let {
118
- alignVertical,
119
- alignHorizontal,
120
- width,
121
- height,
122
- x,
123
- y,
124
- target_width,
125
- target_height,
126
- } = getLayoutInfos()
127
-
128
- // console.log({ getLayoutInfos: getLayoutInfos() })
129
- const layout = () => {
130
- if (alignHorizontal == 'left') {
131
- if (target_width + x > deviceWidth) {
132
- return {
133
- left: Math.abs(deviceWidth - target_width) * .7,
134
- top: y,
135
- }
136
- }
137
- return {
138
- left: Math.max(x, 15),
139
- top: y,
140
- }
141
- } else {
142
- let _x = deviceWidth - x - width
143
- if (target_width + _x > deviceWidth) {
144
- return {
145
- right: Math.abs(deviceWidth - target_width) * .7,
146
- top: y
147
- }
148
- }
149
- return {
150
- right: Math.max(_x, 15),
151
- top: y
152
- }
153
- }
154
- }
155
- if (alignVertical == 'bottom') {
156
- y = y + PADDING
157
- return layout()
158
- } else {
159
- y = rootView.current.pageY - target_height - PADDING * 2 - ARROW_HEIGHT
160
- return layout()
161
- }
162
- }
163
-
164
-
165
- const PADDING = 10
166
- const ARROW_HEIGHT = 12
167
- const CELL_HEIGHT = 36
168
-
169
-
170
- const show = async () => {
171
- props.onContainerClick && props.onContainerClick()
172
- if (props.data == undefined || props.data?.length == 0) return
173
- /**重新获取rootview的定位 */
174
- await getRootViewlayoutPromise()
175
- /**重新获取rootview的定位 */
176
- showPopoverView({
177
- content: (
178
- <TouchableOpacity
179
- activeOpacity={1}
180
- style={{
181
-
182
- position: 'absolute',
183
- minWidth: deviceWidth * 0.36,
184
- maxWidth: deviceWidth * 0.8,
185
- minHeight: CELL_HEIGHT + PADDING * 2,
186
- maxHeight: CELL_HEIGHT * 5 + PADDING * 2,
187
- borderRadius: 6, backgroundColor: '#000000ee',
188
- // overflow: 'hidden' ,
189
- padding: PADDING,
190
- ...reLayout()
191
- }}
192
- >
193
-
194
- <View style={{
195
- width: ARROW_HEIGHT, height: ARROW_HEIGHT,
196
- backgroundColor: '#000000ee', position: 'absolute', zIndex: 1,
197
- transform: [{ rotateZ: '45deg' }],
198
- ...(() => {
199
- const {
200
- alignVertical,
201
- alignHorizontal,
202
- } = getLayoutInfos()
203
- if (alignVertical == 'bottom' && alignHorizontal == 'left') return { left: '20%', top: -5 }
204
- if (alignVertical == 'bottom' && alignHorizontal == 'right') return { right: '20%', top: -5 }
205
- if (alignVertical == 'top' && alignHorizontal == 'left') return { left: '20%', bottom: -5 }
206
- if (alignVertical == 'top' && alignHorizontal == 'right') return { right: '20%', bottom: -5 }
207
- return {}
208
- })()
209
- }} />
210
-
211
- <ScrollView onLayout={e => {
212
- // console.log('target onLayout', e.nativeEvent.layout)
213
- let _sc: LayoutRectangle = e.nativeEvent.layout
214
- sc.current = _sc
215
- }}
216
- // style={{ backgroundColor: "red" }}
217
- >
218
- {props.data?.map((i, idx) => {
219
- return (
220
- <TouchableOpacity
221
- activeOpacity={.7}
222
- key={`sg-memnu-${idx}`}
223
- style={{
224
- height: CELL_HEIGHT, display: 'flex', flexDirection: 'row', alignItems: 'center'
225
- // ,backgroundColor:utils.randomcolor()
226
- }}
227
- onPress={e => {
228
- props.onItemClick && props.onItemClick(idx, i.extra)
229
- hidePopoverView()
230
- }}
231
- >
232
- {i.icon &&
233
- <Image style={{ width: 18, height: 18, marginRight: 4 }} source={i.icon} />
234
- }
235
- <Text style={{ flexShrink: 1, fontSize: 14, color: 'white' }}>{i.text}</Text>
236
- </TouchableOpacity>
237
- )
238
- })}
239
- </ScrollView>
240
- </TouchableOpacity>
241
- )
242
- })
243
- }
244
-
245
- return (
246
- <TouchableOpacity
247
- ref={containerRef as any}
248
- onPress={e => show()}
249
- {...props}
250
- />
251
- )
252
- }