@aks-dev/easyui 1.0.190 → 1.0.192
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.
- package/dist/components/AnimationModal/AnimationModal.js +23 -41
- package/dist/components/Badge/Badge.js +7 -16
- package/dist/components/DottedLine/DottedLine.js +15 -20
- package/dist/components/Echarts/EchartsView.js +40 -77
- package/dist/components/Echarts/demo.js +201 -0
- package/dist/components/Echarts/helper.js +1 -16
- package/dist/components/Hud/AlertBottomView/AlertBottomView.js +49 -64
- package/dist/components/Hud/AlertSheetView/AlertSheetView.js +30 -34
- package/dist/components/Hud/AlertView/AlertView.js +52 -66
- package/dist/components/Hud/Hud.js +8 -19
- package/dist/components/Hud/Loading/Loading.js +7 -25
- package/dist/components/Hud/PopoverView/PopoverView.js +5 -20
- package/dist/components/Hud/Scanner/Scanner.js +71 -99
- package/dist/components/Hud/Toast/Toast.js +6 -16
- package/dist/components/MenuView/MenuView.js +32 -73
- package/dist/components/Modal/Modal.js +0 -7
- package/dist/components/MutiPictureView/MutiPictureView.js +78 -88
- package/dist/components/PictureViewer/PictureViewer.js +11 -32
- package/dist/components/RefreshList/RefreshList.js +43 -52
- package/dist/components/RefreshList/demo.js +9 -0
- package/dist/components/RefreshList/demo1.js +27 -0
- package/dist/components/RefreshList/demo2.js +9 -0
- package/dist/components/RichText/RichText.js +23 -23
- package/dist/components/StickHeaderView/StickHeaderView.js +2 -12
- package/dist/components/StickHeaderView/demo.js +37 -0
- package/dist/components/TableCell/TableCell.js +37 -53
- package/dist/components/TextInputArea/TextInputArea.js +22 -31
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +14 -31
- package/dist/index.js +0 -11
- package/dist/jsbridge/RNEasyui.js +1 -26
- package/dist/jsbridge/UpgradeModule.js +12 -21
- package/dist/jsbridge/index.js +0 -7
- package/dist/screen/index.js +0 -8
- package/dist/screen/px2dp.js +2 -25
- package/dist/screen/px2sp.js +5 -35
- package/dist/screen/text-fit.js +5 -21
- package/dist/utils/index.js +0 -7
- package/dist/utils/lazy.js +19 -71
- package/dist/utils/mode.js +0 -21
- package/package.json +3 -7
- package/types/components/AnimationModal/AnimationModal.d.ts +0 -8
- package/types/components/AnimationModal/AnimationModal.d.ts.map +1 -1
- package/types/components/Echarts/demo.d.ts +4 -0
- package/types/components/Echarts/demo.d.ts.map +1 -0
- package/types/components/Echarts/helper.d.ts +0 -5
- package/types/components/Echarts/helper.d.ts.map +1 -1
- package/types/components/MutiPictureView/MutiPictureView.d.ts +0 -9
- package/types/components/MutiPictureView/MutiPictureView.d.ts.map +1 -1
- package/types/components/RefreshList/demo.d.ts +2 -0
- package/types/components/RefreshList/demo.d.ts.map +1 -0
- package/types/components/RefreshList/demo1.d.ts +2 -0
- package/types/components/RefreshList/demo1.d.ts.map +1 -0
- package/types/components/RefreshList/demo2.d.ts +2 -0
- package/types/components/RefreshList/demo2.d.ts.map +1 -0
- package/types/components/StickHeaderView/StickHeaderView.d.ts +0 -6
- package/types/components/StickHeaderView/StickHeaderView.d.ts.map +1 -1
- package/types/components/StickHeaderView/demo.d.ts +4 -0
- package/types/components/StickHeaderView/demo.d.ts.map +1 -0
- package/types/components/TextInputArea/TextInputArea.d.ts +0 -1
- package/types/components/TextInputArea/TextInputArea.d.ts.map +1 -1
- package/types/jsbridge/RNEasyui.d.ts +0 -18
- package/types/jsbridge/RNEasyui.d.ts.map +1 -1
- package/types/jsbridge/UpgradeModule.d.ts +0 -15
- package/types/jsbridge/UpgradeModule.d.ts.map +1 -1
- package/types/screen/px2dp.d.ts +0 -11
- package/types/screen/px2dp.d.ts.map +1 -1
- package/types/screen/text-fit.d.ts +0 -3
- package/types/screen/text-fit.d.ts.map +1 -1
- package/types/utils/lazy.d.ts +0 -33
- package/types/utils/lazy.d.ts.map +1 -1
- package/types/utils/mode.d.ts +0 -14
- package/types/utils/mode.d.ts.map +1 -1
|
@@ -1,10 +1,3 @@
|
|
|
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
1
|
import * as React from "react";
|
|
9
2
|
import { Image, View, StyleSheet, Keyboard, TouchableOpacity, Text, } from "react-native";
|
|
10
3
|
import { px2dp } from "../../screen/px2dp";
|
|
@@ -13,19 +6,20 @@ import SYImagePicker from "@aks-dev/react-native-syan-image-picker";
|
|
|
13
6
|
let icon_add_image = require("./assets/icon_add_image.png");
|
|
14
7
|
let icon_del_image = require("./assets/icon_del_image.png");
|
|
15
8
|
const MutiPictureView = (props) => {
|
|
16
|
-
|
|
17
|
-
itemContainerStyle, emptyPlaceHolderStyle, delIcon, delIconStyle, spacingHorizontal = px2dp(15), spacingInner = px2dp(8), editable = true, showEmptyPlaceHolder = false, } = props;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10
|
+
const { bind, maxCount = 6, type = "showImagePicker", addIcon, addIconStyle, addIconContainerStyle, itemContainerStyle, emptyPlaceHolderStyle, delIcon, delIconStyle, spacingHorizontal = px2dp(15), spacingInner = px2dp(8), editable = true, showEmptyPlaceHolder = false, } = props;
|
|
18
11
|
const { viewModel, setViewModel } = bind;
|
|
19
12
|
React.useEffect(() => { }, []);
|
|
20
13
|
const [sideLength, setSideLength] = React.useState(0);
|
|
21
14
|
const addPhoto = () => {
|
|
15
|
+
var _a, _b;
|
|
22
16
|
let images = viewModel.photos || [];
|
|
23
17
|
if (!images) {
|
|
24
18
|
throw new Error("viewModel没有定义photos字段");
|
|
25
19
|
}
|
|
26
20
|
if (type == "showImagePicker") {
|
|
27
21
|
SYImagePicker.showImagePicker({
|
|
28
|
-
imageCount: maxCount - (viewModel.photos
|
|
22
|
+
imageCount: maxCount - (((_a = viewModel.photos) === null || _a === void 0 ? void 0 : _a.length) || 0),
|
|
29
23
|
isCrop: false,
|
|
30
24
|
isRecordSelected: false,
|
|
31
25
|
quality: 20,
|
|
@@ -41,7 +35,7 @@ const MutiPictureView = (props) => {
|
|
|
41
35
|
}
|
|
42
36
|
if (type == "openCamera") {
|
|
43
37
|
SYImagePicker.openCamera({
|
|
44
|
-
imageCount: maxCount - (viewModel.photos
|
|
38
|
+
imageCount: maxCount - (((_b = viewModel.photos) === null || _b === void 0 ? void 0 : _b.length) || 0),
|
|
45
39
|
isCrop: false,
|
|
46
40
|
isRecordSelected: false,
|
|
47
41
|
quality: 20,
|
|
@@ -66,13 +60,13 @@ const MutiPictureView = (props) => {
|
|
|
66
60
|
setViewModel({ photos: photos });
|
|
67
61
|
};
|
|
68
62
|
const showPhoto = (index) => {
|
|
63
|
+
var _a;
|
|
69
64
|
Keyboard.dismiss();
|
|
70
|
-
let imgs = (props.value || viewModel.photos)
|
|
65
|
+
let imgs = ((_a = (props.value || viewModel.photos)) === null || _a === void 0 ? void 0 : _a.filter((it) => {
|
|
71
66
|
return ((typeof it === "string" && it.indexOf("http") >= 0) ||
|
|
72
67
|
typeof it == "object");
|
|
73
|
-
}) || [];
|
|
68
|
+
})) || [];
|
|
74
69
|
let images = [];
|
|
75
|
-
// console.log('viewModel', viewModel, imgs)
|
|
76
70
|
imgs.forEach((it) => {
|
|
77
71
|
if (typeof it === "string") {
|
|
78
72
|
images.push({ uri: it });
|
|
@@ -92,7 +86,7 @@ const MutiPictureView = (props) => {
|
|
|
92
86
|
});
|
|
93
87
|
};
|
|
94
88
|
const ItemView = ({ source, index, }) => {
|
|
95
|
-
return (
|
|
89
|
+
return (React.createElement(TouchableOpacity, { style: [
|
|
96
90
|
styles.item_container,
|
|
97
91
|
itemContainerStyle,
|
|
98
92
|
{
|
|
@@ -101,17 +95,15 @@ const MutiPictureView = (props) => {
|
|
|
101
95
|
width: sideLength,
|
|
102
96
|
height: sideLength,
|
|
103
97
|
},
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</TouchableOpacity>)}
|
|
109
|
-
</TouchableOpacity>);
|
|
98
|
+
], activeOpacity: 0.8, onPress: () => showPhoto(index) },
|
|
99
|
+
React.createElement(Image, { source: source, style: { width: "100%", height: "100%" }, resizeMode: "cover" }),
|
|
100
|
+
editable && !props.value && (React.createElement(TouchableOpacity, { onPress: () => deletePhoto(index), style: [styles.del_img_container, delIconStyle] },
|
|
101
|
+
React.createElement(Image, { source: delIcon ? delIcon : icon_del_image, resizeMode: "contain", style: { width: "100%", height: "100%" } })))));
|
|
110
102
|
};
|
|
111
103
|
const containerRef = React.useRef(null);
|
|
112
104
|
React.useEffect(() => {
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
var _a;
|
|
106
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.measure((...args) => {
|
|
115
107
|
if (args.length > 3) {
|
|
116
108
|
let _sideLength = +((args[2] - spacingHorizontal * 2 - spacingInner * 2) /
|
|
117
109
|
3).toFixed(1);
|
|
@@ -119,89 +111,88 @@ const MutiPictureView = (props) => {
|
|
|
119
111
|
}
|
|
120
112
|
});
|
|
121
113
|
});
|
|
122
|
-
if (props.value && props.value
|
|
123
|
-
return (
|
|
124
|
-
|
|
125
|
-
props.value
|
|
126
|
-
return (
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
maxCount - (props.value?.length || 0) - 1 > 0 &&
|
|
114
|
+
if (props.value && ((_a = props.value) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
115
|
+
return (React.createElement(View, { style: [styles.container, props.style], ref: containerRef },
|
|
116
|
+
props.value instanceof Array &&
|
|
117
|
+
((_b = props.value) === null || _b === void 0 ? void 0 : _b.map((item, index) => {
|
|
118
|
+
return (React.createElement(ItemView, { key: index, source: typeof item === "string" ? { uri: item } : item, index: index }));
|
|
119
|
+
})),
|
|
120
|
+
showEmptyPlaceHolder &&
|
|
121
|
+
maxCount - (((_c = props.value) === null || _c === void 0 ? void 0 : _c.length) || 0) - 1 > 0 &&
|
|
131
122
|
Array.from({
|
|
132
|
-
length: maxCount - (props.value
|
|
133
|
-
}, (_, k) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
: 0
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
0
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
length: maxCount - (((_d = props.value) === null || _d === void 0 ? void 0 : _d.length) || 0) - (editable ? 1 : 0),
|
|
124
|
+
}, (_, k) => {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
return (React.createElement(View, { key: `sg-showEmptyPlaceHolder-${k}`, style: [
|
|
127
|
+
styles.empty_place_container,
|
|
128
|
+
emptyPlaceHolderStyle,
|
|
129
|
+
itemContainerStyle,
|
|
130
|
+
{
|
|
131
|
+
marginTop: k + (editable ? 1 : 0) + (((_a = props.value) === null || _a === void 0 ? void 0 : _a.length) || 0) > 2
|
|
132
|
+
? spacingInner
|
|
133
|
+
: 0,
|
|
134
|
+
marginLeft: (k + (editable ? 1 : 0) + (((_b = props.value) === null || _b === void 0 ? void 0 : _b.length) || 0)) %
|
|
135
|
+
3 ==
|
|
136
|
+
0
|
|
137
|
+
? spacingHorizontal
|
|
138
|
+
: spacingInner,
|
|
139
|
+
width: sideLength,
|
|
140
|
+
height: sideLength,
|
|
141
|
+
},
|
|
142
|
+
] }));
|
|
143
|
+
})));
|
|
151
144
|
}
|
|
152
|
-
return (
|
|
153
|
-
|
|
145
|
+
return (React.createElement(View, { style: [styles.container, props.style], ref: containerRef },
|
|
146
|
+
(viewModel === null || viewModel === void 0 ? void 0 : viewModel.photos) instanceof Array &&
|
|
154
147
|
viewModel.photos.map((item, index) => {
|
|
155
|
-
return (
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
{!(viewModel?.photos?.length == maxCount) && editable && (<TouchableOpacity style={[
|
|
148
|
+
return (React.createElement(ItemView, { key: index, source: typeof item === "string" ? { uri: item } : item, index: index }));
|
|
149
|
+
}),
|
|
150
|
+
!(((_e = viewModel === null || viewModel === void 0 ? void 0 : viewModel.photos) === null || _e === void 0 ? void 0 : _e.length) == maxCount) && editable && (React.createElement(TouchableOpacity, { style: [
|
|
159
151
|
styles.item_container,
|
|
160
152
|
itemContainerStyle,
|
|
161
153
|
{
|
|
162
|
-
marginTop: (viewModel
|
|
163
|
-
marginLeft: (viewModel
|
|
154
|
+
marginTop: (((_f = viewModel === null || viewModel === void 0 ? void 0 : viewModel.photos) === null || _f === void 0 ? void 0 : _f.length) || 0) >= 3 ? spacingInner : 0,
|
|
155
|
+
marginLeft: (((_g = viewModel === null || viewModel === void 0 ? void 0 : viewModel.photos) === null || _g === void 0 ? void 0 : _g.length) || 0) % 3 == 0
|
|
164
156
|
? spacingHorizontal
|
|
165
157
|
: spacingInner,
|
|
166
158
|
width: sideLength,
|
|
167
159
|
height: sideLength,
|
|
168
160
|
},
|
|
169
161
|
addIconContainerStyle,
|
|
170
|
-
]
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
], activeOpacity: 0.8, onPress: () => addPhoto() },
|
|
163
|
+
React.createElement(Image, { source: addIcon ? addIcon : icon_add_image, style: [{ width: "25%", height: "25%" }, addIconStyle], resizeMode: "contain" }),
|
|
164
|
+
props.addText && (React.createElement(Text, { style: [
|
|
173
165
|
{
|
|
174
166
|
fontSize: px2sp(12),
|
|
175
167
|
color: "lightgrey",
|
|
176
168
|
marginTop: px2dp(2),
|
|
177
169
|
},
|
|
178
170
|
props.addTextStyle,
|
|
179
|
-
]}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
</TouchableOpacity>)}
|
|
183
|
-
{showEmptyPlaceHolder &&
|
|
184
|
-
maxCount - (viewModel.photos?.length || 0) - 1 > 0 &&
|
|
171
|
+
] }, props.addText)))),
|
|
172
|
+
showEmptyPlaceHolder &&
|
|
173
|
+
maxCount - (((_h = viewModel.photos) === null || _h === void 0 ? void 0 : _h.length) || 0) - 1 > 0 &&
|
|
185
174
|
Array.from({
|
|
186
|
-
length: maxCount - (viewModel.photos
|
|
187
|
-
}, (_, k) =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
: 0
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
0
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
175
|
+
length: maxCount - (((_j = viewModel.photos) === null || _j === void 0 ? void 0 : _j.length) || 0) - (editable ? 1 : 0),
|
|
176
|
+
}, (_, k) => {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
return (React.createElement(View, { key: `sg-showEmptyPlaceHolder-${k}`, style: [
|
|
179
|
+
styles.empty_place_container,
|
|
180
|
+
emptyPlaceHolderStyle,
|
|
181
|
+
itemContainerStyle,
|
|
182
|
+
{
|
|
183
|
+
marginTop: k + (editable ? 1 : 0) + (((_a = viewModel.photos) === null || _a === void 0 ? void 0 : _a.length) || 0) > 2
|
|
184
|
+
? spacingInner
|
|
185
|
+
: 0,
|
|
186
|
+
marginLeft: (k + (editable ? 1 : 0) + (((_b = viewModel.photos) === null || _b === void 0 ? void 0 : _b.length) || 0)) %
|
|
187
|
+
3 ==
|
|
188
|
+
0
|
|
189
|
+
? spacingHorizontal
|
|
190
|
+
: spacingInner,
|
|
191
|
+
width: sideLength,
|
|
192
|
+
height: sideLength,
|
|
193
|
+
},
|
|
194
|
+
] }));
|
|
195
|
+
})));
|
|
205
196
|
};
|
|
206
197
|
const styles = StyleSheet.create({
|
|
207
198
|
container: {
|
|
@@ -211,7 +202,6 @@ const styles = StyleSheet.create({
|
|
|
211
202
|
display: "flex",
|
|
212
203
|
flexDirection: "row",
|
|
213
204
|
flexWrap: "wrap",
|
|
214
|
-
// borderRadius: px2dp(10),
|
|
215
205
|
},
|
|
216
206
|
item_container: {
|
|
217
207
|
overflow: "hidden",
|
|
@@ -1,17 +1,11 @@
|
|
|
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
1
|
import * as React from "react";
|
|
9
2
|
import { Modal, StatusBar, Platform } from "react-native";
|
|
10
3
|
import ImageViewer from "react-native-image-zoom-viewer";
|
|
11
4
|
export const PictureViewer = ({ bind, }) => {
|
|
5
|
+
var _a;
|
|
12
6
|
const { viewModel, setViewModel } = bind;
|
|
13
7
|
const visible = viewModel.imageViewer.visible;
|
|
14
|
-
const imgs = viewModel.imageViewer.imageUrls
|
|
8
|
+
const imgs = (_a = viewModel.imageViewer.imageUrls) === null || _a === void 0 ? void 0 : _a.map((item) => ({ url: item }));
|
|
15
9
|
const index = viewModel.imageViewer.index;
|
|
16
10
|
React.useEffect(() => {
|
|
17
11
|
if (Platform.OS == "android") {
|
|
@@ -25,30 +19,15 @@ export const PictureViewer = ({ bind, }) => {
|
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
}, [visible]);
|
|
28
|
-
return (
|
|
29
|
-
/**
|
|
30
|
-
* 【官方文档】
|
|
31
|
-
* onRequestClose回调会在用户按下 Android 设备上的后退按键或是 Apple TV 上的菜单键时触发。
|
|
32
|
-
* 请务必注意本属性在 Android 平台上为必填,且会在 modal 处于开启状态时阻止BackHandler事件。
|
|
33
|
-
*/
|
|
22
|
+
return (React.createElement(Modal, { presentationStyle: "overFullScreen", visible: visible, transparent: false, onRequestClose: () => {
|
|
34
23
|
setViewModel({
|
|
35
|
-
imageViewer: {
|
|
36
|
-
...viewModel.imageViewer,
|
|
37
|
-
visible: false,
|
|
38
|
-
},
|
|
24
|
+
imageViewer: Object.assign(Object.assign({}, viewModel.imageViewer), { visible: false }),
|
|
39
25
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
imageViewer: {
|
|
48
|
-
...viewModel.imageViewer,
|
|
49
|
-
visible: false,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}}/>
|
|
53
|
-
</Modal>);
|
|
26
|
+
}, style: { margin: 0, backgroundColor: "red" } },
|
|
27
|
+
React.createElement(ImageViewer, { imageUrls: imgs, index: index, onSwipeDown: () => {
|
|
28
|
+
}, saveToLocalByLongPress: false, useNativeDriver: true, enableSwipeDown: true, onClick: () => {
|
|
29
|
+
setViewModel({
|
|
30
|
+
imageViewer: Object.assign(Object.assign({}, viewModel.imageViewer), { visible: false }),
|
|
31
|
+
});
|
|
32
|
+
} })));
|
|
54
33
|
};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import * as React from "react";
|
|
2
13
|
import { View, Text, Animated, StyleSheet, ActivityIndicator, TouchableOpacity, } from "react-native";
|
|
3
14
|
import { SwipeListView } from "react-native-swipe-list-view";
|
|
@@ -20,7 +31,8 @@ export var RefreshState;
|
|
|
20
31
|
RefreshState["None"] = "None";
|
|
21
32
|
})(RefreshState || (RefreshState = {}));
|
|
22
33
|
export default React.forwardRef((props, ref) => {
|
|
23
|
-
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const { mode = "FlatList", refreshState, onHeaderRefresh, onFooterRefresh, reload } = props, rest = __rest(props, ["mode", "refreshState", "onHeaderRefresh", "onFooterRefresh", "reload"]);
|
|
24
36
|
const seed = React.useRef(Math.random()).current;
|
|
25
37
|
let onRefresh = () => {
|
|
26
38
|
if (refreshState == RefreshState.HeaderRefreshing)
|
|
@@ -53,42 +65,33 @@ export default React.forwardRef((props, ref) => {
|
|
|
53
65
|
switch (mode) {
|
|
54
66
|
case "FlatList": {
|
|
55
67
|
let flatListProps = props;
|
|
56
|
-
return (
|
|
68
|
+
return (React.createElement(Animated.FlatList, Object.assign({}, rest, { ref: ref, refreshing: refreshState == RefreshState.HeaderRefreshing, keyExtractor: (_, index) => {
|
|
57
69
|
return `sg-index-FlatList-${seed}-${index}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
{/* {flatListProps.ListHeaderComponent} */}
|
|
61
|
-
</View>)}
|
|
62
|
-
// ListHeaderComponent={flatListProps.ListHeaderComponent}
|
|
63
|
-
ListFooterComponent={(_) => (<ListFooterComponent {...flatListProps}/>)}/>);
|
|
70
|
+
}, contentContainerStyle: ((_a = flatListProps.data) === null || _a === void 0 ? void 0 : _a.length) ? {} : { height: "100%" }, onRefresh: onRefresh, onEndReachedThreshold: 0.1, onEndReached: onEndReached, showsVerticalScrollIndicator: false, ListHeaderComponent: (_) => (React.createElement(View, { style: { display: "flex", flexDirection: "column" } },
|
|
71
|
+
React.createElement(ListHeaderComponent, Object.assign({}, flatListProps)))), ListFooterComponent: (_) => (React.createElement(ListFooterComponent, Object.assign({}, flatListProps))) })));
|
|
64
72
|
}
|
|
65
73
|
case "SectionList": {
|
|
66
74
|
let sectionListProps = props;
|
|
67
|
-
const { ItemSeparatorComponent = (_) =>
|
|
68
|
-
return (
|
|
75
|
+
const { ItemSeparatorComponent = (_) => React.createElement(View, { style: { height: 1 } }), } = sectionListProps;
|
|
76
|
+
return (React.createElement(Animated.SectionList, Object.assign({}, rest, { ref: ref, refreshing: refreshState == RefreshState.HeaderRefreshing, onRefresh: onRefresh, keyExtractor: (_, index) => {
|
|
69
77
|
return `sg-index-SectionList-${seed}-${index}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<ListHeaderComponent {...sectionListProps}/>
|
|
74
|
-
{sectionListProps.ListHeaderComponent}
|
|
75
|
-
</View>)} ListFooterComponent={(_) => (<ListFooterComponent {...sectionListProps}/>)} renderSectionHeader={sectionListProps.renderSectionHeader}/>);
|
|
78
|
+
}, contentContainerStyle: ((_b = sectionListProps.sections) === null || _b === void 0 ? void 0 : _b.length) > 0 ? {} : { height: "100%" }, ItemSeparatorComponent: ItemSeparatorComponent, onEndReachedThreshold: 0.1, onEndReached: onEndReached, showsVerticalScrollIndicator: false, ListHeaderComponent: (_) => (React.createElement(View, { style: { display: "flex", flexDirection: "column" } },
|
|
79
|
+
React.createElement(ListHeaderComponent, Object.assign({}, sectionListProps)),
|
|
80
|
+
sectionListProps.ListHeaderComponent)), ListFooterComponent: (_) => (React.createElement(ListFooterComponent, Object.assign({}, sectionListProps))), renderSectionHeader: sectionListProps.renderSectionHeader })));
|
|
76
81
|
}
|
|
77
82
|
case "SwipeList": {
|
|
78
83
|
let swipeListProps = props;
|
|
79
|
-
const { ItemSeparatorComponent = (_) =>
|
|
80
|
-
const { renderHiddenItem = (data, rowMap) => (
|
|
84
|
+
const { ItemSeparatorComponent = (_) => React.createElement(View, { style: { height: 1 } }), } = swipeListProps;
|
|
85
|
+
const { renderHiddenItem = (data, rowMap) => (React.createElement(View, { style: {
|
|
81
86
|
backgroundColor: "red",
|
|
82
87
|
height: "100%",
|
|
83
88
|
alignItems: "flex-end",
|
|
84
89
|
justifyContent: "center",
|
|
85
|
-
}}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{swipeListProps.ListHeaderComponent}
|
|
91
|
-
</View>)} ListFooterComponent={(args) => (<ListFooterComponent {...swipeListProps}/>)} renderHiddenItem={renderHiddenItem}/>);
|
|
90
|
+
} },
|
|
91
|
+
React.createElement(Text, null, "Right "))), } = swipeListProps;
|
|
92
|
+
return (React.createElement(SwipeListView, Object.assign({}, 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: (_) => (React.createElement(View, { style: { display: "flex", flexDirection: "column" } },
|
|
93
|
+
React.createElement(ListHeaderComponent, Object.assign({}, swipeListProps)),
|
|
94
|
+
swipeListProps.ListHeaderComponent)), ListFooterComponent: (args) => (React.createElement(ListFooterComponent, Object.assign({}, swipeListProps))), renderHiddenItem: renderHiddenItem })));
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
});
|
|
@@ -97,45 +100,34 @@ const ListFooterComponent = React.memo((props) => {
|
|
|
97
100
|
switch (refreshState) {
|
|
98
101
|
case RefreshState.Idle:
|
|
99
102
|
case RefreshState.FooterRefreshing:
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
{RefreshText.FooterRefreshing}
|
|
104
|
-
</Text>
|
|
105
|
-
</View>);
|
|
103
|
+
return (React.createElement(View, { style: Object.assign(Object.assign({}, styles.container), { flexDirection: "row" }) },
|
|
104
|
+
React.createElement(ActivityIndicator, { color: "gray" }),
|
|
105
|
+
React.createElement(Text, { style: Object.assign(Object.assign({}, styles.text), { marginLeft: 5 }) }, RefreshText.FooterRefreshing)));
|
|
106
106
|
case RefreshState.NoMoreData:
|
|
107
|
-
return (
|
|
108
|
-
|
|
109
|
-
{RefreshText.NoMoreData}
|
|
110
|
-
</Text>
|
|
111
|
-
</View>);
|
|
107
|
+
return (React.createElement(View, { style: styles.container },
|
|
108
|
+
React.createElement(Text, { style: Object.assign(Object.assign({}, styles.text), { color: "#999999" }) }, RefreshText.NoMoreData)));
|
|
112
109
|
case RefreshState.Failure:
|
|
113
|
-
return (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</TouchableOpacity>
|
|
117
|
-
</View>);
|
|
110
|
+
return (React.createElement(View, { style: styles.container },
|
|
111
|
+
React.createElement(TouchableOpacity, { onPress: () => reload && reload() },
|
|
112
|
+
React.createElement(Text, { style: styles.text }, RefreshText.Failure))));
|
|
118
113
|
case RefreshState.EmptyData:
|
|
119
114
|
if (props.renderListEmptyComponent)
|
|
120
115
|
return props.renderListEmptyComponent();
|
|
121
|
-
return (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</TouchableOpacity>
|
|
125
|
-
</View>);
|
|
116
|
+
return (React.createElement(View, { style: styles.container },
|
|
117
|
+
React.createElement(TouchableOpacity, { onPress: () => reload && reload() },
|
|
118
|
+
React.createElement(Text, { style: styles.text }, RefreshText.EmptyData))));
|
|
126
119
|
default:
|
|
127
|
-
return
|
|
120
|
+
return React.createElement(View, null);
|
|
128
121
|
}
|
|
129
122
|
});
|
|
130
123
|
const ListHeaderComponent = React.memo((props) => {
|
|
131
124
|
const { refreshState } = props;
|
|
132
125
|
switch (refreshState) {
|
|
133
126
|
case RefreshState.HeaderRefreshing:
|
|
134
|
-
return (
|
|
135
|
-
|
|
136
|
-
</View>);
|
|
127
|
+
return (React.createElement(View, { style: Object.assign({}, styles.container) },
|
|
128
|
+
React.createElement(Text, { style: Object.assign({}, styles.text) }, RefreshText.HeaderRefreshing)));
|
|
137
129
|
default:
|
|
138
|
-
return
|
|
130
|
+
return React.createElement(View, null);
|
|
139
131
|
}
|
|
140
132
|
});
|
|
141
133
|
const styles = StyleSheet.create({
|
|
@@ -145,7 +137,6 @@ const styles = StyleSheet.create({
|
|
|
145
137
|
justifyContent: "center",
|
|
146
138
|
alignItems: "center",
|
|
147
139
|
height: 44,
|
|
148
|
-
// backgroundColor:'cyan'
|
|
149
140
|
},
|
|
150
141
|
text: {
|
|
151
142
|
color: "gray",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { default as RefreshList, RefreshState } from "./RefreshList";
|
|
4
|
+
const App = () => {
|
|
5
|
+
const [refreshState, setRefreshState] = React.useState(RefreshState.Idle);
|
|
6
|
+
return (React.createElement(RefreshList, { data: ["a", "b"], renderItem: ({ item, index }) => {
|
|
7
|
+
return React.createElement(View, null, item);
|
|
8
|
+
}, refreshState: refreshState, onHeaderRefresh: () => { }, onFooterRefresh: () => { } }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { default as RefreshList, RefreshState } from "./RefreshList";
|
|
4
|
+
const App = () => {
|
|
5
|
+
const [refreshState, setRefreshState] = React.useState(RefreshState.Idle);
|
|
6
|
+
const listRef = React.useRef(null);
|
|
7
|
+
return (React.createElement(RefreshList, { mode: "SectionList", sections: [
|
|
8
|
+
{
|
|
9
|
+
title: "Main dishes",
|
|
10
|
+
data: ["Pizza", "Burger", "Risotto"],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: "Sides",
|
|
14
|
+
data: ["French Fries", "Onion Rings", "Fried Shrimps"],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: "Drinks",
|
|
18
|
+
data: ["Water", "Coke", "Beer"],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Desserts",
|
|
22
|
+
data: ["Cheese Cake", "Ice Cream"],
|
|
23
|
+
},
|
|
24
|
+
], renderItem: ({ item, section }) => {
|
|
25
|
+
return React.createElement(View, null, item);
|
|
26
|
+
}, refreshState: refreshState, onHeaderRefresh: () => { }, onFooterRefresh: () => { }, renderSectionHeader: ({ section: { letter } }) => (React.createElement(View, { style: { backgroundColor: "red" } })) }));
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { RefreshState } from "./RefreshList";
|
|
3
|
+
const App = () => {
|
|
4
|
+
const [refreshState, setRefreshState] = React.useState(RefreshState.Idle);
|
|
5
|
+
const listRef = React.useRef(null);
|
|
6
|
+
const dataList = Array(20)
|
|
7
|
+
.fill("")
|
|
8
|
+
.map((_, i) => ({ key: `${i}`, text: `item #${i}` }));
|
|
9
|
+
};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
8
12
|
import React from "react";
|
|
9
13
|
import { StyleSheet, Text } from "react-native";
|
|
10
14
|
import { px2sp } from "../../screen/px2sp";
|
|
11
15
|
import * as utils from "../../utils/lazy";
|
|
12
16
|
export default (props) => {
|
|
13
|
-
const { rich, richStyle, text, suffix, prefix,
|
|
17
|
+
const { rich, richStyle, text, suffix, prefix } = props, rest = __rest(props, ["rich", "richStyle", "text", "suffix", "prefix"]);
|
|
14
18
|
let textStr = "";
|
|
15
19
|
let richStr = "";
|
|
16
20
|
if (utils.isString(text) || utils.isNumber(text)) {
|
|
@@ -21,27 +25,24 @@ export default (props) => {
|
|
|
21
25
|
}
|
|
22
26
|
let positionStart = 0;
|
|
23
27
|
let positionEnd = 0;
|
|
24
|
-
if (textStr
|
|
28
|
+
if ((textStr === null || textStr === void 0 ? void 0 : textStr.indexOf(richStr)) >= 0) {
|
|
25
29
|
positionStart = textStr.indexOf(richStr);
|
|
26
30
|
positionEnd = positionStart + richStr.length;
|
|
27
31
|
}
|
|
28
32
|
if (prefix) {
|
|
29
|
-
return (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</Text>);
|
|
33
|
+
return (React.createElement(Text, Object.assign({ style: styles.container }, rest),
|
|
34
|
+
React.createElement(Text, { style: Object.assign(Object.assign({}, styles.defaultRich), richStyle) }, richStr),
|
|
35
|
+
textStr));
|
|
33
36
|
}
|
|
34
37
|
if (suffix) {
|
|
35
|
-
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</Text>);
|
|
38
|
+
return (React.createElement(Text, Object.assign({ style: styles.container }, rest),
|
|
39
|
+
textStr,
|
|
40
|
+
React.createElement(Text, { style: Object.assign(Object.assign({}, styles.defaultRich), richStyle) }, richStr)));
|
|
39
41
|
}
|
|
40
|
-
return (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</Text>);
|
|
42
|
+
return (React.createElement(Text, Object.assign({ style: styles.container }, rest),
|
|
43
|
+
textStr.substring(0, positionStart),
|
|
44
|
+
positionEnd > 0 && (React.createElement(Text, { style: Object.assign(Object.assign({}, styles.defaultRich), richStyle) }, richStr)),
|
|
45
|
+
textStr.substring(positionEnd, textStr.length)));
|
|
45
46
|
};
|
|
46
47
|
const styles = StyleSheet.create({
|
|
47
48
|
container: {
|
|
@@ -51,6 +52,5 @@ const styles = StyleSheet.create({
|
|
|
51
52
|
defaultRich: {
|
|
52
53
|
color: "red",
|
|
53
54
|
fontSize: px2sp(14),
|
|
54
|
-
// fontWeight: 'bold'
|
|
55
55
|
},
|
|
56
56
|
});
|