@aks-dev/easyui 1.0.163 → 1.1.2

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 (173) hide show
  1. package/dist/components/AnimationModal/AnimationModal.js +151 -0
  2. package/dist/components/DottedLine/DottedLine.js +50 -0
  3. package/{lib/Echarts/EchartsView.tsx → dist/components/EchartsView/EchartsView.js} +74 -113
  4. package/{lib/Echarts/helper.tsx → dist/components/EchartsView/helper.js} +17 -24
  5. package/dist/components/Hud/AlertBottomView/AlertBottomView.js +174 -0
  6. package/dist/components/Hud/AlertSheetView/AlertSheetView.js +117 -0
  7. package/dist/components/Hud/AlertView/AlertView.js +184 -0
  8. package/dist/components/Hud/Hud.js +29 -0
  9. package/dist/components/Hud/Loading/Loading.js +66 -0
  10. package/dist/components/Hud/PopoverView/PopoverView.js +47 -0
  11. package/dist/components/Hud/Scanner/Scanner.js +301 -0
  12. package/dist/components/Hud/Toast/Toast.js +71 -0
  13. package/dist/components/MenuView/MenuView.js +184 -0
  14. package/{lib/Modal/Modal.tsx → dist/components/Modal/Modal.js} +1 -4
  15. package/dist/components/MutiPictureView/MutiPictureView.js +239 -0
  16. package/dist/components/PictureViewer/PictureViewer.js +54 -0
  17. package/dist/components/RefreshList/RefreshList.js +155 -0
  18. package/dist/components/RichText/RichText.js +56 -0
  19. package/dist/components/StickHeaderView/StickHeaderView.js +37 -0
  20. package/dist/components/TableCell/TableCell.js +97 -0
  21. package/dist/components/TextInputArea/TextInputArea.js +65 -0
  22. package/dist/components/WithLoadingContainer/WithLoadingContainer.js +77 -0
  23. package/dist/index.js +31 -0
  24. package/dist/jsbridge/RNEasyui.js +46 -0
  25. package/{jsbridge/UpgradeModule.ts → dist/jsbridge/UpgradeModule.js} +25 -23
  26. package/{jsbridge/index.ts → dist/jsbridge/index.js} +2 -2
  27. package/{screen/index.ts → dist/screen/index.js} +2 -2
  28. package/dist/screen/px2dp.js +45 -0
  29. package/{screen/px2sp.ts → dist/screen/px2sp.js} +13 -20
  30. package/{screen/text-fit.ts → dist/screen/text-fit.js} +10 -20
  31. package/{utils/index.ts → dist/utils/index.js} +2 -2
  32. package/{utils/lazy.ts → dist/utils/lazy.js} +164 -165
  33. package/dist/utils/mode.js +50 -0
  34. package/package.json +31 -19
  35. package/readme.md +3 -3
  36. package/types/components/AnimationModal/AnimationModal.d.ts +27 -0
  37. package/types/components/AnimationModal/AnimationModal.d.ts.map +1 -0
  38. package/types/components/DottedLine/DottedLine.d.ts +10 -0
  39. package/types/components/DottedLine/DottedLine.d.ts.map +1 -0
  40. package/types/components/EchartsView/EchartsView.d.ts +10 -0
  41. package/types/components/EchartsView/EchartsView.d.ts.map +1 -0
  42. package/types/components/EchartsView/helper.d.ts +10 -0
  43. package/types/components/EchartsView/helper.d.ts.map +1 -0
  44. package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts +25 -0
  45. package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts.map +1 -0
  46. package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts +19 -0
  47. package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts.map +1 -0
  48. package/types/components/Hud/AlertView/AlertView.d.ts +25 -0
  49. package/types/components/Hud/AlertView/AlertView.d.ts.map +1 -0
  50. package/types/components/Hud/Hud.d.ts +11 -0
  51. package/types/components/Hud/Hud.d.ts.map +1 -0
  52. package/types/components/Hud/Loading/Loading.d.ts +11 -0
  53. package/types/components/Hud/Loading/Loading.d.ts.map +1 -0
  54. package/types/components/Hud/PopoverView/PopoverView.d.ts +17 -0
  55. package/types/components/Hud/PopoverView/PopoverView.d.ts.map +1 -0
  56. package/types/components/Hud/Scanner/Scanner.d.ts +12 -0
  57. package/types/components/Hud/Scanner/Scanner.d.ts.map +1 -0
  58. package/types/components/Hud/Toast/Toast.d.ts +9 -0
  59. package/types/components/Hud/Toast/Toast.d.ts.map +1 -0
  60. package/types/components/MenuView/MenuView.d.ts +21 -0
  61. package/types/components/MenuView/MenuView.d.ts.map +1 -0
  62. package/types/components/Modal/Modal.d.ts +2 -0
  63. package/types/components/Modal/Modal.d.ts.map +1 -0
  64. package/{lib/MutiPictureView/index.ts → types/components/MutiPictureView/MutiPictureView.d.ts} +18 -31
  65. package/types/components/MutiPictureView/MutiPictureView.d.ts.map +1 -0
  66. package/types/components/PictureViewer/PictureViewer.d.ts +17 -0
  67. package/types/components/PictureViewer/PictureViewer.d.ts.map +1 -0
  68. package/types/components/RefreshList/RefreshList.d.ts +45 -0
  69. package/types/components/RefreshList/RefreshList.d.ts.map +1 -0
  70. package/types/components/RichText/RichText.d.ts +12 -0
  71. package/types/components/RichText/RichText.d.ts.map +1 -0
  72. package/types/components/StickHeaderView/StickHeaderView.d.ts +15 -0
  73. package/types/components/StickHeaderView/StickHeaderView.d.ts.map +1 -0
  74. package/{lib/TableCell/index.ts → types/components/TableCell/TableCell.d.ts} +8 -30
  75. package/types/components/TableCell/TableCell.d.ts.map +1 -0
  76. package/types/components/TextInputArea/TextInputArea.d.ts +17 -0
  77. package/types/components/TextInputArea/TextInputArea.d.ts.map +1 -0
  78. package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts +23 -0
  79. package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts.map +1 -0
  80. package/types/index.d.ts +22 -0
  81. package/types/index.d.ts.map +1 -0
  82. package/types/jsbridge/RNEasyui.d.ts +23 -0
  83. package/types/jsbridge/RNEasyui.d.ts.map +1 -0
  84. package/types/jsbridge/UpgradeModule.d.ts +26 -0
  85. package/types/jsbridge/UpgradeModule.d.ts.map +1 -0
  86. package/types/jsbridge/index.d.ts +3 -0
  87. package/types/jsbridge/index.d.ts.map +1 -0
  88. package/types/screen/index.d.ts +3 -0
  89. package/types/screen/index.d.ts.map +1 -0
  90. package/{screen/index.d.ts → types/screen/px2dp.d.ts} +6 -12
  91. package/types/screen/px2dp.d.ts.map +1 -0
  92. package/types/screen/px2sp.d.ts +2 -0
  93. package/types/screen/px2sp.d.ts.map +1 -0
  94. package/types/screen/text-fit.d.ts +5 -0
  95. package/types/screen/text-fit.d.ts.map +1 -0
  96. package/types/utils/index.d.ts +3 -0
  97. package/types/utils/index.d.ts.map +1 -0
  98. package/{utils/index.d.ts → types/utils/lazy.d.ts} +15 -53
  99. package/types/utils/lazy.d.ts.map +1 -0
  100. package/types/utils/mode.d.ts +24 -0
  101. package/types/utils/mode.d.ts.map +1 -0
  102. package/android/.DS_Store +0 -0
  103. package/android/src/.DS_Store +0 -0
  104. package/android/src/main/.DS_Store +0 -0
  105. package/android/src/main/java/.DS_Store +0 -0
  106. package/android/src/main/java/com/.DS_Store +0 -0
  107. package/android/src/main/java/com/easyui/.DS_Store +0 -0
  108. package/i.sh +0 -23
  109. package/ios/.DS_Store +0 -0
  110. package/ios/assets/.DS_Store +0 -0
  111. package/ios/views/.DS_Store +0 -0
  112. package/jsbridge/RNEasyui.ts +0 -42
  113. package/jsbridge/index.d.ts +0 -67
  114. package/lib/.DS_Store +0 -0
  115. package/lib/AnimationModal/AnimationModal.tsx +0 -201
  116. package/lib/AnimationModal/index.d.ts +0 -41
  117. package/lib/Badge/Badge.tsx +0 -40
  118. package/lib/Badge/index.ts +0 -21
  119. package/lib/DottedLine/DottedLine.tsx +0 -66
  120. package/lib/DottedLine/index.ts +0 -18
  121. package/lib/Echarts/demo.tsx +0 -235
  122. package/lib/Echarts/index.ts +0 -29
  123. package/lib/Hud/.DS_Store +0 -0
  124. package/lib/Hud/AlertBottomView/AlertBottomView.tsx +0 -228
  125. package/lib/Hud/AlertBottomView/index.d.ts +0 -42
  126. package/lib/Hud/AlertSheetView/AlertSheetView.tsx +0 -179
  127. package/lib/Hud/AlertSheetView/index.d.ts +0 -35
  128. package/lib/Hud/AlertView/AlertView.tsx +0 -234
  129. package/lib/Hud/AlertView/index.d.ts +0 -46
  130. package/lib/Hud/Hud.tsx +0 -67
  131. package/lib/Hud/Loading/Loading.tsx +0 -87
  132. package/lib/Hud/Loading/index.d.ts +0 -38
  133. package/lib/Hud/PopoverView/PopoverView.tsx +0 -66
  134. package/lib/Hud/PopoverView/index.d.ts +0 -39
  135. package/lib/Hud/Scanner/Scanner.tsx +0 -250
  136. package/lib/Hud/Scanner/index.d.ts +0 -42
  137. package/lib/Hud/Toast/Toast.tsx +0 -86
  138. package/lib/Hud/Toast/index.d.ts +0 -22
  139. package/lib/Hud/index.ts +0 -20
  140. package/lib/MenuView/MenuView.tsx +0 -252
  141. package/lib/MenuView/index.ts +0 -31
  142. package/lib/Modal/index.ts +0 -10
  143. package/lib/MutiPictureView/MutiPictureView.tsx +0 -259
  144. package/lib/PictureViewer/PictureViewer.tsx +0 -80
  145. package/lib/PictureViewer/index.ts +0 -26
  146. package/lib/RefreshList/RefreshList.tsx +0 -235
  147. package/lib/RefreshList/demo.tsx +0 -30
  148. package/lib/RefreshList/demo1.tsx +0 -60
  149. package/lib/RefreshList/demo2.tsx +0 -46
  150. package/lib/RefreshList/index.ts +0 -84
  151. package/lib/RichText/RichText.tsx +0 -82
  152. package/lib/RichText/index.ts +0 -21
  153. package/lib/StickHeaderView/StickHeaderView.tsx +0 -65
  154. package/lib/StickHeaderView/demo.tsx +0 -104
  155. package/lib/StickHeaderView/index.ts +0 -26
  156. package/lib/TableCell/TableCell.tsx +0 -118
  157. package/lib/TextInputArea/TextInputArea.tsx +0 -89
  158. package/lib/TextInputArea/index.d.ts +0 -33
  159. package/lib/WithLoadingContainer/WithLoadingContainer.tsx +0 -93
  160. package/lib/WithLoadingContainer/index.ts +0 -36
  161. package/screen/px2dp.ts +0 -51
  162. package/src/index.d.ts +0 -42
  163. package/src/index.ts +0 -54
  164. package/utils/mode.ts +0 -48
  165. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-blue.png +0 -0
  166. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-white.png +0 -0
  167. /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/icon_back_white.png +0 -0
  168. /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_add_image.png +0 -0
  169. /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_del_image.png +0 -0
  170. /package/{lib/TableCell → dist/components/TableCell/assets}/back.png +0 -0
  171. /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading.gif +0 -0
  172. /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading3.gif +0 -0
  173. /package/{lib → dist/components}/index.md +0 -0
@@ -0,0 +1,151 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-17 15:22:06
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2023-09-27 15:17:15
6
+ * @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
7
+ */
8
+ import * as React from "react";
9
+ import { View, Animated, Easing, PanResponder, StyleSheet, useWindowDimensions, BackHandler, } from "react-native";
10
+ import * as utils from "../../utils/lazy";
11
+ // type State = {
12
+ // display: 'flex' | 'none';
13
+ // }
14
+ // type StateReducerProps = (state: State, action: Partial<State>) => State
15
+ export const AnimationModal = React.forwardRef((props, ref) => {
16
+ const { animationType = "from-bottom", mask = false } = props || {};
17
+ const { height } = useWindowDimensions();
18
+ // const [state, dispatch] = React.useReducer<StateReducerProps>(
19
+ // (state, action) => ({ ...state, ...action }),
20
+ // {
21
+ // display: 'none'
22
+ // })
23
+ const [display, setDisplay] = useCallbackState("none");
24
+ const animatedValue = React.useRef(new Animated.Value(0)).current;
25
+ const timing = (value) => {
26
+ Animated.timing(animatedValue, {
27
+ toValue: value,
28
+ duration: 350,
29
+ useNativeDriver: true,
30
+ easing: Easing.ease,
31
+ }).start(({ finished }) => {
32
+ /* 动画完成的回调函数 */
33
+ });
34
+ };
35
+ const viewRef = React.useRef(null);
36
+ const layoutRef = React.useRef({ h0: 0, h1: 0 });
37
+ const getLayoutPromise = () => {
38
+ return new Promise((resovle, reject) => {
39
+ viewRef.current?.measure((...args) => {
40
+ if (args.length == 6) {
41
+ layoutRef.current.h1 = args[3];
42
+ }
43
+ resovle(args);
44
+ });
45
+ });
46
+ };
47
+ const init = React.useCallback(() => ({ show, hide, setData, getData }), []);
48
+ React.useImperativeHandle(ref, init, []);
49
+ const dataRef = React.useRef(null);
50
+ const setData = (data) => {
51
+ dataRef.current = data;
52
+ return init();
53
+ };
54
+ const getData = () => dataRef.current;
55
+ const show = () => {
56
+ setDisplay("flex", async () => {
57
+ await utils.sleep(50);
58
+ await getLayoutPromise();
59
+ timing(-layoutRef.current?.h1);
60
+ });
61
+ return init();
62
+ };
63
+ const hide = () => {
64
+ timing(0);
65
+ setTimeout(() => {
66
+ setDisplay("none");
67
+ }, 300);
68
+ return init();
69
+ };
70
+ React.useEffect(() => {
71
+ let addEventListener = BackHandler.addEventListener("hardwareBackPress", () => {
72
+ return display == "flex";
73
+ });
74
+ return () => {
75
+ addEventListener.remove();
76
+ };
77
+ }, [display]);
78
+ return (<View style={Object.assign({
79
+ display: display,
80
+ }, styles.container, props.style)} {...PanResponder.create({
81
+ onStartShouldSetPanResponder: (e, gestureState) => {
82
+ let pageY = e.nativeEvent.pageY;
83
+ let topY = height - layoutRef.current.h1;
84
+ if (pageY <= topY && !mask) {
85
+ return true;
86
+ }
87
+ return false;
88
+ },
89
+ onPanResponderGrant: (e, gestureState) => {
90
+ // console.log({e})
91
+ let pageY = e.nativeEvent.pageY;
92
+ let topY = height - layoutRef.current.h1;
93
+ if (pageY <= topY && !mask) {
94
+ e.stopPropagation();
95
+ hide();
96
+ }
97
+ },
98
+ }).panHandlers}>
99
+ <Animated.View style={Object.assign({}, styles.wrapper, {
100
+ transform: [{ translateY: animatedValue }],
101
+ })}
102
+ // onLayout={e => {
103
+ // let target: LayoutRectangle = e.nativeEvent.layout
104
+ // layoutRef.current.h1 = target.height
105
+ // }}
106
+ ref={viewRef}>
107
+ {props.children}
108
+ </Animated.View>
109
+ </View>);
110
+ });
111
+ const styles = StyleSheet.create({
112
+ container: {
113
+ position: "absolute",
114
+ left: 0,
115
+ right: 0,
116
+ top: 0,
117
+ bottom: 0,
118
+ zIndex: 999,
119
+ // display: 'flex',
120
+ flexDirection: "column",
121
+ backgroundColor: "#00000055",
122
+ overflow: "hidden",
123
+ },
124
+ wrapper: {
125
+ position: "absolute",
126
+ display: "flex",
127
+ flexDirection: "column",
128
+ // backgroundColor: 'pink',
129
+ width: "100%",
130
+ top: "100%",
131
+ },
132
+ empty: {
133
+ flex: 1,
134
+ position: "relative",
135
+ // backgroundColor: 'cyan'
136
+ },
137
+ });
138
+ const useCallbackState = (od) => {
139
+ const cbRef = React.useRef(undefined);
140
+ const [data, setData] = React.useState(od);
141
+ React.useEffect(() => {
142
+ cbRef.current && cbRef.current(data);
143
+ }, [data]);
144
+ return [
145
+ data,
146
+ (d, callback) => {
147
+ cbRef.current = callback;
148
+ setData(d);
149
+ },
150
+ ];
151
+ };
@@ -0,0 +1,50 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-07-12 15:30:19
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-07-12 15:33:06
6
+ * @FilePath: /@aks-dev/easyui/lib/DottedLine/DottedLine.tsx
7
+ */
8
+ import React from "react";
9
+ import { StyleSheet, View } from "react-native";
10
+ export default (props) => {
11
+ const { vertical = false, dottedColor, dottedCount = 200, ...rest } = props;
12
+ const arrs = Array.from({ length: dottedCount }, (k, v) => v);
13
+ return (<View style={{
14
+ ...styles.container,
15
+ flexDirection: vertical ? "column" : "row",
16
+ ...rest.style,
17
+ }}>
18
+ {arrs.map((item, index) => {
19
+ return (<View key={`dotted-${index}`} style={{
20
+ ...(vertical ? styles.dotted_vertical : styles.dotted_horizontal),
21
+ ...(dottedColor && { backgroundColor: dottedColor }),
22
+ }}/>);
23
+ })}
24
+ </View>);
25
+ };
26
+ const styles = StyleSheet.create({
27
+ container: {
28
+ display: "flex",
29
+ flexGrow: 1,
30
+ overflow: "hidden",
31
+ flexDirection: "row",
32
+ flexWrap: "nowrap",
33
+ },
34
+ dotted_horizontal: {
35
+ flexGrow: 0,
36
+ flexShrink: 0,
37
+ width: 2,
38
+ height: 1,
39
+ marginRight: 2,
40
+ backgroundColor: "#cccccc",
41
+ },
42
+ dotted_vertical: {
43
+ flexGrow: 0,
44
+ flexShrink: 0,
45
+ width: 1,
46
+ height: 2,
47
+ marginBottom: 2,
48
+ backgroundColor: "#cccccc",
49
+ },
50
+ });
@@ -5,39 +5,20 @@
5
5
  * @LastEditTime: 2023-01-03 17:50:43
6
6
  * @FilePath: /@aks-dev/easyui/lib/Echarts/EchartsView.tsx
7
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
- const rootView = React.useRef<{
36
- pageX: number;
37
- pageY: number;
38
- height: number;
39
- width: number;
40
- }>({ pageX: 0, pageY: 0, width: 0, height: 0 })
8
+ import * as React from "react";
9
+ import { StyleSheet, View, } from "react-native";
10
+ import { WebView } from "react-native-webview";
11
+ import { getHtml, toString } from "./helper";
12
+ // type Reducer = (prevState: State, action: Partial<State>) => State;
13
+ const EchartsView = (props) => {
14
+ const [state, dispatch] = React.useReducer((prevState, ...args) => Object.assign({}, prevState, ...args), {
15
+ width: 0,
16
+ height: 0,
17
+ isLoaded: false,
18
+ });
19
+ const WebViewRef = React.useRef(null);
20
+ const containerRef = React.useRef(null);
21
+ const rootView = React.useRef({ pageX: 0, pageY: 0, width: 0, height: 0 });
41
22
  const getRootViewlayoutPromise = () => {
42
23
  return new Promise((resovle, reject) => {
43
24
  containerRef.current?.measure((...args) => {
@@ -47,21 +28,23 @@ const EchartsView: React.FC<EchartsViewProps> = (props) => {
47
28
  height: args[3],
48
29
  pageX: args[4],
49
30
  pageY: args[5],
50
- }
31
+ };
51
32
  }
52
33
  // console.log('RootView', rootView.current)
53
- resovle(args)
54
- })
55
- })
56
- }
57
-
58
-
34
+ resovle(args);
35
+ });
36
+ });
37
+ };
59
38
  React.useLayoutEffect(() => {
60
- ; (async () => {
39
+ (async () => {
61
40
  if (state.isLoaded) {
62
- await getRootViewlayoutPromise()
63
- let height = rootView.current.height ? `${rootView.current.height}px` : 'auto'
64
- let width = rootView.current.width ? `${rootView.current.width}px` : 'auto'
41
+ await getRootViewlayoutPromise();
42
+ let height = rootView.current.height
43
+ ? `${rootView.current.height}px`
44
+ : "auto";
45
+ let width = rootView.current.width
46
+ ? `${rootView.current.width}px`
47
+ : "auto";
65
48
  const run = `
66
49
  ;(function() {
67
50
  var instance = echarts.getInstanceByDom(document.getElementById('main'));
@@ -73,9 +56,8 @@ const EchartsView: React.FC<EchartsViewProps> = (props) => {
73
56
  instance.clear();
74
57
  instance.setOption(${toString(props.option)});
75
58
  })();
76
- `
59
+ `;
77
60
  WebViewRef.current?.injectJavaScript(run);
78
-
79
61
  return () => {
80
62
  const run = `
81
63
  ;(function() {
@@ -85,21 +67,15 @@ const EchartsView: React.FC<EchartsViewProps> = (props) => {
85
67
  instance.dispose();
86
68
  }
87
69
  })();
88
- `
89
-
70
+ `;
90
71
  WebViewRef.current?.injectJavaScript(run);
91
- }
72
+ };
92
73
  }
93
- return undefined
94
- })().catch(err => {
95
- console.log(err)
96
- })
97
-
98
-
99
- }, [props.option, state.isLoaded])
100
-
101
-
102
-
74
+ return undefined;
75
+ })().catch((err) => {
76
+ console.log(err);
77
+ });
78
+ }, [props.option, state.isLoaded]);
103
79
  // const injectedJavaScript = (): string => {
104
80
  // console.log('injectedJavaScript', props.option.xAxis.data)
105
81
  // let height = state.height ? `${state.height}px` : 'auto'
@@ -130,61 +106,46 @@ const EchartsView: React.FC<EchartsViewProps> = (props) => {
130
106
  // })();
131
107
  // `
132
108
  // }
133
-
134
-
135
-
136
- return (
137
- <View style={[styles.container, props.style]} ref={containerRef as any}>
138
- <WebView
139
- ref={WebViewRef as any}
140
- originWhitelist={['*']}
141
- useWebKit={true} // ios使用最新webkit内核渲染
142
- allowUniversalAccessFromFileURLs={true}
143
- geolocationEnabled={true}
144
- mixedContentMode={'always'}
145
- renderLoading={() => {
146
- if (props.renderLoading) return props.renderLoading()
147
- return <View style={{ backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent' }} />
148
- }} // 设置空View,修复ioswebview闪白
149
- style={{
150
- backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent',
151
- opacity: 0.99,//解决闪退的办法
152
- }} // 设置背景色透明,修复android闪白
153
- scrollEnabled={false}
154
- // onMessage={e=>{
155
- // console.log(e)
156
- // }}
157
- javaScriptEnabled={true}
158
- // injectedJavaScript={injectedJavaScript()}
159
- startInLoadingState={false}
160
- onLoadEnd={(_) => {
161
- dispatch({ isLoaded: true })
162
- // console.log('onLoadEnd')
163
- }}
164
- onError={e => {
165
- console.log('onError', e)
166
- }}
167
- source={{
168
- baseUrl: '',
169
- html: getHtml({ backgroundColor: (props.style as ViewStyle)?.backgroundColor || 'transparent' })
170
- }}
171
- />
172
- </View>
173
- )
174
-
175
- }
176
-
109
+ return (<View style={[styles.container, props.style]} ref={containerRef}>
110
+ <WebView ref={WebViewRef} originWhitelist={["*"]} useWebKit={true} // ios使用最新webkit内核渲染
111
+ allowUniversalAccessFromFileURLs={true} geolocationEnabled={true} mixedContentMode={"always"} renderLoading={() => {
112
+ if (props.renderLoading)
113
+ return props.renderLoading();
114
+ return (<View style={{
115
+ backgroundColor: props.style?.backgroundColor || "transparent",
116
+ }}/>);
117
+ }} // 设置空View,修复ioswebview闪白
118
+ style={{
119
+ backgroundColor: props.style?.backgroundColor || "transparent",
120
+ opacity: 0.99, //解决闪退的办法
121
+ }} // 设置背景色透明,修复android闪白
122
+ scrollEnabled={false}
123
+ // onMessage={e=>{
124
+ // console.log(e)
125
+ // }}
126
+ javaScriptEnabled={true}
127
+ // injectedJavaScript={injectedJavaScript()}
128
+ startInLoadingState={false} onLoadEnd={(_) => {
129
+ dispatch({ isLoaded: true });
130
+ // console.log('onLoadEnd')
131
+ }} onError={(e) => {
132
+ console.log("onError", e);
133
+ }} source={{
134
+ baseUrl: "",
135
+ html: getHtml({
136
+ backgroundColor: props.style?.backgroundColor || "transparent",
137
+ }),
138
+ }}/>
139
+ </View>);
140
+ };
177
141
  const styles = StyleSheet.create({
178
142
  container: {
179
- display: 'flex',
143
+ display: "flex",
180
144
  flexGrow: 0,
181
- backgroundColor: 'white'
182
- }
183
- })
184
-
185
-
186
-
187
-
188
-
189
- export default EchartsView
145
+ backgroundColor: "white",
146
+ },
147
+ });
148
+ export default EchartsView;
190
149
  // React.memo(EchartsView)
150
+ // import * as echarts from "echarts/core";
151
+ // export { echarts };
@@ -5,9 +5,7 @@
5
5
  * @LastEditTime: 2023-01-03 17:02:57
6
6
  * @FilePath: /@aks-dev/easyui/lib/Echarts/helper.tsx
7
7
  */
8
-
9
-
10
- export const getHtml = (props: { backgroundColor: any }) => {
8
+ export const getHtml = (props) => {
11
9
  return `
12
10
  <!DOCTYPE html>
13
11
  <html>
@@ -42,30 +40,25 @@ export const getHtml = (props: { backgroundColor: any }) => {
42
40
  </body>
43
41
 
44
42
  </html>
45
- `
46
- }
47
-
48
- /**
49
- * https://res.actiiot.com/echarts/5.0.2/echarts.min.js
50
- *
51
- * https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js
52
- */
53
-
54
- export const toString = (obj: object) => {
43
+ `;
44
+ };
45
+ /**
46
+ * https://res.actiiot.com/echarts/5.0.2/echarts.min.js
47
+ *
48
+ * https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js
49
+ */
50
+ export const toString = (obj) => {
55
51
  let result = JSON.stringify(obj, function (key, val) {
56
- // 对function进行特殊处理
57
- if (typeof val === 'function') {
58
- return `~ha~${val}~ha~`;
59
- }
60
- return val;
52
+ // 对function进行特殊处理
53
+ if (typeof val === 'function') {
54
+ return `~ha~${val}~ha~`;
55
+ }
56
+ return val;
61
57
  });
62
58
  // 再进行还原
63
59
  do {
64
- result = result.replace('\"~ha~', '').replace('~ha~\"', '').replace(/\\\"/g, "\"");//最后一个replace将release模式中莫名生成的\"转换成"
60
+ result = result.replace('\"~ha~', '').replace('~ha~\"', '').replace(/\\\"/g, "\""); //最后一个replace将release模式中莫名生成的\"转换成"
65
61
  } while (result.indexOf('~ha~') >= 0);
66
-
67
62
  return result;
68
- }
69
-
70
-
71
- ///.replace(/\\n/g, '')
63
+ };
64
+ ///.replace(/\\n/g, '')
@@ -0,0 +1,174 @@
1
+ import * as React from "react";
2
+ import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity, Dimensions, } from "react-native";
3
+ import Modal from "react-native-modal";
4
+ import { px2dp, deviceWidth } from "../../../screen/px2dp";
5
+ import { px2sp } from "../../../screen/px2sp";
6
+ export default React.forwardRef((_, ref) => {
7
+ const defaultState = {
8
+ visible: false,
9
+ cancelText: "取消",
10
+ confirmText: "确定",
11
+ };
12
+ const [state, setState] = React.useState(defaultState);
13
+ const cancelCallbackRef = React.useRef(undefined);
14
+ const confirmCallbackRef = React.useRef(undefined);
15
+ React.useImperativeHandle(ref, () => ({
16
+ show: async (options) => {
17
+ setState(Object.assign({}, defaultState, { visible: true }, options));
18
+ cancelCallbackRef.current = options.cancel;
19
+ confirmCallbackRef.current = options.confirm;
20
+ },
21
+ hide,
22
+ }), []);
23
+ const hide = async () => {
24
+ setState(defaultState);
25
+ };
26
+ React.useEffect(() => {
27
+ if (Platform.OS == "android") {
28
+ if (state.visible) {
29
+ StatusBar.setBackgroundColor("black");
30
+ StatusBar.setBarStyle("light-content");
31
+ }
32
+ else {
33
+ StatusBar.setBackgroundColor("transparent");
34
+ StatusBar.setBarStyle("dark-content");
35
+ }
36
+ }
37
+ }, [state.visible]);
38
+ return (<Modal hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
39
+ useNativeDriver={true} //定义动画是否应使用本机驱动程序
40
+ animationIn="slideInUp" animationOut="slideOutDown" onBackButtonPress={() => {
41
+ //按下Android后退按钮时调用
42
+ hide();
43
+ }} onBackdropPress={() => {
44
+ //按下背景时调用
45
+ hide();
46
+ }} isVisible={state.visible} style={{ margin: 0 }} deviceHeight={Dimensions.get("screen").height}>
47
+ <View style={styles.container}>
48
+ <View style={[styles.wrapper, state.wrapperStyle]}>
49
+ {state.title && <Text style={styles.titleText}>{state.title}</Text>}
50
+ <View style={[state.contentContainerStyle]}>
51
+ {(() => {
52
+ if (typeof state.content == "string")
53
+ return <Text style={styles.contentText}>{state.content}</Text>;
54
+ if (React.isValidElement(state.content))
55
+ return state.content;
56
+ return <View />;
57
+ })()}
58
+ </View>
59
+ {(state.cancelText || state.confirmText) && (<View style={styles.action}>
60
+ {state.cancelText && (<TouchableOpacity style={[
61
+ styles.cancel,
62
+ { marginRight: state.confirmText ? px2dp(15) : 0 },
63
+ state.cancelContainerStyle,
64
+ ]} activeOpacity={0.8} onPress={() => {
65
+ hide();
66
+ cancelCallbackRef.current && cancelCallbackRef.current();
67
+ cancelCallbackRef.current = undefined;
68
+ }}>
69
+ <Text style={[styles.cancelText, state.cancelTextStyle]}>
70
+ {state.cancelText}
71
+ </Text>
72
+ </TouchableOpacity>)}
73
+
74
+ {state.confirmText && (<TouchableOpacity style={[
75
+ styles.confirm,
76
+ { marginLeft: state.cancelText ? px2dp(15) : 0 },
77
+ state.confirmContainerStyle,
78
+ ]} activeOpacity={0.8} onPress={() => {
79
+ hide();
80
+ confirmCallbackRef.current && confirmCallbackRef.current();
81
+ confirmCallbackRef.current = undefined;
82
+ }}>
83
+ <Text style={[styles.confirmText, state.confirmTextStyle]}>
84
+ {state.confirmText}
85
+ </Text>
86
+ </TouchableOpacity>)}
87
+ </View>)}
88
+ </View>
89
+ </View>
90
+ </Modal>);
91
+ });
92
+ export const alertBottomViewRef = React.createRef();
93
+ export const showAlertBottomModal = (props) => {
94
+ alertBottomViewRef.current?.show(props);
95
+ };
96
+ // const sleep = (msec?: number) => {
97
+ // return new Promise(resolve => {
98
+ // setTimeout(resolve, msec || 350);
99
+ // });
100
+ // }
101
+ const styles = StyleSheet.create({
102
+ container: {
103
+ display: "flex",
104
+ flexGrow: 1,
105
+ justifyContent: "flex-end",
106
+ alignItems: "center",
107
+ },
108
+ wrapper: {
109
+ flexGrow: 0,
110
+ flexShrink: 0,
111
+ width: "100%",
112
+ backgroundColor: "white",
113
+ overflow: "hidden",
114
+ borderTopLeftRadius: px2dp(10),
115
+ borderTopRightRadius: px2dp(10),
116
+ display: "flex",
117
+ padding: px2dp(15),
118
+ },
119
+ titleText: {
120
+ maxWidth: deviceWidth - px2dp(30),
121
+ fontSize: px2sp(18),
122
+ marginBottom: px2dp(20),
123
+ // backgroundColor: 'red',
124
+ textAlign: "center",
125
+ fontWeight: "bold",
126
+ color: "#1A1A1A",
127
+ },
128
+ contentText: {
129
+ maxWidth: deviceWidth - px2dp(30),
130
+ marginBottom: px2dp(20),
131
+ minHeight: px2dp(40),
132
+ flexGrow: 0,
133
+ flexShrink: 1,
134
+ width: undefined,
135
+ fontSize: px2sp(15),
136
+ // backgroundColor: 'red',
137
+ color: "#1A1A1A",
138
+ textAlign: "center",
139
+ },
140
+ action: {
141
+ display: "flex",
142
+ flexDirection: "row",
143
+ justifyContent: "space-between",
144
+ alignItems: "center",
145
+ // backgroundColor:"red"
146
+ },
147
+ cancel: {
148
+ width: "40%",
149
+ height: px2dp(44),
150
+ display: "flex",
151
+ justifyContent: "center",
152
+ alignItems: "center",
153
+ borderRadius: px2dp(10),
154
+ borderWidth: px2dp(1),
155
+ borderColor: "#A3A9CC",
156
+ },
157
+ confirm: {
158
+ width: "40%",
159
+ height: px2dp(44),
160
+ display: "flex",
161
+ justifyContent: "center",
162
+ alignItems: "center",
163
+ backgroundColor: "#2763FF",
164
+ borderRadius: px2dp(10),
165
+ },
166
+ cancelText: {
167
+ fontSize: px2sp(15),
168
+ color: "#A3A9CC",
169
+ },
170
+ confirmText: {
171
+ fontSize: px2sp(15),
172
+ color: "white",
173
+ },
174
+ });