@aks-dev/easyui 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/android/build.gradle +44 -0
  4. package/android/src/main/AndroidManifest.xml +20 -0
  5. package/android/src/main/java/com/easyui/RNEasyuiModule.java +29 -0
  6. package/android/src/main/java/com/easyui/RNEasyuiPackage.java +38 -0
  7. package/android/src/main/java/com/easyui/UpgradeModule.java +54 -0
  8. package/ios/RNEasyui.h +18 -0
  9. package/ios/RNEasyui.m +13 -0
  10. package/ios/RNEasyui.podspec +24 -0
  11. package/ios/RNEasyui.xcodeproj/project.pbxproj +259 -0
  12. package/ios/RNEasyui.xcworkspace/contents.xcworkspacedata +9 -0
  13. package/ios/UpgradeModule.h +12 -0
  14. package/ios/UpgradeModule.m +38 -0
  15. package/jsbridge/RNEasyui.tsx +13 -0
  16. package/jsbridge/UpgradeModule.tsx +13 -0
  17. package/jsbridge/index.ts +13 -0
  18. package/lib/Badge/Badge.tsx +39 -0
  19. package/lib/Badge/index.ts +21 -0
  20. package/lib/Easy-Hud/AlertView/AlertView.tsx +233 -0
  21. package/lib/Easy-Hud/AlertView/index.ts +41 -0
  22. package/lib/Easy-Hud/EasyHud.tsx +48 -0
  23. package/lib/Easy-Hud/Loading/Loading.tsx +80 -0
  24. package/lib/Easy-Hud/Loading/index.ts +35 -0
  25. package/lib/Easy-Hud/Toast/Toast.tsx +86 -0
  26. package/lib/Easy-Hud/Toast/index.ts +22 -0
  27. package/lib/Easy-Hud/index.ts +18 -0
  28. package/lib/Echarts/EchartsView.tsx +151 -0
  29. package/lib/Echarts/demo.tsx +235 -0
  30. package/lib/Echarts/helper.tsx +63 -0
  31. package/lib/Echarts/index.ts +29 -0
  32. package/lib/Modal/Modal.tsx +12 -0
  33. package/lib/Modal/index.ts +10 -0
  34. package/lib/MutiPictureView/MutiPictureView.tsx +213 -0
  35. package/lib/MutiPictureView/icon_add_image.png +0 -0
  36. package/lib/MutiPictureView/icon_del_image.png +0 -0
  37. package/lib/MutiPictureView/index.ts +55 -0
  38. package/lib/PictureViewer/PictureViewer.tsx +80 -0
  39. package/lib/PictureViewer/index.ts +26 -0
  40. package/lib/RefreshList/RefreshList.tsx +222 -0
  41. package/lib/RefreshList/demo.tsx +30 -0
  42. package/lib/RefreshList/demo1.tsx +60 -0
  43. package/lib/RefreshList/demo2.tsx +46 -0
  44. package/lib/RefreshList/index.ts +84 -0
  45. package/lib/StickHeaderView/StickHeaderView.tsx +65 -0
  46. package/lib/StickHeaderView/demo.tsx +104 -0
  47. package/lib/StickHeaderView/index.ts +26 -0
  48. package/lib/TableCell/TableCell.tsx +117 -0
  49. package/lib/TableCell/back.png +0 -0
  50. package/lib/TableCell/index.ts +45 -0
  51. package/lib/TextInputArea/TextInputArea.tsx +88 -0
  52. package/lib/TextInputArea/index.ts +32 -0
  53. package/lib/WithLoadingContainer/WithLoadingContainer.tsx +93 -0
  54. package/lib/WithLoadingContainer/index.ts +36 -0
  55. package/lib/WithLoadingContainer/loading.gif +0 -0
  56. package/lib/WithLoadingContainer/loading3.gif +0 -0
  57. package/package.json +59 -0
  58. package/screen/index.ts +16 -0
  59. package/screen/px2dp.tsx +44 -0
  60. package/screen/px2sp.tsx +65 -0
  61. package/screen/text-set.tsx +58 -0
  62. package/src/index.d.ts +58 -0
  63. package/src/index.ts +66 -0
  64. package/utils/index.ts +56 -0
  65. package/utils/lazy.tsx +40 -0
  66. package/utils/mode.tsx +48 -0
@@ -0,0 +1,213 @@
1
+ /*
2
+ * @Author: OBKoro1
3
+ * @Date: 2022-04-24 17:38:27
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-05-11 20:01:05
6
+ * @FilePath: /@aks/easyui/lib/MutiPictureView/MutiPictureView.tsx
7
+ */
8
+
9
+ import * as React from 'react'
10
+ import { Image, View, StyleSheet, Keyboard, ImageSourcePropType, TouchableOpacity, MeasureOnSuccessCallback, Text } from 'react-native'
11
+ import { px2dp } from '../../screen/px2dp'
12
+ import { px2sp } from '../../screen/px2sp'
13
+
14
+ import SYImagePicker from "@shiguo2022/react-native-syan-image-picker";
15
+
16
+
17
+ import type { MutiPictureViewProps } from '.'
18
+
19
+ let icon_add_image = require('./icon_add_image.png')
20
+ let icon_del_image = require('./icon_del_image.png')
21
+
22
+ const MutiPictureView: React.FC<MutiPictureViewProps> = (props) => {
23
+ const {
24
+ bind,
25
+ maxCount = 6,
26
+ type = 'showImagePicker',
27
+ addIcon,
28
+ addIconStyle,
29
+ addIconContainerStyle,//borderWidth: 1, borderStyle: 'dashed', borderColor: assets.color_A3A9CC 虚线框
30
+ delIcon,
31
+ delIconStyle,
32
+ spacingHorizontal = px2dp(15),
33
+ spacingInner = px2dp(8),
34
+ editable = true
35
+ } = props
36
+ const { viewModel, setViewModel } = bind
37
+ React.useEffect(() => {
38
+
39
+
40
+ }, [])
41
+
42
+ const [sideLength, setSideLength] = React.useState<number>(0)
43
+
44
+
45
+
46
+ const addPhoto = () => {
47
+ let images: any[] = viewModel.photos || []
48
+ if (!images) {
49
+ throw new Error("viewModel没有定义photos字段")
50
+ }
51
+
52
+ if (type == 'showImagePicker') {
53
+ SYImagePicker.showImagePicker({ imageCount: maxCount - (viewModel.photos?.length || 0), isCrop: false, isRecordSelected: false, quality: 20 }, (err, photos) => {
54
+ if (!err) {
55
+ let imgs = photos.map((it) => { return { uri: it.uri } })
56
+ images = images.concat(imgs)
57
+ setViewModel({ photos: images })
58
+ }
59
+ })
60
+ }
61
+
62
+ if (type == 'openCamera') {
63
+ SYImagePicker.openCamera({ imageCount: maxCount - (viewModel.photos?.length || 0), isCrop: false, isRecordSelected: false, quality: 20 }, (err, photos) => {
64
+ if (!err) {
65
+ let imgs = photos.map((it) => { return { uri: it.uri } })
66
+ images = images.concat(imgs)
67
+ setViewModel({ photos: images })
68
+ } else {
69
+ console.log('打开相机失败')
70
+ }
71
+ })
72
+ }
73
+
74
+
75
+
76
+ }
77
+
78
+ const deletePhoto = (index: number) => {
79
+ Keyboard.dismiss()
80
+ let photos = [...viewModel.photos || []]
81
+ photos.splice(index, 1)
82
+ setViewModel({ photos: photos })
83
+ }
84
+
85
+ const showPhoto = (index: number) => {
86
+ Keyboard.dismiss()
87
+ let imgs: any[] = viewModel.photos?.filter((it) => { return (typeof it === 'string' && it.indexOf('http') >= 0) || typeof it == 'object' }) || []
88
+ let images: any[] = []
89
+ // console.log('viewModel', viewModel, imgs)
90
+ imgs.forEach(it => {
91
+ if (typeof it === 'string') {
92
+ images.push({ uri: it })
93
+ } else {
94
+ images.push(it)
95
+ }
96
+ })
97
+ setViewModel({
98
+ imageViewer: {
99
+ imageUrls: images.map((it) => {
100
+ return it.uri
101
+ }),
102
+ index: index,
103
+ visible: true,
104
+ }
105
+ })
106
+ }
107
+
108
+
109
+
110
+
111
+
112
+
113
+ const ItemView: React.FC<{ source: ImageSourcePropType, index: number }> = ({ source, index }) => {
114
+
115
+ return (
116
+ <TouchableOpacity style={[styles.item_container, {
117
+ marginTop: index < 3 ? 0 : spacingInner,
118
+ marginLeft: index % 3 == 0 ? spacingHorizontal : spacingInner,
119
+ width: sideLength,
120
+ height: sideLength,
121
+ }]} activeOpacity={0.8} onPress={() => showPhoto(index)}>
122
+ <Image source={source} style={{ width: '100%', height: '100%' }} resizeMode='cover' />
123
+ {
124
+ editable &&
125
+ <TouchableOpacity onPress={() => deletePhoto(index)} style={[styles.del_img_container, delIconStyle]}>
126
+ <Image source={delIcon ? delIcon : icon_del_image} resizeMode='contain' style={{ width: '100%', height: '100%' }} />
127
+ </TouchableOpacity>
128
+ }
129
+ </TouchableOpacity>
130
+ )
131
+
132
+
133
+ }
134
+
135
+
136
+
137
+ const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
138
+
139
+ React.useEffect(() => {
140
+ containerRef.current?.measure((...args) => {
141
+ // console.log(args)
142
+ let _sideLength = (args[2] - spacingHorizontal * 2 - spacingInner * 2) / 3
143
+ setSideLength(_sideLength)
144
+ })
145
+
146
+ }, [])
147
+
148
+ return (
149
+ <View style={[styles.container, props.style]} ref={containerRef as any}>
150
+ {viewModel?.photos instanceof Array && viewModel.photos.map((item, index) => {
151
+ return <ItemView key={index} source={typeof item === 'string' ? { uri: item } : item} index={index} />
152
+ })}
153
+
154
+ {
155
+ !(viewModel?.photos?.length == maxCount) && editable && (
156
+ <TouchableOpacity style={[styles.item_container, {
157
+ marginTop: (viewModel?.photos?.length || 0) >= 3 ? spacingInner : 0,
158
+ marginLeft: (viewModel?.photos?.length || 0) % 3 == 0 ? spacingHorizontal : spacingInner,
159
+ width: sideLength,
160
+ height: sideLength,
161
+ }, addIconContainerStyle]} activeOpacity={0.8} onPress={() => addPhoto()}>
162
+ <Image source={addIcon ? addIcon : icon_add_image} style={[{ width: '25%', height: '25%' }, addIconStyle]} resizeMode='contain' />
163
+ {props.addText && <Text style={[{ fontSize: px2sp(12), color: 'lightgrey', marginTop: px2dp(2) }, props.addTextStyle]}>{props.addText}</Text>}
164
+ </TouchableOpacity>
165
+
166
+ )
167
+ }
168
+ </View >
169
+
170
+ )
171
+ }
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ const styles = StyleSheet.create({
181
+ container: {
182
+ flexGrow: 1,
183
+ minHeight: 1,
184
+ // backgroundColor: 'red',
185
+ display: 'flex',
186
+ flexDirection: 'row',
187
+ flexWrap: 'wrap',
188
+ borderRadius: px2dp(10),
189
+ },
190
+ item_container: {
191
+ overflow: 'hidden',
192
+ borderRadius: px2dp(10),
193
+ display: 'flex',
194
+ position: 'relative',
195
+ justifyContent: 'center',
196
+ alignItems: 'center',
197
+ backgroundColor: '#ededed'
198
+ },
199
+
200
+ del_img_container: {
201
+ position: 'absolute',
202
+ right: 2,
203
+ top: 2,
204
+ width: px2dp(24),
205
+ height: px2dp(24)
206
+ },
207
+ })
208
+
209
+
210
+ export default React.memo(MutiPictureView, (prevProps, nextProps) => false);
211
+
212
+
213
+
@@ -0,0 +1,55 @@
1
+ import { TextStyle } from 'react-native';
2
+ /*
3
+ * @Author: shiguo
4
+ * @Date: 2022-04-24 17:38:32
5
+ * @LastEditors: shiguo
6
+ * @LastEditTime: 2022-05-09 19:34:22
7
+ * @FilePath: /@aks/easyui/lib/MutiPictureView/index.ts
8
+ */
9
+ import { StyleProp, ViewStyle, ImageStyle, ImageSourcePropType } from 'react-native'
10
+
11
+ type ViewModelProps = {
12
+ photos?: any[];
13
+ /**@deprecated disabled 图片点击状态,已弃用*/
14
+ disabled?: boolean;
15
+ imageViewer: {
16
+ imageUrls: any[],
17
+ index: number,
18
+ visible: boolean
19
+ }
20
+ }
21
+
22
+
23
+ type BindProps = {
24
+ viewModel: ViewModelProps;
25
+ setViewModel: (intent: Partial<ViewModelProps>) => void
26
+ }
27
+
28
+
29
+
30
+ export declare type MutiPictureViewProps = {
31
+ /**@deprecated title 标题 ,已弃用*/
32
+ title?: string;
33
+ bind: BindProps;
34
+ maxCount?: number;
35
+ type?: 'showImagePicker' | 'openCamera';
36
+ style?:StyleProp<ViewStyle>;
37
+ addIcon?: ImageSourcePropType;
38
+ addIconStyle?: StyleProp<ImageStyle>;
39
+ addText?:string;
40
+ addTextStyle?:StyleProp<TextStyle>;
41
+ addIconContainerStyle?:StyleProp<ViewStyle>;
42
+ delIcon?: ImageSourcePropType;
43
+ delIconStyle?: StyleProp<ImageStyle>;
44
+ /**外边距 */
45
+ spacingHorizontal?: number;
46
+ /**内边距 */
47
+ spacingInner?: number;
48
+ /**仅仅看看,不增减图片 */
49
+ editable?:boolean;
50
+ }
51
+
52
+
53
+ export declare const MutiPictureView:React.FC<MutiPictureViewProps>;
54
+
55
+
@@ -0,0 +1,80 @@
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
+
9
+ import * as React from 'react'
10
+ import { Modal, StatusBar, Platform } from 'react-native'
11
+ import ImageViewer from "react-native-image-zoom-viewer";
12
+
13
+ import type { BindProps } from './index'
14
+
15
+ export const PictureViewer: React.FC<{ bind: BindProps }> = ({ bind }) => {
16
+
17
+ const { viewModel, setViewModel } = bind
18
+ const visible = viewModel.imageViewer.visible
19
+ const imgs = viewModel.imageViewer.imageUrls?.map(item => ({ url: item }))
20
+ const index = viewModel.imageViewer.index
21
+
22
+ React.useEffect(() => {
23
+ if (Platform.OS == 'android') {
24
+ if (visible) {
25
+ StatusBar.setBackgroundColor('black')
26
+ StatusBar.setBarStyle('light-content')
27
+ } else {
28
+ StatusBar.setBackgroundColor('transparent')
29
+ StatusBar.setBarStyle('dark-content')
30
+ }
31
+ }
32
+ }, [visible])
33
+
34
+
35
+
36
+ return (
37
+ <Modal
38
+ presentationStyle='overFullScreen'
39
+ visible={visible}
40
+ transparent={false}
41
+ onRequestClose={() => {
42
+ /**
43
+ * 【官方文档】
44
+ * onRequestClose回调会在用户按下 Android 设备上的后退按键或是 Apple TV 上的菜单键时触发。
45
+ * 请务必注意本属性在 Android 平台上为必填,且会在 modal 处于开启状态时阻止BackHandler事件。
46
+ */
47
+ setViewModel({
48
+ imageViewer: {
49
+ ...viewModel.imageViewer,
50
+ visible: false
51
+ }
52
+ })
53
+ }}
54
+ style={{ margin: 0, backgroundColor: 'red' }}
55
+ >
56
+ <ImageViewer
57
+ imageUrls={imgs}
58
+ index={index}
59
+ onSwipeDown={() => {
60
+ // console.log('onSwipeDown');
61
+ }}
62
+ saveToLocalByLongPress={false}
63
+ // onMove={data => console.log(data)}
64
+ useNativeDriver={true}
65
+ enableSwipeDown={true}
66
+ onClick={() => {
67
+ setViewModel({
68
+ imageViewer: {
69
+ ...viewModel.imageViewer,
70
+ visible: false
71
+ }
72
+ })
73
+ }}
74
+ />
75
+ </Modal>
76
+ )
77
+ }
78
+
79
+
80
+
@@ -0,0 +1,26 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-24 17:10:21
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-04-26 11:35:20
6
+ * @FilePath: /@aks/easy/lib/PictureViewer/index.ts
7
+ */
8
+
9
+
10
+ type ViewModelProps = {
11
+ imageViewer: {
12
+ imageUrls: any[],
13
+ index: number,
14
+ visible: boolean
15
+ }
16
+ }
17
+
18
+
19
+ export type BindProps = {
20
+ viewModel: ViewModelProps,
21
+ setViewModel: (intent: Partial<ViewModelProps>) => void
22
+ }
23
+
24
+
25
+
26
+ export declare const PictureViewer: React.FC<{ bind: BindProps }>;
@@ -0,0 +1,222 @@
1
+ import * as React from 'react';
2
+ import { View, Text, Animated, StyleSheet, ActivityIndicator, TouchableOpacity } from 'react-native';
3
+ import { SwipeListView, RowMap } from 'react-native-swipe-list-view'
4
+
5
+
6
+
7
+ import {
8
+ FlatListRefreshProps,
9
+ SectionListRefreshProps,
10
+ SwipeListViewRefreshProps,
11
+ RefreshListProps,
12
+ RefreshState,
13
+ RefreshText
14
+ } from './index'
15
+
16
+
17
+
18
+
19
+
20
+ export default React.forwardRef((props: RefreshListProps, ref: React.Ref<any>) => {
21
+ const {
22
+ mode = 'FlatList',
23
+ refreshState,
24
+ onHeaderRefresh,
25
+ onFooterRefresh,
26
+ reload,
27
+ ...rest
28
+ } = props
29
+
30
+
31
+ const seed = React.useRef(Math.random()).current
32
+
33
+
34
+ let onRefresh = () => {
35
+ if (refreshState == RefreshState.HeaderRefreshing) return
36
+ if (refreshState == RefreshState.FooterRefreshing) return
37
+ onHeaderRefresh && onHeaderRefresh(RefreshState.HeaderRefreshing)
38
+ }
39
+
40
+ let onEndReached = (info: unknown) => {
41
+
42
+ if (mode == 'FlatList') {
43
+ props = props as FlatListRefreshProps;
44
+ if (!(props.data instanceof Array)) {
45
+ throw new Error('[sg:FlatList] data is not Array')
46
+ }
47
+ if (props.data.length == 0) return
48
+ }
49
+
50
+ if (mode == 'SectionList') {
51
+ props = props as SectionListRefreshProps;
52
+ if (!(props.sections instanceof Array)) {
53
+ throw new Error('[sg:SectionList] sections is not Array')
54
+ }
55
+ if (props.sections.length == 0) return
56
+ }
57
+
58
+ if (refreshState != RefreshState.Idle) return
59
+ onFooterRefresh && onFooterRefresh(RefreshState.FooterRefreshing)
60
+ }
61
+
62
+
63
+
64
+ switch (mode) {
65
+ case 'FlatList':
66
+ props = props as FlatListRefreshProps;
67
+ return (
68
+ <Animated.FlatList
69
+ {...rest as FlatListRefreshProps}
70
+ ref={ref}
71
+ refreshing={refreshState == RefreshState.HeaderRefreshing}
72
+ keyExtractor={(_, index) => { return `sg-index-FlatList-${seed}-${index}` }}
73
+ contentContainerStyle={props.data?.length ? {} : { height: "100%" }}
74
+ onRefresh={onRefresh}
75
+ onEndReachedThreshold={0.1}
76
+ onEndReached={onEndReached}
77
+ showsVerticalScrollIndicator={false}
78
+ ListHeaderComponent={(_) => <ListHeaderComponent {...props} />}
79
+ ListFooterComponent={(_) => <ListFooterComponent {...props} />}
80
+
81
+ />
82
+ )
83
+
84
+ case 'SectionList':
85
+ props = props as SectionListRefreshProps;
86
+ const { ItemSeparatorComponent = (_) => (
87
+ <View style={{ height: 1 }} />
88
+ ) } = props
89
+ return (
90
+ <Animated.SectionList
91
+ {...rest as SectionListRefreshProps}
92
+ ref={ref}
93
+ refreshing={refreshState == RefreshState.HeaderRefreshing}
94
+ onRefresh={onRefresh}
95
+ keyExtractor={(_, index) => { return `sg-index-SectionList-${seed}-${index}` }}
96
+ contentContainerStyle={props.sections?.length > 0 ? {} : { height: "100%" }}
97
+ ItemSeparatorComponent={ItemSeparatorComponent}
98
+ onEndReachedThreshold={0.1}
99
+ onEndReached={onEndReached}
100
+ showsVerticalScrollIndicator={false}
101
+ ListHeaderComponent={(_) => <ListHeaderComponent {...props} />}
102
+ ListFooterComponent={(_) => <ListFooterComponent {...props} />}
103
+ renderSectionHeader={props.renderSectionHeader}
104
+ />
105
+ )
106
+
107
+ case 'SwipeList':
108
+ const { renderHiddenItem = (data, rowMap) => (
109
+ <View style={{ backgroundColor: 'red', height: '100%', alignItems: 'flex-end', justifyContent: "center" }}>
110
+ <Text>Right </Text>
111
+ </View>
112
+ ) } = props as SwipeListViewRefreshProps
113
+ return (
114
+ <SwipeListView
115
+
116
+ {...rest as SwipeListViewRefreshProps}
117
+ rightOpenValue={-100}
118
+ leftOpenValue={0}
119
+ ref={ref}
120
+ disableLeftSwipe={false}
121
+ disableRightSwipe={true}
122
+ onRefresh={onRefresh}
123
+ refreshing={refreshState == RefreshState.HeaderRefreshing}
124
+ ItemSeparatorComponent={ItemSeparatorComponent}
125
+ onEndReachedThreshold={0.1}
126
+ onEndReached={onEndReached}
127
+ showsVerticalScrollIndicator={false}
128
+ ListHeaderComponent={(args) => <ListHeaderComponent {...props} />}
129
+ ListFooterComponent={(args) => <ListFooterComponent {...props} />}
130
+ renderHiddenItem={renderHiddenItem}
131
+ />
132
+
133
+ )
134
+ }
135
+
136
+ })
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ const ListFooterComponent = React.memo((props: RefreshListProps) => {
145
+ const {
146
+ refreshState,
147
+ reload,
148
+ } = props
149
+
150
+ switch (refreshState) {
151
+ case RefreshState.Idle:
152
+ case RefreshState.FooterRefreshing:
153
+ return (
154
+ <View style={{ ...styles.container, flexDirection: 'row' }}>
155
+ <ActivityIndicator color={'gray'} />
156
+ <Text style={{ ...styles.text, marginLeft: 5 }}>{RefreshText.FooterRefreshing}</Text>
157
+ </View>
158
+ )
159
+ case RefreshState.NoMoreData:
160
+ return (
161
+ <View style={styles.container}>
162
+ <Text style={{ ...styles.text, color: '#999999' }}>{RefreshText.NoMoreData}</Text>
163
+ </View>
164
+ )
165
+ case RefreshState.Failure:
166
+ return (
167
+ <View style={styles.container}>
168
+ <TouchableOpacity onPress={() => reload && reload()}>
169
+ <Text style={styles.text}>{RefreshText.Failure}</Text>
170
+ </TouchableOpacity>
171
+ </View>
172
+ )
173
+ case RefreshState.EmptyData:
174
+ if (props.renderListEmptyComponent) return props.renderListEmptyComponent()
175
+ return (
176
+ <View style={{ width: '100%', height: '100%' }}>
177
+ <TouchableOpacity onPress={() => {
178
+ reload && reload()
179
+ }}>
180
+ <Text style={styles.text}>{RefreshText.EmptyData}</Text>
181
+ </TouchableOpacity>
182
+ </View>
183
+ )
184
+ default:
185
+ return <View />
186
+ }
187
+ })
188
+
189
+
190
+ const ListHeaderComponent = React.memo((props: RefreshListProps) => {
191
+ const { refreshState } = props
192
+ switch (refreshState) {
193
+ case RefreshState.HeaderRefreshing:
194
+ return (
195
+ <View style={{ ...styles.container, }}>
196
+ <Text style={{ ...styles.text, }}>{RefreshText.HeaderRefreshing}</Text>
197
+ </View>
198
+ )
199
+ default:
200
+ return <View />
201
+ }
202
+ })
203
+
204
+
205
+
206
+
207
+ const styles = StyleSheet.create({
208
+ container: {
209
+ display: 'flex',
210
+ flexDirection: 'column',
211
+ justifyContent: "center",
212
+ alignItems: 'center',
213
+ height: 44,
214
+ // backgroundColor:'cyan'
215
+ },
216
+ text: {
217
+ color: 'gray',
218
+ lineHeight: 16,
219
+ fontSize: 13,
220
+ },
221
+ })
222
+
@@ -0,0 +1,30 @@
1
+ import * as React from 'react'
2
+ import { View, TouchableOpacity, Text } from 'react-native'
3
+
4
+ import { RefreshList, RefreshState } from './index'
5
+
6
+
7
+
8
+ const App = () => {
9
+
10
+ const [refreshState, setRefreshState] = React.useState(RefreshState.Idle)
11
+
12
+
13
+ return (
14
+ <RefreshList
15
+ data={['a', 'b']}
16
+ renderItem={({ item, index }) => {
17
+
18
+ return <View>{item}</View>
19
+ }}
20
+
21
+ refreshState={refreshState}
22
+ onHeaderRefresh={() => {
23
+
24
+ }}
25
+ onFooterRefresh={() => {
26
+
27
+ }}
28
+ />
29
+ )
30
+ }
@@ -0,0 +1,60 @@
1
+ import * as React from 'react'
2
+ import { View, TouchableOpacity, Text } from 'react-native'
3
+
4
+ import { RefreshList, RefreshState } from './index'
5
+
6
+
7
+
8
+ const App = () => {
9
+
10
+ const [refreshState, setRefreshState] = React.useState(RefreshState.Idle)
11
+
12
+ const listRef = React.useRef<any>()
13
+
14
+ return (
15
+
16
+ <RefreshList
17
+ mode='SectionList'
18
+ sections={
19
+ [
20
+ {
21
+ title: "Main dishes",
22
+ data: ["Pizza", "Burger", "Risotto"]
23
+ },
24
+ {
25
+ title: "Sides",
26
+ data: ["French Fries", "Onion Rings", "Fried Shrimps"]
27
+ },
28
+ {
29
+ title: "Drinks",
30
+ data: ["Water", "Coke", "Beer"]
31
+ },
32
+ {
33
+ title: "Desserts",
34
+ data: ["Cheese Cake", "Ice Cream"]
35
+ }
36
+ ]
37
+ }
38
+ renderItem={({ item, section }) => {
39
+
40
+ return <View>{item}</View>
41
+ }}
42
+
43
+ refreshState={refreshState}
44
+ onHeaderRefresh={() => {
45
+
46
+ }}
47
+ onFooterRefresh={() => {
48
+
49
+ }}
50
+
51
+ renderSectionHeader={({ section: { letter } }) => (
52
+ <View style={{ backgroundColor: 'red' }}>
53
+
54
+ </View>
55
+ )}
56
+ />
57
+
58
+
59
+ )
60
+ }