@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,239 @@
1
+ /*
2
+ * @Author: OBKoro1
3
+ * @Date: 2022-04-24 17:38:27
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-11-14 11:33:33
6
+ * @FilePath: /@aks-dev/easyui/lib/MutiPictureView/MutiPictureView.tsx
7
+ */
8
+ import * as React from "react";
9
+ import { Image, View, StyleSheet, Keyboard, TouchableOpacity, Text, } from "react-native";
10
+ import { px2dp } from "../../screen/px2dp";
11
+ import { px2sp } from "../../screen/px2sp";
12
+ import SYImagePicker from "@aks-dev/react-native-syan-image-picker";
13
+ let icon_add_image = require("./assets/icon_add_image.png");
14
+ let icon_del_image = require("./assets/icon_del_image.png");
15
+ const MutiPictureView = (props) => {
16
+ const { bind, maxCount = 6, type = "showImagePicker", addIcon, addIconStyle, addIconContainerStyle, //borderWidth: 1, borderStyle: 'dashed', borderColor: assets.color_A3A9CC 虚线框
17
+ itemContainerStyle, emptyPlaceHolderStyle, delIcon, delIconStyle, spacingHorizontal = px2dp(15), spacingInner = px2dp(8), editable = true, showEmptyPlaceHolder = false, } = props;
18
+ const { viewModel, setViewModel } = bind;
19
+ React.useEffect(() => { }, []);
20
+ const [sideLength, setSideLength] = React.useState(0);
21
+ const addPhoto = () => {
22
+ let images = viewModel.photos || [];
23
+ if (!images) {
24
+ throw new Error("viewModel没有定义photos字段");
25
+ }
26
+ if (type == "showImagePicker") {
27
+ SYImagePicker.showImagePicker({
28
+ imageCount: maxCount - (viewModel.photos?.length || 0),
29
+ isCrop: false,
30
+ isRecordSelected: false,
31
+ quality: 20,
32
+ }, (err, photos) => {
33
+ if (!err) {
34
+ let imgs = photos.map((it) => {
35
+ return { uri: it.uri };
36
+ });
37
+ images = images.concat(imgs);
38
+ setViewModel({ photos: images });
39
+ }
40
+ });
41
+ }
42
+ if (type == "openCamera") {
43
+ SYImagePicker.openCamera({
44
+ imageCount: maxCount - (viewModel.photos?.length || 0),
45
+ isCrop: false,
46
+ isRecordSelected: false,
47
+ quality: 20,
48
+ }, (err, photos) => {
49
+ if (!err) {
50
+ let imgs = photos.map((it) => {
51
+ return { uri: it.uri };
52
+ });
53
+ images = images.concat(imgs);
54
+ setViewModel({ photos: images });
55
+ }
56
+ else {
57
+ console.log("打开相机失败");
58
+ }
59
+ });
60
+ }
61
+ };
62
+ const deletePhoto = (index) => {
63
+ Keyboard.dismiss();
64
+ let photos = [...(viewModel.photos || [])];
65
+ photos.splice(index, 1);
66
+ setViewModel({ photos: photos });
67
+ };
68
+ const showPhoto = (index) => {
69
+ Keyboard.dismiss();
70
+ let imgs = (props.value || viewModel.photos)?.filter((it) => {
71
+ return ((typeof it === "string" && it.indexOf("http") >= 0) ||
72
+ typeof it == "object");
73
+ }) || [];
74
+ let images = [];
75
+ // console.log('viewModel', viewModel, imgs)
76
+ imgs.forEach((it) => {
77
+ if (typeof it === "string") {
78
+ images.push({ uri: it });
79
+ }
80
+ else {
81
+ images.push(it);
82
+ }
83
+ });
84
+ setViewModel({
85
+ imageViewer: {
86
+ imageUrls: images.map((it) => {
87
+ return it.uri;
88
+ }),
89
+ index: index,
90
+ visible: true,
91
+ },
92
+ });
93
+ };
94
+ const ItemView = ({ source, index, }) => {
95
+ return (<TouchableOpacity style={[
96
+ styles.item_container,
97
+ itemContainerStyle,
98
+ {
99
+ marginTop: index < 3 ? 0 : spacingInner,
100
+ marginLeft: index % 3 == 0 ? spacingHorizontal : spacingInner,
101
+ width: sideLength,
102
+ height: sideLength,
103
+ },
104
+ ]} activeOpacity={0.8} onPress={() => showPhoto(index)}>
105
+ <Image source={source} style={{ width: "100%", height: "100%" }} resizeMode="cover"/>
106
+ {editable && !props.value && (<TouchableOpacity onPress={() => deletePhoto(index)} style={[styles.del_img_container, delIconStyle]}>
107
+ <Image source={delIcon ? delIcon : icon_del_image} resizeMode="contain" style={{ width: "100%", height: "100%" }}/>
108
+ </TouchableOpacity>)}
109
+ </TouchableOpacity>);
110
+ };
111
+ const containerRef = React.useRef(null);
112
+ React.useEffect(() => {
113
+ containerRef.current?.measure((...args) => {
114
+ // console.log('measure', args[2])
115
+ if (args.length > 3) {
116
+ let _sideLength = +((args[2] - spacingHorizontal * 2 - spacingInner * 2) /
117
+ 3).toFixed(1);
118
+ setSideLength(_sideLength - 0.1);
119
+ }
120
+ });
121
+ });
122
+ if (props.value && props.value?.length > 0) {
123
+ return (<View style={[styles.container, props.style]} ref={containerRef}>
124
+ {props.value instanceof Array &&
125
+ props.value?.map((item, index) => {
126
+ return (<ItemView key={index} source={typeof item === "string" ? { uri: item } : item} index={index}/>);
127
+ })}
128
+
129
+ {showEmptyPlaceHolder &&
130
+ maxCount - (props.value?.length || 0) - 1 > 0 &&
131
+ Array.from({
132
+ length: maxCount - (props.value?.length || 0) - (editable ? 1 : 0),
133
+ }, (_, k) => (<View key={`sg-showEmptyPlaceHolder-${k}`} style={[
134
+ styles.empty_place_container,
135
+ emptyPlaceHolderStyle,
136
+ itemContainerStyle,
137
+ {
138
+ marginTop: k + (editable ? 1 : 0) + (props.value?.length || 0) > 2
139
+ ? spacingInner
140
+ : 0,
141
+ marginLeft: (k + (editable ? 1 : 0) + (props.value?.length || 0)) %
142
+ 3 ==
143
+ 0
144
+ ? spacingHorizontal
145
+ : spacingInner,
146
+ width: sideLength,
147
+ height: sideLength,
148
+ },
149
+ ]}/>))}
150
+ </View>);
151
+ }
152
+ return (<View style={[styles.container, props.style]} ref={containerRef}>
153
+ {viewModel?.photos instanceof Array &&
154
+ viewModel.photos.map((item, index) => {
155
+ return (<ItemView key={index} source={typeof item === "string" ? { uri: item } : item} index={index}/>);
156
+ })}
157
+
158
+ {!(viewModel?.photos?.length == maxCount) && editable && (<TouchableOpacity style={[
159
+ styles.item_container,
160
+ itemContainerStyle,
161
+ {
162
+ marginTop: (viewModel?.photos?.length || 0) >= 3 ? spacingInner : 0,
163
+ marginLeft: (viewModel?.photos?.length || 0) % 3 == 0
164
+ ? spacingHorizontal
165
+ : spacingInner,
166
+ width: sideLength,
167
+ height: sideLength,
168
+ },
169
+ addIconContainerStyle,
170
+ ]} activeOpacity={0.8} onPress={() => addPhoto()}>
171
+ <Image source={addIcon ? addIcon : icon_add_image} style={[{ width: "25%", height: "25%" }, addIconStyle]} resizeMode="contain"/>
172
+ {props.addText && (<Text style={[
173
+ {
174
+ fontSize: px2sp(12),
175
+ color: "lightgrey",
176
+ marginTop: px2dp(2),
177
+ },
178
+ props.addTextStyle,
179
+ ]}>
180
+ {props.addText}
181
+ </Text>)}
182
+ </TouchableOpacity>)}
183
+ {showEmptyPlaceHolder &&
184
+ maxCount - (viewModel.photos?.length || 0) - 1 > 0 &&
185
+ Array.from({
186
+ length: maxCount - (viewModel.photos?.length || 0) - (editable ? 1 : 0),
187
+ }, (_, k) => (<View key={`sg-showEmptyPlaceHolder-${k}`} style={[
188
+ styles.empty_place_container,
189
+ emptyPlaceHolderStyle,
190
+ itemContainerStyle,
191
+ {
192
+ marginTop: k + (editable ? 1 : 0) + (viewModel.photos?.length || 0) > 2
193
+ ? spacingInner
194
+ : 0,
195
+ marginLeft: (k + (editable ? 1 : 0) + (viewModel.photos?.length || 0)) %
196
+ 3 ==
197
+ 0
198
+ ? spacingHorizontal
199
+ : spacingInner,
200
+ width: sideLength,
201
+ height: sideLength,
202
+ },
203
+ ]}/>))}
204
+ </View>);
205
+ };
206
+ const styles = StyleSheet.create({
207
+ container: {
208
+ flex: 1,
209
+ minHeight: 1,
210
+ backgroundColor: "transparent",
211
+ display: "flex",
212
+ flexDirection: "row",
213
+ flexWrap: "wrap",
214
+ // borderRadius: px2dp(10),
215
+ },
216
+ item_container: {
217
+ overflow: "hidden",
218
+ borderRadius: px2dp(10),
219
+ display: "flex",
220
+ position: "relative",
221
+ justifyContent: "center",
222
+ alignItems: "center",
223
+ backgroundColor: "#ededed",
224
+ },
225
+ del_img_container: {
226
+ position: "absolute",
227
+ right: 2,
228
+ top: 2,
229
+ width: px2dp(24),
230
+ height: px2dp(24),
231
+ },
232
+ empty_place_container: {
233
+ borderRadius: px2dp(10),
234
+ backgroundColor: "#ededed",
235
+ borderColor: "#cccccc",
236
+ borderWidth: 0.75,
237
+ },
238
+ });
239
+ export default React.memo(MutiPictureView, (prevProps, nextProps) => false);
@@ -0,0 +1,54 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-24 15:58:39
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-04-26 12:38:13
6
+ * @FilePath: /@aks/easy/lib/PictureViewer/PictureViewer.tsx
7
+ */
8
+ import * as React from "react";
9
+ import { Modal, StatusBar, Platform } from "react-native";
10
+ import ImageViewer from "react-native-image-zoom-viewer";
11
+ export const PictureViewer = ({ bind, }) => {
12
+ const { viewModel, setViewModel } = bind;
13
+ const visible = viewModel.imageViewer.visible;
14
+ const imgs = viewModel.imageViewer.imageUrls?.map((item) => ({ url: item }));
15
+ const index = viewModel.imageViewer.index;
16
+ React.useEffect(() => {
17
+ if (Platform.OS == "android") {
18
+ if (visible) {
19
+ StatusBar.setBackgroundColor("black");
20
+ StatusBar.setBarStyle("light-content");
21
+ }
22
+ else {
23
+ StatusBar.setBackgroundColor("transparent");
24
+ StatusBar.setBarStyle("dark-content");
25
+ }
26
+ }
27
+ }, [visible]);
28
+ return (<Modal presentationStyle="overFullScreen" visible={visible} transparent={false} onRequestClose={() => {
29
+ /**
30
+ * 【官方文档】
31
+ * onRequestClose回调会在用户按下 Android 设备上的后退按键或是 Apple TV 上的菜单键时触发。
32
+ * 请务必注意本属性在 Android 平台上为必填,且会在 modal 处于开启状态时阻止BackHandler事件。
33
+ */
34
+ setViewModel({
35
+ imageViewer: {
36
+ ...viewModel.imageViewer,
37
+ visible: false,
38
+ },
39
+ });
40
+ }} style={{ margin: 0, backgroundColor: "red" }}>
41
+ <ImageViewer imageUrls={imgs} index={index} onSwipeDown={() => {
42
+ // console.log('onSwipeDown');
43
+ }} saveToLocalByLongPress={false}
44
+ // onMove={data => console.log(data)}
45
+ useNativeDriver={true} enableSwipeDown={true} onClick={() => {
46
+ setViewModel({
47
+ imageViewer: {
48
+ ...viewModel.imageViewer,
49
+ visible: false,
50
+ },
51
+ });
52
+ }}/>
53
+ </Modal>);
54
+ };
@@ -0,0 +1,155 @@
1
+ import * as React from "react";
2
+ import { View, Text, Animated, StyleSheet, ActivityIndicator, TouchableOpacity, } from "react-native";
3
+ import { SwipeListView } from "react-native-swipe-list-view";
4
+ export const RefreshText = {
5
+ HeaderRefreshing: "上拉可以刷新",
6
+ FooterRefreshing: "下拉可以加载更多",
7
+ Failure: "服务器正在出小差,点击重新加载",
8
+ NoMoreData: "已经全部加载完毕",
9
+ EmptyData: "没有数据",
10
+ Idle: "正在加载更多的数据..",
11
+ };
12
+ export var RefreshState;
13
+ (function (RefreshState) {
14
+ RefreshState["Idle"] = "Idle";
15
+ RefreshState["HeaderRefreshing"] = "HeaderRefreshing";
16
+ RefreshState["FooterRefreshing"] = "FooterRefreshing";
17
+ RefreshState["NoMoreData"] = "NoMoreData";
18
+ RefreshState["Failure"] = "Failure";
19
+ RefreshState["EmptyData"] = "EmptyData";
20
+ RefreshState["None"] = "None";
21
+ })(RefreshState || (RefreshState = {}));
22
+ export default React.forwardRef((props, ref) => {
23
+ const { mode = "FlatList", refreshState, onHeaderRefresh, onFooterRefresh, reload, ...rest } = props;
24
+ const seed = React.useRef(Math.random()).current;
25
+ let onRefresh = () => {
26
+ if (refreshState == RefreshState.HeaderRefreshing)
27
+ return;
28
+ if (refreshState == RefreshState.FooterRefreshing)
29
+ return;
30
+ onHeaderRefresh && onHeaderRefresh(RefreshState.HeaderRefreshing);
31
+ };
32
+ let onEndReached = (info) => {
33
+ if (mode == "FlatList") {
34
+ props = props;
35
+ if (!(props.data instanceof Array)) {
36
+ throw new Error("[sg:FlatList] data is not Array");
37
+ }
38
+ if (props.data.length == 0)
39
+ return;
40
+ }
41
+ if (mode == "SectionList") {
42
+ props = props;
43
+ if (!(props.sections instanceof Array)) {
44
+ throw new Error("[sg:SectionList] sections is not Array");
45
+ }
46
+ if (props.sections.length == 0)
47
+ return;
48
+ }
49
+ if (refreshState != RefreshState.Idle)
50
+ return;
51
+ onFooterRefresh && onFooterRefresh(RefreshState.FooterRefreshing);
52
+ };
53
+ switch (mode) {
54
+ case "FlatList": {
55
+ let flatListProps = props;
56
+ return (<Animated.FlatList {...rest} ref={ref} refreshing={refreshState == RefreshState.HeaderRefreshing} keyExtractor={(_, index) => {
57
+ return `sg-index-FlatList-${seed}-${index}`;
58
+ }} contentContainerStyle={flatListProps.data?.length ? {} : { height: "100%" }} onRefresh={onRefresh} onEndReachedThreshold={0.1} onEndReached={onEndReached} showsVerticalScrollIndicator={false} ListHeaderComponent={(_) => (<View style={{ display: "flex", flexDirection: "column" }}>
59
+ <ListHeaderComponent {...flatListProps}/>
60
+ {/* {flatListProps.ListHeaderComponent} */}
61
+ </View>)}
62
+ // ListHeaderComponent={flatListProps.ListHeaderComponent}
63
+ ListFooterComponent={(_) => (<ListFooterComponent {...flatListProps}/>)}/>);
64
+ }
65
+ case "SectionList": {
66
+ let sectionListProps = props;
67
+ const { ItemSeparatorComponent = (_) => <View style={{ height: 1 }}/>, } = sectionListProps;
68
+ return (<Animated.SectionList {...rest} ref={ref} refreshing={refreshState == RefreshState.HeaderRefreshing} onRefresh={onRefresh} keyExtractor={(_, index) => {
69
+ return `sg-index-SectionList-${seed}-${index}`;
70
+ }} contentContainerStyle={sectionListProps.sections?.length > 0 ? {} : { height: "100%" }} ItemSeparatorComponent={ItemSeparatorComponent} onEndReachedThreshold={0.1} onEndReached={onEndReached} showsVerticalScrollIndicator={false}
71
+ // ListHeaderComponent={(_) => <ListHeaderComponent {...sectionListProps} />}
72
+ ListHeaderComponent={(_) => (<View style={{ display: "flex", flexDirection: "column" }}>
73
+ <ListHeaderComponent {...sectionListProps}/>
74
+ {sectionListProps.ListHeaderComponent}
75
+ </View>)} ListFooterComponent={(_) => (<ListFooterComponent {...sectionListProps}/>)} renderSectionHeader={sectionListProps.renderSectionHeader}/>);
76
+ }
77
+ case "SwipeList": {
78
+ let swipeListProps = props;
79
+ const { ItemSeparatorComponent = (_) => <View style={{ height: 1 }}/>, } = swipeListProps;
80
+ const { renderHiddenItem = (data, rowMap) => (<View style={{
81
+ backgroundColor: "red",
82
+ height: "100%",
83
+ alignItems: "flex-end",
84
+ justifyContent: "center",
85
+ }}>
86
+ <Text>Right </Text>
87
+ </View>), } = swipeListProps;
88
+ return (<SwipeListView {...rest} rightOpenValue={-100} leftOpenValue={0} ref={ref} disableLeftSwipe={false} disableRightSwipe={true} onRefresh={onRefresh} refreshing={refreshState == RefreshState.HeaderRefreshing} ItemSeparatorComponent={ItemSeparatorComponent} onEndReachedThreshold={0.1} onEndReached={onEndReached} showsVerticalScrollIndicator={false} ListHeaderComponent={(_) => (<View style={{ display: "flex", flexDirection: "column" }}>
89
+ <ListHeaderComponent {...swipeListProps}/>
90
+ {swipeListProps.ListHeaderComponent}
91
+ </View>)} ListFooterComponent={(args) => (<ListFooterComponent {...swipeListProps}/>)} renderHiddenItem={renderHiddenItem}/>);
92
+ }
93
+ }
94
+ });
95
+ const ListFooterComponent = React.memo((props) => {
96
+ const { refreshState, reload } = props;
97
+ switch (refreshState) {
98
+ case RefreshState.Idle:
99
+ case RefreshState.FooterRefreshing:
100
+ return (<View style={{ ...styles.container, flexDirection: "row" }}>
101
+ <ActivityIndicator color={"gray"}/>
102
+ <Text style={{ ...styles.text, marginLeft: 5 }}>
103
+ {RefreshText.FooterRefreshing}
104
+ </Text>
105
+ </View>);
106
+ case RefreshState.NoMoreData:
107
+ return (<View style={styles.container}>
108
+ <Text style={{ ...styles.text, color: "#999999" }}>
109
+ {RefreshText.NoMoreData}
110
+ </Text>
111
+ </View>);
112
+ case RefreshState.Failure:
113
+ return (<View style={styles.container}>
114
+ <TouchableOpacity onPress={() => reload && reload()}>
115
+ <Text style={styles.text}>{RefreshText.Failure}</Text>
116
+ </TouchableOpacity>
117
+ </View>);
118
+ case RefreshState.EmptyData:
119
+ if (props.renderListEmptyComponent)
120
+ return props.renderListEmptyComponent();
121
+ return (<View style={styles.container}>
122
+ <TouchableOpacity onPress={() => reload && reload()}>
123
+ <Text style={styles.text}>{RefreshText.EmptyData}</Text>
124
+ </TouchableOpacity>
125
+ </View>);
126
+ default:
127
+ return <View />;
128
+ }
129
+ });
130
+ const ListHeaderComponent = React.memo((props) => {
131
+ const { refreshState } = props;
132
+ switch (refreshState) {
133
+ case RefreshState.HeaderRefreshing:
134
+ return (<View style={{ ...styles.container }}>
135
+ <Text style={{ ...styles.text }}>{RefreshText.HeaderRefreshing}</Text>
136
+ </View>);
137
+ default:
138
+ return <View />;
139
+ }
140
+ });
141
+ const styles = StyleSheet.create({
142
+ container: {
143
+ display: "flex",
144
+ flexDirection: "column",
145
+ justifyContent: "center",
146
+ alignItems: "center",
147
+ height: 44,
148
+ // backgroundColor:'cyan'
149
+ },
150
+ text: {
151
+ color: "gray",
152
+ lineHeight: 16,
153
+ fontSize: 13,
154
+ },
155
+ });
@@ -0,0 +1,56 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-07-11 15:42:16
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-07-11 16:15:02
6
+ * @FilePath: /@aks-dev/easyui/lib/RichText/RichText.tsx
7
+ */
8
+ import React from "react";
9
+ import { StyleSheet, Text } from "react-native";
10
+ import { px2sp } from "../../screen/px2sp";
11
+ import * as utils from "../../utils/lazy";
12
+ export default (props) => {
13
+ const { rich, richStyle, text, suffix, prefix, ...rest } = props;
14
+ let textStr = "";
15
+ let richStr = "";
16
+ if (utils.isString(text) || utils.isNumber(text)) {
17
+ textStr = String(text);
18
+ }
19
+ if (utils.isString(rich) || utils.isNumber(rich)) {
20
+ richStr = String(rich);
21
+ }
22
+ let positionStart = 0;
23
+ let positionEnd = 0;
24
+ if (textStr?.indexOf(richStr) >= 0) {
25
+ positionStart = textStr.indexOf(richStr);
26
+ positionEnd = positionStart + richStr.length;
27
+ }
28
+ if (prefix) {
29
+ return (<Text style={styles.container} {...rest}>
30
+ <Text style={{ ...styles.defaultRich, ...richStyle }}>{richStr}</Text>
31
+ {textStr}
32
+ </Text>);
33
+ }
34
+ if (suffix) {
35
+ return (<Text style={styles.container} {...rest}>
36
+ {textStr}
37
+ <Text style={{ ...styles.defaultRich, ...richStyle }}>{richStr}</Text>
38
+ </Text>);
39
+ }
40
+ return (<Text style={styles.container} {...rest}>
41
+ {textStr.substring(0, positionStart)}
42
+ {positionEnd > 0 && (<Text style={{ ...styles.defaultRich, ...richStyle }}>{richStr}</Text>)}
43
+ {textStr.substring(positionEnd, textStr.length)}
44
+ </Text>);
45
+ };
46
+ const styles = StyleSheet.create({
47
+ container: {
48
+ color: "#333333",
49
+ fontSize: px2sp(14),
50
+ },
51
+ defaultRich: {
52
+ color: "red",
53
+ fontSize: px2sp(14),
54
+ // fontWeight: 'bold'
55
+ },
56
+ });
@@ -0,0 +1,37 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-29 10:22:16
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-04-29 10:27:44
6
+ * @FilePath: /@aks/easyui/lib/StickHeaderView/StickHeaderView.tsx
7
+ */
8
+ import * as React from "react";
9
+ import { StyleSheet, Animated, } from "react-native";
10
+ const App = (props) => {
11
+ const { style, children, stickyHeaderY = -1, stickyScrollY = new Animated.Value(0), } = props;
12
+ const [stickyLayoutY, setStickyLayoutY] = React.useState(0);
13
+ // 兼容代码,防止没有传头部高度
14
+ const _onLayout = (event) => {
15
+ setStickyLayoutY(event.nativeEvent.layout.y);
16
+ };
17
+ const translateY = () => {
18
+ let y = stickyHeaderY !== -1 ? stickyHeaderY : stickyLayoutY;
19
+ return stickyScrollY.interpolate({
20
+ inputRange: [-1, 0, y, y + 1],
21
+ outputRange: [0, 0, 0, 1],
22
+ });
23
+ };
24
+ return (<Animated.View onLayout={_onLayout} style={[
25
+ style,
26
+ styles.container,
27
+ { transform: [{ translateY: translateY() }] },
28
+ ]}>
29
+ {children}
30
+ </Animated.View>);
31
+ };
32
+ const styles = StyleSheet.create({
33
+ container: {
34
+ zIndex: 100,
35
+ },
36
+ });
37
+ export default React.memo(App);
@@ -0,0 +1,97 @@
1
+ import * as React from "react";
2
+ import { View, Text, StyleSheet, TouchableOpacity, Image, } from "react-native";
3
+ import { px2dp } from "../../screen/px2dp";
4
+ import { px2sp } from "../../screen/px2sp";
5
+ export default (props) => {
6
+ const { showNav = false, activeOpacity = 0.8 } = props;
7
+ return (<TouchableOpacity activeOpacity={props.onPress == undefined ? activeOpacity : 1} style={[styles.container, props.style]} disabled={props.onPress == undefined} onPress={() => props.onPress && props.onPress()}>
8
+ <View style={[
9
+ styles.warpper,
10
+ props.showUnderline
11
+ ? {
12
+ borderBottomColor: "#f2f2f2",
13
+ // borderBottomWidth: StyleSheet.hairlineWidth,
14
+ borderBottomWidth: px2dp(1),
15
+ ...props.underlineStyle,
16
+ }
17
+ : {},
18
+ ]}>
19
+ {props.icon && (<Image style={[
20
+ { width: px2dp(20), height: px2dp(20), marginRight: px2dp(8) },
21
+ props.iconStyle,
22
+ ]} resizeMode="contain" source={props.icon}/>)}
23
+ <View style={[styles.middle, props.middleContaierStyle]}>
24
+ {/* 标题 */}
25
+ {(() => {
26
+ if (typeof props.title === "string" ||
27
+ typeof props.title === "number") {
28
+ return (<Text numberOfLines={1} {...props.titleOptions} style={[styles.title, props.titleOptions?.style]}>
29
+ {props.title}
30
+ </Text>);
31
+ }
32
+ if (React.isValidElement(props.title))
33
+ return props.title;
34
+ return <View style={styles.title}/>;
35
+ })()}
36
+
37
+ {(() => {
38
+ if (typeof props.content === "string" ||
39
+ typeof props.content === "number") {
40
+ return (<Text numberOfLines={1} {...props.contentOptions} style={[styles.content, props.contentOptions?.style]}>
41
+ {props.content}
42
+ </Text>);
43
+ }
44
+ if (React.isValidElement(props.content))
45
+ return props.content;
46
+ return undefined;
47
+ })()}
48
+ </View>
49
+ {showNav &&
50
+ (props.nav || (<Image style={{
51
+ width: px2dp(9),
52
+ height: px2dp(16),
53
+ marginLeft: px2dp(8),
54
+ }} source={require("./assets/back.png")}/>))}
55
+ </View>
56
+ </TouchableOpacity>);
57
+ };
58
+ const styles = StyleSheet.create({
59
+ container: {
60
+ display: "flex",
61
+ minHeight: px2dp(44),
62
+ paddingLeft: px2dp(15),
63
+ paddingRight: px2dp(10),
64
+ backgroundColor: "white",
65
+ },
66
+ warpper: {
67
+ flexGrow: 1,
68
+ display: "flex",
69
+ flexDirection: "row",
70
+ alignItems: "center",
71
+ position: "relative",
72
+ },
73
+ middle: {
74
+ flexGrow: 1,
75
+ flexShrink: 1,
76
+ display: "flex",
77
+ flexDirection: "row",
78
+ alignItems: "center",
79
+ justifyContent: "space-between",
80
+ // backgroundColor: 'cyan'
81
+ },
82
+ title: {
83
+ // backgroundColor: 'red',
84
+ flexGrow: 0,
85
+ flexShrink: 0,
86
+ fontSize: px2sp(14),
87
+ color: "#333333",
88
+ },
89
+ content: {
90
+ // backgroundColor: 'yellow',
91
+ flexGrow: 1,
92
+ flexShrink: 1,
93
+ fontSize: px2sp(14),
94
+ color: "#666666",
95
+ textAlign: "right",
96
+ },
97
+ });