@aks-dev/easyui 1.0.140 → 1.0.143
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.
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-05-17 15:22:06
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-12-
|
|
5
|
+
* @LastEditTime: 2022-12-27 09:12:36
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions, BackHandler } from 'react-native';
|
|
10
|
+
import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions, BackHandler, MeasureOnSuccessCallback } from 'react-native';
|
|
11
11
|
import type { AnimationModalProps } from '.';
|
|
12
12
|
import * as utils from '../../utils/lazy';
|
|
13
13
|
// type State = {
|
|
@@ -17,6 +17,7 @@ import * as utils from '../../utils/lazy';
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
|
|
20
21
|
export const AnimationModal: React.ForwardRefExoticComponent<
|
|
21
22
|
React.PropsWithoutRef<AnimationModalProps>
|
|
22
23
|
& React.RefAttributes<AnimationModalProps.RefAttributes>
|
|
@@ -49,24 +50,40 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
49
50
|
});
|
|
50
51
|
};
|
|
51
52
|
|
|
53
|
+
|
|
54
|
+
const viewRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>() as any
|
|
52
55
|
const layoutRef = React.useRef<{
|
|
53
56
|
/**:父容器的高度 */
|
|
54
57
|
h0: number;
|
|
55
58
|
/**:子容器的高度 */
|
|
56
59
|
h1: number;
|
|
57
60
|
}>({ h0: 0, h1: 0 })
|
|
61
|
+
const getLayoutPromise = () => {
|
|
62
|
+
return new Promise((resovle, reject) => {
|
|
63
|
+
viewRef.current?.measure((...args: any[]) => {
|
|
64
|
+
if (args.length == 6) {
|
|
65
|
+
layoutRef.current.h1 = args[3]
|
|
66
|
+
}
|
|
67
|
+
resovle(args)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}
|
|
58
71
|
|
|
59
72
|
React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
|
|
60
73
|
show,
|
|
61
74
|
hide,
|
|
62
75
|
target: targetRef.current
|
|
63
76
|
}), [])
|
|
77
|
+
|
|
64
78
|
const targetRef = React.useRef<any>()
|
|
65
79
|
|
|
66
80
|
|
|
81
|
+
|
|
82
|
+
|
|
67
83
|
const show = async () => {
|
|
68
84
|
setDisplay('flex', async () => {
|
|
69
85
|
await utils.sleep(50)
|
|
86
|
+
await getLayoutPromise()
|
|
70
87
|
timing(-layoutRef.current?.h1)
|
|
71
88
|
})
|
|
72
89
|
}
|
|
@@ -115,10 +132,12 @@ export const AnimationModal: React.ForwardRefExoticComponent<
|
|
|
115
132
|
>
|
|
116
133
|
<Animated.View
|
|
117
134
|
style={Object.assign({}, styles.wrapper, { transform: [{ translateY: animatedValue }] })}
|
|
118
|
-
onLayout={e => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}}
|
|
135
|
+
// onLayout={e => {
|
|
136
|
+
// let target: LayoutRectangle = e.nativeEvent.layout
|
|
137
|
+
// layoutRef.current.h1 = target.height
|
|
138
|
+
// }}
|
|
139
|
+
|
|
140
|
+
ref={viewRef}
|
|
122
141
|
>
|
|
123
142
|
{props.children}
|
|
124
143
|
</Animated.View>
|
|
@@ -172,4 +191,4 @@ const useCallbackState = <T,>(od: T): [T, (d: T, callback?: Function) => void] =
|
|
|
172
191
|
setData(d)
|
|
173
192
|
}
|
|
174
193
|
]
|
|
175
|
-
}
|
|
194
|
+
}
|
|
@@ -62,29 +62,34 @@ export default React.forwardRef((props: RefreshListProps, ref: React.Ref<any>) =
|
|
|
62
62
|
|
|
63
63
|
switch (mode) {
|
|
64
64
|
case 'FlatList':
|
|
65
|
-
|
|
65
|
+
let flatListProps: FlatListRefreshProps = props as FlatListRefreshProps
|
|
66
66
|
return (
|
|
67
67
|
<Animated.FlatList
|
|
68
68
|
{...rest as FlatListRefreshProps}
|
|
69
69
|
ref={ref}
|
|
70
70
|
refreshing={refreshState == RefreshState.HeaderRefreshing}
|
|
71
71
|
keyExtractor={(_, index) => { return `sg-index-FlatList-${seed}-${index}` }}
|
|
72
|
-
contentContainerStyle={
|
|
72
|
+
contentContainerStyle={flatListProps.data?.length ? {} : { height: "100%" }}
|
|
73
73
|
onRefresh={onRefresh}
|
|
74
74
|
onEndReachedThreshold={0.1}
|
|
75
75
|
onEndReached={onEndReached}
|
|
76
76
|
showsVerticalScrollIndicator={false}
|
|
77
|
-
ListHeaderComponent={(_) =>
|
|
78
|
-
|
|
77
|
+
ListHeaderComponent={(_) => (
|
|
78
|
+
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
79
|
+
<ListHeaderComponent {...flatListProps} />
|
|
80
|
+
{flatListProps.ListHeaderComponent}
|
|
81
|
+
</View>
|
|
82
|
+
)}
|
|
83
|
+
ListFooterComponent={(_) => <ListFooterComponent {...flatListProps} />}
|
|
79
84
|
|
|
80
85
|
/>
|
|
81
86
|
)
|
|
82
87
|
|
|
83
88
|
case 'SectionList':
|
|
84
|
-
|
|
89
|
+
let sectionListProps:SectionListRefreshProps = props as SectionListRefreshProps;
|
|
85
90
|
const { ItemSeparatorComponent = (_) => (
|
|
86
91
|
<View style={{ height: 1 }} />
|
|
87
|
-
) } =
|
|
92
|
+
) } = sectionListProps
|
|
88
93
|
return (
|
|
89
94
|
<Animated.SectionList
|
|
90
95
|
{...rest as SectionListRefreshProps}
|
|
@@ -92,26 +97,32 @@ export default React.forwardRef((props: RefreshListProps, ref: React.Ref<any>) =
|
|
|
92
97
|
refreshing={refreshState == RefreshState.HeaderRefreshing}
|
|
93
98
|
onRefresh={onRefresh}
|
|
94
99
|
keyExtractor={(_, index) => { return `sg-index-SectionList-${seed}-${index}` }}
|
|
95
|
-
contentContainerStyle={
|
|
100
|
+
contentContainerStyle={sectionListProps.sections?.length > 0 ? {} : { height: "100%" }}
|
|
96
101
|
ItemSeparatorComponent={ItemSeparatorComponent}
|
|
97
102
|
onEndReachedThreshold={0.1}
|
|
98
103
|
onEndReached={onEndReached}
|
|
99
104
|
showsVerticalScrollIndicator={false}
|
|
100
|
-
ListHeaderComponent={(_) => <ListHeaderComponent {...
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
// ListHeaderComponent={(_) => <ListHeaderComponent {...sectionListProps} />}
|
|
106
|
+
ListHeaderComponent={(_) => (
|
|
107
|
+
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
108
|
+
<ListHeaderComponent {...flatListProps} />
|
|
109
|
+
{sectionListProps.ListHeaderComponent}
|
|
110
|
+
</View>
|
|
111
|
+
)}
|
|
112
|
+
ListFooterComponent={(_) => <ListFooterComponent {...sectionListProps} />}
|
|
113
|
+
renderSectionHeader={sectionListProps.renderSectionHeader}
|
|
103
114
|
/>
|
|
104
115
|
)
|
|
105
116
|
|
|
106
117
|
case 'SwipeList':
|
|
118
|
+
let swipeListProps:SwipeListViewRefreshProps = props as SwipeListViewRefreshProps
|
|
107
119
|
const { renderHiddenItem = (data, rowMap) => (
|
|
108
120
|
<View style={{ backgroundColor: 'red', height: '100%', alignItems: 'flex-end', justifyContent: "center" }}>
|
|
109
121
|
<Text>Right </Text>
|
|
110
122
|
</View>
|
|
111
|
-
) } =
|
|
123
|
+
) } = swipeListProps
|
|
112
124
|
return (
|
|
113
125
|
<SwipeListView
|
|
114
|
-
|
|
115
126
|
{...rest as SwipeListViewRefreshProps}
|
|
116
127
|
rightOpenValue={-100}
|
|
117
128
|
leftOpenValue={0}
|
|
@@ -124,8 +135,13 @@ export default React.forwardRef((props: RefreshListProps, ref: React.Ref<any>) =
|
|
|
124
135
|
onEndReachedThreshold={0.1}
|
|
125
136
|
onEndReached={onEndReached}
|
|
126
137
|
showsVerticalScrollIndicator={false}
|
|
127
|
-
ListHeaderComponent={(
|
|
128
|
-
|
|
138
|
+
ListHeaderComponent={(_) => (
|
|
139
|
+
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
140
|
+
<ListHeaderComponent {...flatListProps} />
|
|
141
|
+
{swipeListProps.ListHeaderComponent}
|
|
142
|
+
</View>
|
|
143
|
+
)}
|
|
144
|
+
ListFooterComponent={(args) => <ListFooterComponent {...swipeListProps} />}
|
|
129
145
|
renderHiddenItem={renderHiddenItem}
|
|
130
146
|
/>
|
|
131
147
|
|
|
@@ -170,7 +186,7 @@ const ListFooterComponent = React.memo((props: RefreshListProps) => {
|
|
|
170
186
|
</View>
|
|
171
187
|
)
|
|
172
188
|
case RefreshState.EmptyData:
|
|
173
|
-
if (props.
|
|
189
|
+
if (props.renderListEmptyComponent) return props.renderListEmptyComponent()
|
|
174
190
|
return (
|
|
175
191
|
<View style={{
|
|
176
192
|
width: '100%', height: '100%',
|
package/lib/RefreshList/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: your name
|
|
3
3
|
* @Date: 2022-04-20 14:56:05
|
|
4
|
-
* @LastEditTime: 2022-
|
|
4
|
+
* @LastEditTime: 2022-12-29 10:46:57
|
|
5
5
|
* @LastEditors: shiguo
|
|
6
6
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
7
7
|
* @FilePath: /@aks-dev/easyui/lib/RefreshList/index.ts
|
|
@@ -29,7 +29,7 @@ type CommonProps = {
|
|
|
29
29
|
onFooterRefresh: (info: any) => void;
|
|
30
30
|
reload: () => void;
|
|
31
31
|
refreshState: RefreshState;
|
|
32
|
-
|
|
32
|
+
renderListEmptyComponent: () => React.ReactElement;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
|
|
@@ -52,7 +52,7 @@ export type SectionListRefreshProps = {
|
|
|
52
52
|
export type SwipeListViewRefreshProps = {
|
|
53
53
|
mode: 'SwipeList';
|
|
54
54
|
data: ItemT[];
|
|
55
|
-
} & IPropsSwipeListView<ItemT> & Partial<CommonProps
|
|
55
|
+
} & IPropsSwipeListView<ItemT> & Partial<CommonProps> & FlatListProps<ItemT> ;
|
|
56
56
|
|
|
57
57
|
export type RefreshListProps = FlatListRefreshProps | SwipeListViewRefreshProps | SectionListRefreshProps
|
|
58
58
|
|