@aks-dev/easyui 1.0.10

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 (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/android/build.gradle +44 -0
  4. package/android/src/main/AndroidManifest.xml +20 -0
  5. package/android/src/main/java/com/easyui/RNEasyuiModule.java +29 -0
  6. package/android/src/main/java/com/easyui/RNEasyuiPackage.java +38 -0
  7. package/android/src/main/java/com/easyui/UpgradeModule.java +54 -0
  8. package/ios/RNEasyui.h +18 -0
  9. package/ios/RNEasyui.m +13 -0
  10. package/ios/RNEasyui.podspec +24 -0
  11. package/ios/RNEasyui.xcodeproj/project.pbxproj +259 -0
  12. package/ios/RNEasyui.xcworkspace/contents.xcworkspacedata +9 -0
  13. package/ios/UpgradeModule.h +12 -0
  14. package/ios/UpgradeModule.m +38 -0
  15. package/jsbridge/RNEasyui.tsx +13 -0
  16. package/jsbridge/UpgradeModule.tsx +13 -0
  17. package/jsbridge/index.ts +13 -0
  18. package/lib/Badge/Badge.tsx +39 -0
  19. package/lib/Badge/index.ts +21 -0
  20. package/lib/Easy-Hud/AlertView/AlertView.tsx +233 -0
  21. package/lib/Easy-Hud/AlertView/index.ts +41 -0
  22. package/lib/Easy-Hud/EasyHud.tsx +48 -0
  23. package/lib/Easy-Hud/Loading/Loading.tsx +80 -0
  24. package/lib/Easy-Hud/Loading/index.ts +35 -0
  25. package/lib/Easy-Hud/Toast/Toast.tsx +86 -0
  26. package/lib/Easy-Hud/Toast/index.ts +22 -0
  27. package/lib/Easy-Hud/index.ts +18 -0
  28. package/lib/Echarts/EchartsView.tsx +151 -0
  29. package/lib/Echarts/demo.tsx +235 -0
  30. package/lib/Echarts/helper.tsx +63 -0
  31. package/lib/Echarts/index.ts +29 -0
  32. package/lib/Modal/Modal.tsx +12 -0
  33. package/lib/Modal/index.ts +10 -0
  34. package/lib/MutiPictureView/MutiPictureView.tsx +213 -0
  35. package/lib/MutiPictureView/icon_add_image.png +0 -0
  36. package/lib/MutiPictureView/icon_del_image.png +0 -0
  37. package/lib/MutiPictureView/index.ts +55 -0
  38. package/lib/PictureViewer/PictureViewer.tsx +80 -0
  39. package/lib/PictureViewer/index.ts +26 -0
  40. package/lib/RefreshList/RefreshList.tsx +222 -0
  41. package/lib/RefreshList/demo.tsx +30 -0
  42. package/lib/RefreshList/demo1.tsx +60 -0
  43. package/lib/RefreshList/demo2.tsx +46 -0
  44. package/lib/RefreshList/index.ts +84 -0
  45. package/lib/StickHeaderView/StickHeaderView.tsx +65 -0
  46. package/lib/StickHeaderView/demo.tsx +104 -0
  47. package/lib/StickHeaderView/index.ts +26 -0
  48. package/lib/TableCell/TableCell.tsx +117 -0
  49. package/lib/TableCell/back.png +0 -0
  50. package/lib/TableCell/index.ts +45 -0
  51. package/lib/TextInputArea/TextInputArea.tsx +88 -0
  52. package/lib/TextInputArea/index.ts +32 -0
  53. package/lib/WithLoadingContainer/WithLoadingContainer.tsx +93 -0
  54. package/lib/WithLoadingContainer/index.ts +36 -0
  55. package/lib/WithLoadingContainer/loading.gif +0 -0
  56. package/lib/WithLoadingContainer/loading3.gif +0 -0
  57. package/package.json +59 -0
  58. package/screen/index.ts +16 -0
  59. package/screen/px2dp.tsx +44 -0
  60. package/screen/px2sp.tsx +65 -0
  61. package/screen/text-set.tsx +58 -0
  62. package/src/index.d.ts +58 -0
  63. package/src/index.ts +66 -0
  64. package/utils/index.ts +56 -0
  65. package/utils/lazy.tsx +40 -0
  66. package/utils/mode.tsx +48 -0
@@ -0,0 +1,151 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-05 14:52:53
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-05-10 18:10:15
6
+ * @FilePath: /@aks/easyui/lib/Echarts/EchartsView.tsx
7
+ */
8
+ import * as React from 'react'
9
+ import { MeasureOnSuccessCallback, StyleSheet, View, ViewStyle } from 'react-native'
10
+ import { WebView } from 'react-native-webview'
11
+ import { EchartsViewProps } from '.'
12
+ import { getHtml, toString } from './helper'
13
+
14
+ type State = {
15
+ width: number;
16
+ height: number;
17
+ isLoaded: boolean;
18
+ }
19
+
20
+
21
+ type Reducer = (prevState: State, action: Partial<State>) => State
22
+
23
+
24
+ const EchartsView: React.FC<EchartsViewProps> = (props) => {
25
+ const [state, dispatch] = React.useReducer<Reducer>(
26
+ (prevState, action) => Object.assign({}, prevState, action),
27
+ {
28
+ width: 0,
29
+ height: 0,
30
+ isLoaded: false
31
+ }
32
+ )
33
+ const WebViewRef: React.MutableRefObject<{ injectJavaScript: Function }> = React.useRef() as any
34
+ const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
35
+
36
+ React.useEffect(() => {
37
+ containerRef.current?.measure((...args) => {
38
+ dispatch({
39
+ width: args[2],
40
+ height: args[3]
41
+ })
42
+ })
43
+
44
+ }, [props.style])
45
+
46
+
47
+
48
+
49
+
50
+
51
+ React.useEffect(() => {
52
+ if (state.isLoaded) {
53
+ const run = `
54
+ ;(function() {
55
+ var myChart = echarts.init(document.getElementById('main'));
56
+ myChart.setOption(${toString(props.option)});
57
+ })();
58
+ `
59
+ WebViewRef.current?.injectJavaScript(run);
60
+
61
+ return () => {
62
+ const run = `
63
+ ;(function() {
64
+ var myChart = echarts.init(document.getElementById('main'));
65
+ myChart.clear();
66
+ })();
67
+ `
68
+ WebViewRef.current?.injectJavaScript(run);
69
+ }
70
+ }
71
+
72
+ return undefined
73
+
74
+ }, [props.option, state.isLoaded])
75
+
76
+
77
+
78
+
79
+ const injectedJavaScript = (): string => {
80
+ let height = state.height ? `${state.height}px` : 'auto'
81
+ let width = state.width ? `${state.width}px` : 'auto'
82
+ return `
83
+ ;(function() {
84
+ document.getElementById('main').style.height = "${height}";
85
+ document.getElementById('main').style.width = "${width}";
86
+ var myChart = echarts.init(document.getElementById('main'));
87
+ myChart.setOption(${toString(props.option)});
88
+ myChart.on('click', function(params) {
89
+ var seen = [];
90
+ var paramsString = JSON.stringify(params, function(key, val) {
91
+ if (val != null && typeof val == "object") {
92
+ if (seen.indexOf(val) >= 0) {
93
+ return;
94
+ }
95
+ seen.push(val);
96
+ }
97
+ return val;
98
+ });
99
+ window.ReactNativeWebView.postMessage(JSON.stringify({"types":"ON_PRESS","payload": paramsString}));
100
+ });
101
+ })();
102
+ `
103
+ }
104
+
105
+
106
+
107
+ return (
108
+ <View style={[styles.container, props.style]} ref={containerRef as any}>
109
+ <WebView
110
+ ref={WebViewRef as any}
111
+ originWhitelist={['*']}
112
+ useWebKit={true} // ios使用最新webkit内核渲染
113
+ allowUniversalAccessFromFileURLs={true}
114
+ geolocationEnabled={true}
115
+ mixedContentMode={'always'}
116
+ renderLoading={() => {
117
+ if (props.renderLoading) return props.renderLoading()
118
+ return <View style={{ backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent' }} />
119
+ }} // 设置空View,修复ioswebview闪白
120
+ style={{ backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent' }} // 设置背景色透明,修复android闪白
121
+ scrollEnabled={false}
122
+ // onMessage={onMessage}
123
+ javaScriptEnabled={true}
124
+ injectedJavaScript={injectedJavaScript()}
125
+ startInLoadingState={false}
126
+ onLoadEnd={(_) => {
127
+ dispatch({ isLoaded: true })
128
+ }}
129
+ source={{
130
+ baseUrl: '',
131
+ html: getHtml({ backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent' })
132
+ }}
133
+ />
134
+ </View>
135
+ )
136
+
137
+ }
138
+
139
+ const styles = StyleSheet.create({
140
+ container: {
141
+ display: 'flex',
142
+ flexGrow: 0,
143
+ backgroundColor: 'white'
144
+ }
145
+ })
146
+
147
+
148
+
149
+
150
+
151
+ export default React.memo(EchartsView)
@@ -0,0 +1,235 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-06 12:05:42
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-05-06 12:07:58
6
+ * @FilePath: /@aks/easyui/lib/Echarts/demo.tsx
7
+ */
8
+
9
+
10
+
11
+ import * as React from 'react'
12
+ import { View, StyleSheet, } from 'react-native';
13
+
14
+ import EchartsView from './EchartsView'
15
+ import {echarts} from '.'
16
+
17
+
18
+
19
+ export default () => {
20
+
21
+
22
+
23
+ let option = {
24
+ color: ['#80FFA5', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'],
25
+ title: {
26
+ text: 'Gradient Stacked Area Chart'
27
+ },
28
+ tooltip: {
29
+ trigger: 'axis',
30
+ axisPointer: {
31
+ type: 'cross',
32
+ label: {
33
+ backgroundColor: '#6a7985'
34
+ }
35
+ }
36
+ },
37
+ legend: {
38
+ data: ['Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5']
39
+ },
40
+ toolbox: {
41
+ feature: {
42
+ saveAsImage: {}
43
+ }
44
+ },
45
+ grid: {
46
+ left: '3%',
47
+ right: '4%',
48
+ bottom: '3%',
49
+ containLabel: true
50
+ },
51
+ xAxis: [
52
+ {
53
+ type: 'category',
54
+ boundaryGap: false,
55
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
56
+ }
57
+ ],
58
+ yAxis: [
59
+ {
60
+ type: 'value'
61
+ }
62
+ ],
63
+ series: [
64
+ {
65
+ name: 'Line 1',
66
+ type: 'line',
67
+ stack: 'Total',
68
+ smooth: true,
69
+ lineStyle: {
70
+ width: 0
71
+ },
72
+ showSymbol: false,
73
+ areaStyle: {
74
+ opacity: 0.8,
75
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
76
+ {
77
+ offset: 0,
78
+ color: 'rgb(128, 255, 165)'
79
+ },
80
+ {
81
+ offset: 1,
82
+ color: 'rgb(1, 191, 236)'
83
+ }
84
+ ])
85
+ },
86
+ emphasis: {
87
+ focus: 'series'
88
+ },
89
+ data: [140, 232, 101, 264, 90, 340, 250]
90
+ },
91
+ {
92
+ name: 'Line 2',
93
+ type: 'line',
94
+ stack: 'Total',
95
+ smooth: true,
96
+ lineStyle: {
97
+ width: 0
98
+ },
99
+ showSymbol: false,
100
+ areaStyle: {
101
+ opacity: 0.8,
102
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
103
+ {
104
+ offset: 0,
105
+ color: 'rgb(0, 221, 255)'
106
+ },
107
+ {
108
+ offset: 1,
109
+ color: 'rgb(77, 119, 255)'
110
+ }
111
+ ])
112
+ },
113
+ emphasis: {
114
+ focus: 'series'
115
+ },
116
+ data: [120, 282, 111, 234, 220, 340, 310]
117
+ },
118
+ {
119
+ name: 'Line 3',
120
+ type: 'line',
121
+ stack: 'Total',
122
+ smooth: true,
123
+ lineStyle: {
124
+ width: 0
125
+ },
126
+ showSymbol: false,
127
+ areaStyle: {
128
+ opacity: 0.8,
129
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
130
+ {
131
+ offset: 0,
132
+ color: 'rgb(55, 162, 255)'
133
+ },
134
+ {
135
+ offset: 1,
136
+ color: 'rgb(116, 21, 219)'
137
+ }
138
+ ])
139
+ },
140
+ emphasis: {
141
+ focus: 'series'
142
+ },
143
+ data: [320, 132, 201, 334, 190, 130, 220]
144
+ },
145
+ {
146
+ name: 'Line 4',
147
+ type: 'line',
148
+ stack: 'Total',
149
+ smooth: true,
150
+ lineStyle: {
151
+ width: 0
152
+ },
153
+ showSymbol: false,
154
+ areaStyle: {
155
+ opacity: 0.8,
156
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
157
+ {
158
+ offset: 0,
159
+ color: 'rgb(255, 0, 135)'
160
+ },
161
+ {
162
+ offset: 1,
163
+ color: 'rgb(135, 0, 157)'
164
+ }
165
+ ])
166
+ },
167
+ emphasis: {
168
+ focus: 'series'
169
+ },
170
+ data: [220, 402, 231, 134, 190, 230, 120]
171
+ },
172
+ {
173
+ name: 'Line 5',
174
+ type: 'line',
175
+ stack: 'Total',
176
+ smooth: true,
177
+ lineStyle: {
178
+ width: 0
179
+ },
180
+ showSymbol: false,
181
+ label: {
182
+ show: true,
183
+ position: 'top'
184
+ },
185
+ areaStyle: {
186
+ opacity: 0.8,
187
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
188
+ {
189
+ offset: 0,
190
+ color: 'rgb(255, 191, 0)'
191
+ },
192
+ {
193
+ offset: 1,
194
+ color: 'rgb(224, 62, 76)'
195
+ }
196
+ ])
197
+ },
198
+ emphasis: {
199
+ focus: 'series'
200
+ },
201
+ data: [220, 302, 181, 234, 210, 290, 150]
202
+ }
203
+ ]
204
+ };
205
+
206
+
207
+
208
+
209
+
210
+ return (
211
+ <View style={styles.container}>
212
+
213
+ <View style={{ width: 100, height: 100, backgroundColor: 'pink' }} />
214
+ <EchartsView
215
+ option={option}
216
+ style={{
217
+ marginTop: 100,
218
+ marginHorizontal: 20,
219
+ height: 200,
220
+ // backgroundColor: 'red'
221
+ }}
222
+ />
223
+
224
+ </View>
225
+ )
226
+ }
227
+
228
+
229
+ const styles = StyleSheet.create({
230
+ container: {
231
+ flexGrow: 1,
232
+ display: 'flex',
233
+ },
234
+
235
+ })
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-05 15:56:21
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-05-06 11:40:51
6
+ * @FilePath: /@aks/easyui/lib/Echarts/helper.tsx
7
+ */
8
+
9
+
10
+ export const getHtml = (props: { backgroundColor: any }) => {
11
+ return `
12
+ <!DOCTYPE html>
13
+ <html>
14
+
15
+ <head>
16
+ <title>echarts</title>
17
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
18
+ <!-- webView ios适配 start -->
19
+ <meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
20
+ <!-- webView ios适配 end -->
21
+ <style type="text/css">
22
+ html,
23
+ body {
24
+ height: 100%;
25
+ width: 100%;
26
+ margin: 0;
27
+ padding: 0;
28
+ background-color: rgba(0, 0, 0, 0);
29
+ }
30
+
31
+ #main {
32
+ height: 100%;
33
+ background-color: rgba(0, 0, 0, 0);
34
+ }
35
+
36
+ </style>
37
+ <script type="text/javascript" src="https://cdn.bootcss.com/echarts/5.0.2/echarts.min.js"></script>
38
+ </head>
39
+
40
+ <body style="background-color:${props.backgroundColor}">
41
+ <div id="main"></div>
42
+ </body>
43
+
44
+ </html>
45
+ `
46
+ }
47
+
48
+ export const toString = (obj: object) => {
49
+ let result = JSON.stringify(obj, function (key, val) {
50
+ // 对function进行特殊处理
51
+ if (typeof val === 'function') {
52
+ return `~ha~${val}~ha~`;
53
+ }
54
+ return val;
55
+ });
56
+ // 再进行还原
57
+ do {
58
+ result = result.replace('\"~ha~', '').replace('~ha~\"', '').replace(/\\n/g, '').replace(/\\\"/g, "\"");//最后一个replace将release模式中莫名生成的\"转换成"
59
+ } while (result.indexOf('~ha~') >= 0);
60
+
61
+ return result;
62
+ }
63
+
@@ -0,0 +1,29 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-05 14:52:22
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-05-06 10:10:43
6
+ * @FilePath: /@aks/easyui/lib/Echarts/index.ts
7
+ */
8
+
9
+ import * as React from 'react'
10
+ import { StyleProp, ViewStyle } from 'react-native'
11
+
12
+ export type EchartsViewProps = {
13
+ option: any;
14
+ style?: StyleProp<ViewStyle>;
15
+ renderLoading?: () => React.ReactElement;
16
+ }
17
+
18
+
19
+
20
+ export declare const EchartsView: React.FC<EchartsViewProps>;
21
+
22
+
23
+
24
+ import * as echarts from 'echarts/core'
25
+
26
+
27
+ export {
28
+ echarts
29
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-26 11:30:34
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-04-26 14:34:52
6
+ * @FilePath: /@aks/easy/lib/Modal/Modal.tsx
7
+ */
8
+
9
+
10
+
11
+
12
+ export { default as Modal, ModalProps } from 'react-native-modal'
@@ -0,0 +1,10 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-22 14:29:32
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-04-26 14:34:45
6
+ * @FilePath: /@aks/easy/lib/Modal/index.ts
7
+ */
8
+
9
+
10
+ export { default as Modal, ModalProps } from 'react-native-modal'